diff options
author | Mike Reed <reed@google.com> | 2017-07-12 08:40:05 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-12 13:19:35 +0000 |
commit | 6ee29658202a0bd8394df5daed8db30321c01cc9 (patch) | |
tree | 1efed95d65f841bbbe8006165f37d9f03a0c0972 | |
parent | 016eef47d78091bab7fbd6a445996f252e3283fc (diff) |
remove unreachable perspective code for imageshader
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Bug: skia:
Change-Id: If9a7df3e1c387098b00bf1cc1a37c36c6d256ef1
Reviewed-on: https://skia-review.googlesource.com/22348
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
-rw-r--r-- | gn/core.gni | 1 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 4 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_matrix.h | 32 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_matrixProcs.cpp | 13 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_matrix_template.h | 22 | ||||
-rw-r--r-- | src/core/SkMatrix.cpp | 51 | ||||
-rw-r--r-- | src/core/SkPerspIter.h | 48 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_matrixProcs_neon.cpp | 1 | ||||
-rw-r--r-- | src/opts/SkBitmapProcState_matrix_neon.h | 107 |
9 files changed, 6 insertions, 273 deletions
diff --git a/gn/core.gni b/gn/core.gni index c0eecd9a2a..187a6de902 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -221,7 +221,6 @@ skia_core_sources = [ "$_src/core/SkPathMeasure.cpp", "$_src/core/SkPathPriv.h", "$_src/core/SkPathRef.cpp", - "$_src/core/SkPerspIter.h", "$_src/core/SkPicture.cpp", "$_src/core/SkPictureAnalyzer.cpp", "$_src/core/SkPictureCommon.h", diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 87e3ad8d1c..4df0f58100 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -90,6 +90,8 @@ static bool valid_for_filtering(unsigned dimension) { } bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) { + SkASSERT(!inv.hasPerspective()); + fPixmap.reset(); fInvMatrix = inv; fFilterQuality = paint.getFilterQuality(); @@ -648,7 +650,7 @@ SkBitmapProcState::MatrixProc SkBitmapProcState::getMatrixProc() const { scale/translate nofilter Y(4bytes) + N * X affine/perspective nofilter N * (X Y) scale/translate filter Y Y + N * (X X) - affine/perspective filter N * (Y Y X X) + affine filter N * (Y Y X X) */ int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const { int32_t size = static_cast<int32_t>(bufferSize); diff --git a/src/core/SkBitmapProcState_matrix.h b/src/core/SkBitmapProcState_matrix.h index ea784c675c..02dba44eeb 100644 --- a/src/core/SkBitmapProcState_matrix.h +++ b/src/core/SkBitmapProcState_matrix.h @@ -10,7 +10,6 @@ #define SCALE_FILTER_NAME MAKENAME(_filter_scale) #define AFFINE_FILTER_NAME MAKENAME(_filter_affine) -#define PERSP_FILTER_NAME MAKENAME(_filter_persp) #define PACK_FILTER_X_NAME MAKENAME(_pack_filter_x) #define PACK_FILTER_Y_NAME MAKENAME(_pack_filter_y) @@ -28,9 +27,6 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s, uint32_t xy[], int count, int x, int y); void AFFINE_FILTER_NAME(const SkBitmapProcState& s, uint32_t xy[], int count, int x, int y); -void PERSP_FILTER_NAME(const SkBitmapProcState& s, - uint32_t* SK_RESTRICT xy, int count, - int x, int y); static inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max, SkFixed one PREAMBLE_PARAM_Y) { @@ -112,33 +108,6 @@ void AFFINE_FILTER_NAME(const SkBitmapProcState& s, } while (--count != 0); } -void PERSP_FILTER_NAME(const SkBitmapProcState& s, - uint32_t* SK_RESTRICT xy, int count, - int x, int y) { - SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); - - PREAMBLE(s); - unsigned maxX = s.fPixmap.width() - 1; - unsigned maxY = s.fPixmap.height() - 1; - SkFixed oneX = s.fFilterOneX; - SkFixed oneY = s.fFilterOneY; - - SkPerspIter iter(s.fInvMatrix, - SkIntToScalar(x) + SK_ScalarHalf, - SkIntToScalar(y) + SK_ScalarHalf, count); - - while ((count = iter.next()) != 0) { - const SkFixed* SK_RESTRICT srcXY = iter.getXY(); - do { - *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY, - oneY PREAMBLE_ARG_Y); - *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX, - oneX PREAMBLE_ARG_X); - srcXY += 2; - } while (--count != 0); - } -} - #undef MAKENAME #undef TILEX_PROCF #undef TILEY_PROCF @@ -148,7 +117,6 @@ void PERSP_FILTER_NAME(const SkBitmapProcState& s, #undef SCALE_FILTER_NAME #undef AFFINE_FILTER_NAME -#undef PERSP_FILTER_NAME #undef PREAMBLE #undef PREAMBLE_PARAM_X diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp index 08753bed99..2860e4b250 100644 --- a/src/core/SkBitmapProcState_matrixProcs.cpp +++ b/src/core/SkBitmapProcState_matrixProcs.cpp @@ -14,7 +14,6 @@ */ #include "SkBitmapProcState.h" -#include "SkPerspIter.h" #include "SkShader.h" #include "SkUtils.h" #include "SkUtilsArm.h" @@ -89,8 +88,6 @@ static SkBitmapProcState::MatrixProc ClampX_ClampY_Procs[] = { ClampX_ClampY_filter_scale, ClampX_ClampY_nofilter_affine, ClampX_ClampY_filter_affine, - NoFilterProc_Persp<ClampTileProcs>, - ClampX_ClampY_filter_persp }; #define MAKENAME(suffix) RepeatX_RepeatY ## suffix @@ -115,8 +112,6 @@ static SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs[] = { RepeatX_RepeatY_filter_scale, NoFilterProc_Affine<RepeatTileProcs>, RepeatX_RepeatY_filter_affine, - NoFilterProc_Persp<RepeatTileProcs>, - RepeatX_RepeatY_filter_persp }; #endif @@ -146,8 +141,6 @@ static SkBitmapProcState::MatrixProc GeneralXY_Procs[] = { GeneralXY_filter_scale, NoFilterProc_Affine<GeneralTileProcs>, GeneralXY_filter_affine, - NoFilterProc_Persp<GeneralTileProcs>, - GeneralXY_filter_persp }; /////////////////////////////////////////////////////////////////////////////// @@ -449,6 +442,8 @@ static void mirrorx_nofilter_trans(const SkBitmapProcState& s, /////////////////////////////////////////////////////////////////////////////// SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc(bool trivial_matrix) { + SkASSERT((fInvType & SkMatrix::kPerspective_Mask) == 0); + // test_int_tileprocs(); // check for our special case when there is no scale/affine/perspective if (trivial_matrix && kNone_SkFilterQuality == fFilterQuality) { @@ -467,9 +462,7 @@ SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc(bool trivial_m if (fFilterQuality != kNone_SkFilterQuality) { index = 1; } - if (fInvType & SkMatrix::kPerspective_Mask) { - index += 4; - } else if (fInvType & SkMatrix::kAffine_Mask) { + if (fInvType & SkMatrix::kAffine_Mask) { index += 2; } diff --git a/src/core/SkBitmapProcState_matrix_template.h b/src/core/SkBitmapProcState_matrix_template.h index c38610a077..772c8622c5 100644 --- a/src/core/SkBitmapProcState_matrix_template.h +++ b/src/core/SkBitmapProcState_matrix_template.h @@ -98,26 +98,4 @@ void NoFilterProc_Affine(const SkBitmapProcState& s, uint32_t xy[], } } -template <typename TileProc> -void NoFilterProc_Persp(const SkBitmapProcState& s, uint32_t* SK_RESTRICT xy, - int count, int x, int y) { - SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); - - int maxX = s.fPixmap.width() - 1; - int maxY = s.fPixmap.height() - 1; - - SkPerspIter iter(s.fInvMatrix, - SkIntToScalar(x) + SK_ScalarHalf, - SkIntToScalar(y) + SK_ScalarHalf, count); - - while ((count = iter.next()) != 0) { - const SkFixed* SK_RESTRICT srcXY = iter.getXY(); - while (--count >= 0) { - *xy++ = (TileProc::Y(s, srcXY[1], maxY) << 16) | - TileProc::X(s, srcXY[0], maxX); - srcXY += 2; - } - } -} - #endif diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 8517d87555..5feee12874 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -1268,57 +1268,6 @@ SkVector SkMatrix::fixedStepInX(SkScalar y) const { /////////////////////////////////////////////////////////////////////////////// -#include "SkPerspIter.h" - -SkPerspIter::SkPerspIter(const SkMatrix& m, SkScalar x0, SkScalar y0, int count) - : fMatrix(m), fSX(x0), fSY(y0), fCount(count) { - SkPoint pt; - - SkMatrix::Persp_xy(m, x0, y0, &pt); - fX = SkScalarToFixed(pt.fX); - fY = SkScalarToFixed(pt.fY); -} - -int SkPerspIter::next() { - int n = fCount; - - if (0 == n) { - return 0; - } - SkPoint pt; - SkFixed x = fX; - SkFixed y = fY; - SkFixed dx, dy; - - if (n >= kCount) { - n = kCount; - fSX += SkIntToScalar(kCount); - SkMatrix::Persp_xy(fMatrix, fSX, fSY, &pt); - fX = SkScalarToFixed(pt.fX); - fY = SkScalarToFixed(pt.fY); - dx = (fX - x) >> kShift; - dy = (fY - y) >> kShift; - } else { - fSX += SkIntToScalar(n); - SkMatrix::Persp_xy(fMatrix, fSX, fSY, &pt); - fX = SkScalarToFixed(pt.fX); - fY = SkScalarToFixed(pt.fY); - dx = (fX - x) / n; - dy = (fY - y) / n; - } - - SkFixed* p = fStorage; - for (int i = 0; i < n; i++) { - *p++ = x; x += dx; - *p++ = y; y += dy; - } - - fCount -= n; - return n; -} - -/////////////////////////////////////////////////////////////////////////////// - static inline bool checkForZero(float x) { return x*x == 0; } diff --git a/src/core/SkPerspIter.h b/src/core/SkPerspIter.h deleted file mode 100644 index c0a9083bee..0000000000 --- a/src/core/SkPerspIter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2006 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#ifndef SkPerspIter_DEFINED -#define SkPerspIter_DEFINED - -#include "SkFixed.h" -#include "SkMatrix.h" - -class SkPerspIter { -public: - /** Iterate a line through the matrix [x,y] ... [x+count-1, y]. - @param m The matrix we will be iterating a line through - @param x The initial X coordinate to be mapped through the matrix - @param y The initial Y coordinate to be mapped through the matrix - @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map - */ - SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count); - - /** Return the buffer of [x,y] fixed point values we will be filling. - This always returns the same value, so it can be saved across calls to - next(). - */ - const SkFixed* getXY() const { return fStorage; } - - /** Return the number of [x,y] pairs that have been filled in the getXY() buffer. - When this returns 0, the iterator is finished. - */ - int next(); - -private: - enum { - kShift = 4, - kCount = (1 << kShift) - }; - const SkMatrix& fMatrix; - SkFixed fStorage[kCount * 2]; - SkFixed fX, fY; - SkScalar fSX, fSY; - int fCount; -}; - -#endif diff --git a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp index 612ef04720..1efd1eddfe 100644 --- a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp +++ b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp @@ -5,7 +5,6 @@ */ #include "SkBitmapProcState.h" -#include "SkPerspIter.h" #include "SkShader.h" #include "SkUtilsArm.h" #include "SkBitmapProcState_utils.h" diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h index fb91547571..fabe45d4c3 100644 --- a/src/opts/SkBitmapProcState_matrix_neon.h +++ b/src/opts/SkBitmapProcState_matrix_neon.h @@ -11,8 +11,6 @@ #define SCALE_FILTER_NAME MAKENAME(_filter_scale) #define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine) #define AFFINE_FILTER_NAME MAKENAME(_filter_affine) -#define PERSP_NOFILTER_NAME MAKENAME(_nofilter_persp) -#define PERSP_FILTER_NAME MAKENAME(_filter_persp) #define PACK_FILTER_X_NAME MAKENAME(_pack_filter_x) #define PACK_FILTER_Y_NAME MAKENAME(_pack_filter_y) @@ -180,55 +178,6 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s, } } -static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, - uint32_t* SK_RESTRICT xy, - int count, int x, int y) { - SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); - - PREAMBLE(s); - // max{X,Y} are int here, but later shown/assumed to fit in 16 bits - int maxX = s.fPixmap.width() - 1; - int maxY = s.fPixmap.height() - 1; - - SkPerspIter iter(s.fInvMatrix, - SkIntToScalar(x) + SK_ScalarHalf, - SkIntToScalar(y) + SK_ScalarHalf, count); - - while ((count = iter.next()) != 0) { - const SkFixed* SK_RESTRICT srcXY = iter.getXY(); - - if (count >= 8) { - int32_t *mysrc = (int32_t *) srcXY; - int16_t *mydst = (int16_t *) xy; - do { - int16x8x2_t hi16; - int32x4x2_t xy1, xy2; - - xy1 = vld2q_s32(mysrc); - xy2 = vld2q_s32(mysrc+8); - - hi16.val[0] = TILEX_PROCF_NEON8(xy1.val[0], xy2.val[0], maxX); - hi16.val[1] = TILEY_PROCF_NEON8(xy1.val[1], xy2.val[1], maxY); - - vst2q_s16(mydst, hi16); - - count -= 8; // 8 iterations - mysrc += 16; // 16 longs - mydst += 16; // 16 shorts, aka 8 longs - } while (count >= 8); - // get xy and srcXY fixed up - srcXY = (const SkFixed *) mysrc; - xy = (uint32_t *) mydst; - } - - while (--count >= 0) { - *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) | - TILEX_PROCF(srcXY[0], maxX); - srcXY += 2; - } - } -} - static inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max, SkFixed one PREAMBLE_PARAM_Y) { unsigned i = TILEY_PROCF(f, max); @@ -410,65 +359,11 @@ static void AFFINE_FILTER_NAME(const SkBitmapProcState& s, } } -static void PERSP_FILTER_NAME(const SkBitmapProcState& s, - uint32_t* SK_RESTRICT xy, int count, - int x, int y) { - SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); - - PREAMBLE(s); - unsigned maxX = s.fPixmap.width() - 1; - unsigned maxY = s.fPixmap.height() - 1; - SkFixed oneX = s.fFilterOneX; - SkFixed oneY = s.fFilterOneY; - - SkPerspIter iter(s.fInvMatrix, - SkIntToScalar(x) + SK_ScalarHalf, - SkIntToScalar(y) + SK_ScalarHalf, count); - - while ((count = iter.next()) != 0) { - const SkFixed* SK_RESTRICT srcXY = iter.getXY(); - - while (count >= 4) { - int32x4_t wide_x, wide_y; - int32x4x2_t vxy, vresyx; - - // load src: x-y-x-y-x-y-x-y - vxy = vld2q_s32(srcXY); - - // do the X side, then the Y side, then interleave them - wide_x = vsubq_s32(vxy.val[0], vdupq_n_s32(oneX>>1)); - wide_y = vsubq_s32(vxy.val[1], vdupq_n_s32(oneY>>1)); - - vresyx.val[0] = PACK_FILTER_Y4_NAME(wide_y, maxY, oneY PREAMBLE_ARG_Y); - vresyx.val[1] = PACK_FILTER_X4_NAME(wide_x, maxX, oneX PREAMBLE_ARG_X); - - // store interleaved as y-x-y-x-y-x-y-x (NB != read order) - vst2q_s32((int32_t*)xy, vresyx); - - // on to the next iteration - srcXY += 2*4; - count -= 4; - xy += 2*4; - } - - while (--count >= 0) { - // NB: we read x/y, we write y/x - *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY, - oneY PREAMBLE_ARG_Y); - *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX, - oneX PREAMBLE_ARG_X); - srcXY += 2; - } - } -} - const SkBitmapProcState::MatrixProc MAKENAME(_Procs)[] = { SCALE_NOFILTER_NAME, SCALE_FILTER_NAME, AFFINE_NOFILTER_NAME, AFFINE_FILTER_NAME, - PERSP_NOFILTER_NAME, - PERSP_FILTER_NAME }; #undef TILEX_PROCF_NEON8 @@ -488,8 +383,6 @@ const SkBitmapProcState::MatrixProc MAKENAME(_Procs)[] = { #undef SCALE_FILTER_NAME #undef AFFINE_NOFILTER_NAME #undef AFFINE_FILTER_NAME -#undef PERSP_NOFILTER_NAME -#undef PERSP_FILTER_NAME #undef PREAMBLE #undef PREAMBLE_PARAM_X |