diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 79 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.h | 1 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 36 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 7 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_procs.h | 111 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_sample.h | 40 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_shaderproc.h | 8 | ||||
-rw-r--r-- | src/core/SkBlitter_RGB16.cpp | 144 | ||||
-rw-r--r-- | src/core/SkColorShader.h | 3 | ||||
-rw-r--r-- | src/core/SkFilterShader.cpp | 3 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 23 |
11 files changed, 17 insertions, 438 deletions
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index 6c9410ee32..e5b577a20c 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -68,11 +68,6 @@ void SkBitmapProcShader::flatten(SkWriteBuffer& buffer) const { buffer.writeUInt(fTileModeY); } -static bool only_scale_and_translate(const SkMatrix& matrix) { - unsigned mask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask; - return (matrix.getType() & ~mask) == 0; -} - bool SkBitmapProcShader::isOpaque() const { return fRawBitmap.isOpaque(); } @@ -110,47 +105,10 @@ SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext(const SkSha : INHERITED(shader, rec) , fState(state) { - const SkPixmap& pixmap = fState->fPixmap; - bool isOpaque = pixmap.isOpaque(); - - // update fFlags - uint32_t flags = 0; - if (isOpaque && (255 == this->getPaintAlpha())) { - flags |= kOpaqueAlpha_Flag; - } - - switch (pixmap.colorType()) { - case kRGB_565_SkColorType: - flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); - break; - case kIndex_8_SkColorType: - case kN32_SkColorType: - if (isOpaque) { - flags |= kHasSpan16_Flag; - } - break; - case kAlpha_8_SkColorType: - break; // never set kHasSpan16_Flag - default: - break; + fFlags = 0; + if (fState->fPixmap.isOpaque() && (255 == this->getPaintAlpha())) { + fFlags |= kOpaqueAlpha_Flag; } - - if (rec.fPaint->isDither() && pixmap.colorType() != kRGB_565_SkColorType) { - // gradients can auto-dither in their 16bit sampler, but we don't so - // we clear the flag here. - flags &= ~kHasSpan16_Flag; - } - - // if we're only 1-pixel high, and we don't rotate, then we can claim this - if (1 == pixmap.height() && - only_scale_and_translate(this->getTotalInverse())) { - flags |= kConstInY32_Flag; - if (flags & kHasSpan16_Flag) { - flags |= kConstInY16_Flag; - } - } - - fFlags = flags; } SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { @@ -221,37 +179,6 @@ SkShader::Context::ShadeProc SkBitmapProcShader::BitmapProcShaderContext::asASha return nullptr; } -void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint16_t dstC[], - int count) { - const SkBitmapProcState& state = *fState; - if (state.getShaderProc16()) { - state.getShaderProc16()(&state, x, y, dstC, count); - return; - } - - uint32_t buffer[BUF_MAX]; - SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); - SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); - int max = state.maxCountForBufferSize(sizeof(buffer)); - - SkASSERT(state.fPixmap.addr()); - - for (;;) { - int n = count; - if (n > max) { - n = max; - } - mproc(state, buffer, n, x, y); - sproc(state, buffer, n, dstC); - - if ((count -= n) == 0) { - break; - } - x += n; - dstC += n; - } -} - /////////////////////////////////////////////////////////////////////////////// #include "SkUnPreMultiply.h" diff --git a/src/core/SkBitmapProcShader.h b/src/core/SkBitmapProcShader.h index b69b028616..0346eff0e2 100644 --- a/src/core/SkBitmapProcShader.h +++ b/src/core/SkBitmapProcShader.h @@ -43,7 +43,6 @@ protected: void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; ShadeProc asAShadeProc(void** ctx) override; - void shadeSpan16(int x, int y, uint16_t dstC[], int count) override; uint32_t getFlags() const override { return fFlags; } diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index d18dfb5d0f..b1438cb8a0 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -21,7 +21,6 @@ #if !SK_ARM_NEON_IS_NONE // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp -extern const SkBitmapProcState::SampleProc16 gSkBitmapProcStateSample16_neon[]; extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, int, uint16_t*); extern void Clamp_S16_D16_filter_DX_shaderproc_neon(const void *, int, int, uint16_t*, int); @@ -193,7 +192,6 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { fShaderProc32 = nullptr; fShaderProc16 = nullptr; fSampleProc32 = nullptr; - fSampleProc16 = nullptr; // recompute the triviality of the matrix here because we may have // changed it! @@ -336,45 +334,13 @@ bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, SG8_alpha_D32_filter_DX, SG8_alpha_D32_filter_DX }; - - static const SampleProc16 gSkBitmapProcStateSample16[] = { - S32_D16_nofilter_DXDY, - S32_D16_nofilter_DX, - S32_D16_filter_DXDY, - S32_D16_filter_DX, - - S16_D16_nofilter_DXDY, - S16_D16_nofilter_DX, - S16_D16_filter_DXDY, - S16_D16_filter_DX, - - SI8_D16_nofilter_DXDY, - SI8_D16_nofilter_DX, - SI8_D16_filter_DXDY, - SI8_D16_filter_DX, - - // Don't support 4444 -> 565 - nullptr, nullptr, nullptr, nullptr, - // Don't support A8 -> 565 - nullptr, nullptr, nullptr, nullptr, - // Don't support G8 -> 565 (but we could) - nullptr, nullptr, nullptr, nullptr - }; #endif fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; index >>= 1; // shift away any opaque/alpha distinction - fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index]; // our special-case shaderprocs - if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) { - if (clampClamp) { - fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderproc); - } else if (SkShader::kRepeat_TileMode == fTileModeX && - SkShader::kRepeat_TileMode == fTileModeY) { - fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shaderproc); - } - } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && clampClamp) { + if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && clampClamp) { fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shaderproc); } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) { fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc; diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index 24c6db6552..34f70c55e7 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -46,11 +46,6 @@ struct SkBitmapProcState { int count, SkPMColor colors[]); - typedef void (*SampleProc16)(const SkBitmapProcState&, - const uint32_t[], - int count, - uint16_t colors[]); - typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1 @@ -117,7 +112,6 @@ struct SkBitmapProcState { MatrixProc getMatrixProc() const { return fMatrixProc; } #endif SampleProc32 getSampleProc32() const { return fSampleProc32; } - SampleProc16 getSampleProc16() const { return fSampleProc16; } private: friend class SkBitmapProcShader; @@ -128,7 +122,6 @@ private: // These are used if the shaderproc is nullptr MatrixProc fMatrixProc; // chooseProcs SampleProc32 fSampleProc32; // chooseProcs - SampleProc16 fSampleProc16; // chooseProcs const SkBitmapProvider fProvider; diff --git a/src/core/SkBitmapProcState_procs.h b/src/core/SkBitmapProcState_procs.h index 03e192719c..cec079eae5 100644 --- a/src/core/SkBitmapProcState_procs.h +++ b/src/core/SkBitmapProcState_procs.h @@ -1,4 +1,3 @@ - /* * Copyright 2011 Google Inc. * @@ -88,7 +87,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) NAME_WRAP(Filter_32_opaque)(x, y, a, b, c, d, dst) #define MAKENAME(suffix) NAME_WRAP(S32_opaque_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE SkPMColor #define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \ SkASSERT(state.fAlphaScale == 256) @@ -100,7 +98,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) NAME_WRAP(Filter_32_alpha)(x, y, a, b, c, d, dst, alphaScale) #define MAKENAME(suffix) NAME_WRAP(S32_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE SkPMColor #define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \ SkASSERT(state.fAlphaScale < 256) @@ -119,7 +116,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, } while (0) #define MAKENAME(suffix) NAME_WRAP(S16_opaque_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint16_t #define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale == 256) @@ -135,7 +131,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, } while (0) #define MAKENAME(suffix) NAME_WRAP(S16_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint16_t #define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale < 256) @@ -150,7 +145,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) NAME_WRAP(Filter_32_opaque)(x, y, a, b, c, d, dst) #define MAKENAME(suffix) NAME_WRAP(SI8_opaque_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint8_t #define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale == 256) @@ -164,7 +158,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) NAME_WRAP(Filter_32_alpha)(x, y, a, b, c, d, dst, alphaScale) #define MAKENAME(suffix) NAME_WRAP(SI8_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint8_t #define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale < 256) @@ -181,7 +174,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) *(dst) = Filter_4444_D32(x, y, a, b, c, d) #define MAKENAME(suffix) NAME_WRAP(S4444_opaque_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE SkPMColor16 #define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale == 256) @@ -197,7 +189,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, } while (0) #define MAKENAME(suffix) NAME_WRAP(S4444_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE SkPMColor16 #define CHECKSTATE(state) SkASSERT(kARGB_4444_SkColorType == state.fPixmap.colorType()); \ SkASSERT(state.fAlphaScale < 256) @@ -216,7 +207,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, } while (0) #define MAKENAME(suffix) NAME_WRAP(SA8_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint8_t #define CHECKSTATE(state) SkASSERT(kAlpha_8_SkColorType == state.fPixmap.colorType()); #define PREAMBLE(state) const SkPMColor pmColor = state.fPaintPMColor; @@ -235,7 +225,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, } while (0) #define MAKENAME(suffix) NAME_WRAP(SG8_alpha_D32 ## suffix) -#define DSTSIZE 32 #define SRCTYPE uint8_t #define CHECKSTATE(state) SkASSERT(kGray_8_SkColorType == state.fPixmap.colorType()); #define PREAMBLE(state) unsigned alphaScale = state.fAlphaScale @@ -243,105 +232,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define SRC_TO_FILTER(src) src #include "SkBitmapProcState_sample.h" -/***************************************************************************** - * - * D16 functions - * - */ - -// SRC == 8888 - -#undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d, dst) \ - do { \ - SkPMColor dstColor; \ - NAME_WRAP(Filter_32_opaque)(x, y, a, b, c, d, &dstColor); \ - (*dst) = SkPixel32ToPixel16(dstColor); \ - } while (0) - -#define MAKENAME(suffix) NAME_WRAP(S32_D16 ## suffix) -#define DSTSIZE 16 -#define SRCTYPE SkPMColor -#define CHECKSTATE(state) SkASSERT(4 == state.fPixmap.info().bytesPerPixel()); \ - SkASSERT(state.fPixmap.isOpaque()) -#define RETURNDST(src) SkPixel32ToPixel16(src) -#define SRC_TO_FILTER(src) src -#include "SkBitmapProcState_sample.h" - -// SRC == 565 - -#undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d, dst) \ - do { \ - uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ - *(dst) = SkCompact_rgb_16((tmp) >> 5); \ - } while (0) - -#define MAKENAME(suffix) NAME_WRAP(S16_D16 ## suffix) -#define DSTSIZE 16 -#define SRCTYPE uint16_t -#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()) -#define RETURNDST(src) src -#define SRC_TO_FILTER(src) src -#include "SkBitmapProcState_sample.h" - -// SRC == Index8 - -#undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d, dst) \ - do { \ - uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ - *(dst) = SkCompact_rgb_16((tmp) >> 5); \ - } while (0) - -#define MAKENAME(suffix) NAME_WRAP(SI8_D16 ## suffix) -#define DSTSIZE 16 -#define SRCTYPE uint8_t -#define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()); \ - SkASSERT(state.fPixmap.isOpaque()) -#define PREAMBLE(state) const uint16_t* SK_RESTRICT table = state.fPixmap.ctable()->read16BitCache() -#define RETURNDST(src) table[src] -#define SRC_TO_FILTER(src) table[src] -#define POSTAMBLE(state) -#include "SkBitmapProcState_sample.h" - -/////////////////////////////////////////////////////////////////////////////// - -#undef FILTER_PROC -#define FILTER_PROC(x, y, a, b, c, d, dst) \ - do { \ - uint32_t tmp = Filter_565_Expanded(x, y, a, b, c, d); \ - *(dst) = SkCompact_rgb_16((tmp) >> 5); \ - } while (0) - - -// clamp - -#define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) -#define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) -#define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) -#define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) - -#define MAKENAME(suffix) NAME_WRAP(Clamp_S16_D16 ## suffix) -#define SRCTYPE uint16_t -#define DSTTYPE uint16_t -#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()) -#define SRC_TO_FILTER(src) src -#include "SkBitmapProcState_shaderproc.h" - - -#define TILEX_PROCF(fx, max) (((fx) & 0xFFFF) * ((max) + 1) >> 16) -#define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16) -#define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) -#define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) - -#define MAKENAME(suffix) NAME_WRAP(Repeat_S16_D16 ## suffix) -#define SRCTYPE uint16_t -#define DSTTYPE uint16_t -#define CHECKSTATE(state) SkASSERT(kRGB_565_SkColorType == state.fPixmap.colorType()) -#define SRC_TO_FILTER(src) src -#include "SkBitmapProcState_shaderproc.h" - #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) @@ -352,7 +242,6 @@ static inline U8CPU Filter_8(unsigned x, unsigned y, #define FILTER_PROC(x, y, a, b, c, d, dst) NAME_WRAP(Filter_32_opaque)(x, y, a, b, c, d, dst) #define MAKENAME(suffix) NAME_WRAP(Clamp_SI8_opaque_D32 ## suffix) #define SRCTYPE uint8_t -#define DSTTYPE uint32_t #define CHECKSTATE(state) SkASSERT(kIndex_8_SkColorType == state.fPixmap.colorType()) #define PREAMBLE(state) const SkPMColor* SK_RESTRICT table = state.fPixmap.ctable()->readColors() #define SRC_TO_FILTER(src) table[src] diff --git a/src/core/SkBitmapProcState_sample.h b/src/core/SkBitmapProcState_sample.h index f70b758ac2..4a022884d5 100644 --- a/src/core/SkBitmapProcState_sample.h +++ b/src/core/SkBitmapProcState_sample.h @@ -7,40 +7,23 @@ #include "SkUtils.h" -#if DSTSIZE==32 - #define DSTTYPE SkPMColor -#elif DSTSIZE==16 - #define DSTTYPE uint16_t -#else - #error "need DSTSIZE to be 32 or 16" -#endif - -#if (DSTSIZE == 32) - #define BITMAPPROC_MEMSET(ptr, value, n) sk_memset32(ptr, value, n) -#elif (DSTSIZE == 16) - #define BITMAPPROC_MEMSET(ptr, value, n) sk_memset16(ptr, value, n) -#else - #error "unsupported DSTSIZE" -#endif - - // declare functions externally to suppress warnings. void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors); + int count, SkPMColor* SK_RESTRICT colors); void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors); + int count, SkPMColor* SK_RESTRICT colors); void MAKENAME(_filter_DX)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors); + int count, SkPMColor* SK_RESTRICT colors); void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors); + int count, SkPMColor* SK_RESTRICT colors); void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors) { + int count, SkPMColor* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != nullptr); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); SkDEBUGCODE(CHECKSTATE(s);) @@ -82,7 +65,7 @@ void MAKENAME(_nofilter_DXDY)(const SkBitmapProcState& s, void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors) { + int count, SkPMColor* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != nullptr); SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); @@ -104,8 +87,8 @@ void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, if (1 == s.fPixmap.width()) { src = srcAddr[0]; - DSTTYPE dstValue = RETURNDST(src); - BITMAPPROC_MEMSET(colors, dstValue, count); + SkPMColor dstValue = RETURNDST(src); + sk_memset32(colors, dstValue, count); } else { int i; for (i = (count >> 2); i > 0; --i) { @@ -137,7 +120,7 @@ void MAKENAME(_nofilter_DX)(const SkBitmapProcState& s, void MAKENAME(_filter_DX)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors) { + int count, SkPMColor* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != nullptr); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); SkDEBUGCODE(CHECKSTATE(s);) @@ -183,7 +166,7 @@ void MAKENAME(_filter_DX)(const SkBitmapProcState& s, } void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, - int count, DSTTYPE* SK_RESTRICT colors) { + int count, SkPMColor* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != nullptr); SkASSERT(s.fFilterLevel != kNone_SkFilterQuality); SkDEBUGCODE(CHECKSTATE(s);) @@ -225,8 +208,6 @@ void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, } #undef MAKENAME -#undef DSTSIZE -#undef DSTTYPE #undef SRCTYPE #undef CHECKSTATE #undef RETURNDST @@ -245,4 +226,3 @@ void MAKENAME(_filter_DXDY)(const SkBitmapProcState& s, #undef GET_FILTER_ROW #undef GET_FILTER_ROW_PROC #undef GET_FILTER_PROC -#undef BITMAPPROC_MEMSET diff --git a/src/core/SkBitmapProcState_shaderproc.h b/src/core/SkBitmapProcState_shaderproc.h index b1fdc5f056..d41ff063e4 100644 --- a/src/core/SkBitmapProcState_shaderproc.h +++ b/src/core/SkBitmapProcState_shaderproc.h @@ -1,4 +1,3 @@ - /* * Copyright 2011 Google Inc. * @@ -12,11 +11,9 @@ // Can't be static in the general case because some of these implementations // will be defined and referenced in different object files. -void SCALE_FILTER_NAME(const void* sIn, int x, int y, - DSTTYPE* SK_RESTRICT colors, int count); +void SCALE_FILTER_NAME(const void* sIn, int x, int y, SkPMColor* SK_RESTRICT colors, int count); -void SCALE_FILTER_NAME(const void* sIn, int x, int y, - DSTTYPE* SK_RESTRICT colors, int count) { +void SCALE_FILTER_NAME(const void* sIn, int x, int y, SkPMColor* SK_RESTRICT colors, int count) { const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) == 0); @@ -85,7 +82,6 @@ void SCALE_FILTER_NAME(const void* sIn, int x, int y, #undef TILEY_LOW_BITS #undef MAKENAME #undef SRCTYPE -#undef DSTTYPE #undef CHECKSTATE #undef SRC_TO_FILTER #undef FILTER_TO_DST diff --git a/src/core/SkBlitter_RGB16.cpp b/src/core/SkBlitter_RGB16.cpp index 06dfeea1c1..38edd60a9d 100644 --- a/src/core/SkBlitter_RGB16.cpp +++ b/src/core/SkBlitter_RGB16.cpp @@ -134,20 +134,6 @@ private: typedef SkShaderBlitter INHERITED; }; -// used only if the shader can perform shadSpan16 -class SkRGB16_Shader16_Blitter : public SkRGB16_Shader_Blitter { -public: - SkRGB16_Shader16_Blitter(const SkPixmap& device, const SkPaint& paint, - SkShader::Context* shaderContext); - void blitH(int x, int y, int width) override; - virtual void blitAntiH(int x, int y, const SkAlpha* antialias, - const int16_t* runs) override; - void blitRect(int x, int y, int width, int height) override; - -private: - typedef SkRGB16_Shader_Blitter INHERITED; -}; - class SkRGB16_Shader_Xfermode_Blitter : public SkShaderBlitter { public: SkRGB16_Shader_Xfermode_Blitter(const SkPixmap& device, const SkPaint& paint, @@ -692,131 +678,6 @@ void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) { /////////////////////////////////////////////////////////////////////////////// -SkRGB16_Shader16_Blitter::SkRGB16_Shader16_Blitter(const SkPixmap& device, - const SkPaint& paint, - SkShader::Context* shaderContext) - : SkRGB16_Shader_Blitter(device, paint, shaderContext) -{ - SkASSERT(SkShader::CanCallShadeSpan16(fShaderFlags)); -} - -void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) { - SkASSERT(x + width <= fDevice.width()); - - uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); - SkShader::Context* shaderContext = fShaderContext; - - int alpha = shaderContext->getSpan16Alpha(); - if (0xFF == alpha) { - shaderContext->shadeSpan16(x, y, device, width); - } else { - uint16_t* span16 = (uint16_t*)fBuffer; - shaderContext->shadeSpan16(x, y, span16, width); - SkBlendRGB16(span16, device, SkAlpha255To256(alpha), width); - } -} - -void SkRGB16_Shader16_Blitter::blitRect(int x, int y, int width, int height) { - SkShader::Context* shaderContext = fShaderContext; - uint16_t* dst = fDevice.writable_addr16(x, y); - size_t dstRB = fDevice.rowBytes(); - int alpha = shaderContext->getSpan16Alpha(); - - if (0xFF == alpha) { - if (fShaderFlags & SkShader::kConstInY16_Flag) { - // have the shader blit directly into the device the first time - shaderContext->shadeSpan16(x, y, dst, width); - // and now just memcpy that line on the subsequent lines - if (--height > 0) { - const uint16_t* orig = dst; - do { - dst = (uint16_t*)((char*)dst + dstRB); - memcpy(dst, orig, width << 1); - } while (--height); - } - } else { // need to call shadeSpan16 for every line - do { - shaderContext->shadeSpan16(x, y, dst, width); - y += 1; - dst = (uint16_t*)((char*)dst + dstRB); - } while (--height); - } - } else { - int scale = SkAlpha255To256(alpha); - uint16_t* span16 = (uint16_t*)fBuffer; - if (fShaderFlags & SkShader::kConstInY16_Flag) { - shaderContext->shadeSpan16(x, y, span16, width); - do { - SkBlendRGB16(span16, dst, scale, width); - dst = (uint16_t*)((char*)dst + dstRB); - } while (--height); - } else { - do { - shaderContext->shadeSpan16(x, y, span16, width); - SkBlendRGB16(span16, dst, scale, width); - y += 1; - dst = (uint16_t*)((char*)dst + dstRB); - } while (--height); - } - } -} - -void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y, - const SkAlpha* SK_RESTRICT antialias, - const int16_t* SK_RESTRICT runs) { - SkShader::Context* shaderContext = fShaderContext; - SkPMColor* SK_RESTRICT span = fBuffer; - uint16_t* SK_RESTRICT device = fDevice.writable_addr16(x, y); - - int alpha = shaderContext->getSpan16Alpha(); - uint16_t* span16 = (uint16_t*)span; - - if (0xFF == alpha) { - for (;;) { - int count = *runs; - if (count <= 0) { - break; - } - SkASSERT(count <= fDevice.width()); // don't overrun fBuffer - - int aa = *antialias; - if (aa == 255) { - // go direct to the device! - shaderContext->shadeSpan16(x, y, device, count); - } else if (aa) { - shaderContext->shadeSpan16(x, y, span16, count); - SkBlendRGB16(span16, device, SkAlpha255To256(aa), count); - } - device += count; - runs += count; - antialias += count; - x += count; - } - } else { // span alpha is < 255 - alpha = SkAlpha255To256(alpha); - for (;;) { - int count = *runs; - if (count <= 0) { - break; - } - SkASSERT(count <= fDevice.width()); // don't overrun fBuffer - - int aa = SkAlphaMul(*antialias, alpha); - if (aa) { - shaderContext->shadeSpan16(x, y, span16, count); - SkBlendRGB16(span16, device, SkAlpha255To256(aa), count); - } - - device += count; - runs += count; - antialias += count; - x += count; - } - } -} - -/////////////////////////////////////////////////////////////////////////////// - SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device, const SkPaint& paint, SkShader::Context* shaderContext) @@ -834,8 +695,7 @@ SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device, if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) { flags |= SkBlitRow::kSrcPixelAlpha_Flag; } - // don't dither if the shader is really 16bit - if (paint.isDither() && !(shaderFlags & SkShader::kIntrinsicly16_Flag)) { + if (paint.isDither()) { flags |= SkBlitRow::kDither_Flag; } // used when we know our global alpha is 0xFF @@ -1047,8 +907,6 @@ SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint, if (mode) { blitter = allocator->createT<SkRGB16_Shader_Xfermode_Blitter>(device, paint, shaderContext); - } else if (shaderContext->canCallShadeSpan16()) { - blitter = allocator->createT<SkRGB16_Shader16_Blitter>(device, paint, shaderContext); } else { blitter = allocator->createT<SkRGB16_Shader_Blitter>(device, paint, shaderContext); } diff --git a/src/core/SkColorShader.h b/src/core/SkColorShader.h index e3fddb231a..25a1d6c8d0 100644 --- a/src/core/SkColorShader.h +++ b/src/core/SkColorShader.h @@ -34,15 +34,12 @@ public: ColorShaderContext(const SkColorShader& shader, const ContextRec&); uint32_t getFlags() const override; - uint8_t getSpan16Alpha() const override; void shadeSpan(int x, int y, SkPMColor span[], int count) override; - void shadeSpan16(int x, int y, uint16_t span[], int count) override; void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; private: SkPMColor fPMColor; uint32_t fFlags; - uint16_t fColor16; typedef SkShader::Context INHERITED; }; diff --git a/src/core/SkFilterShader.cpp b/src/core/SkFilterShader.cpp index b52c2be8c4..2f07c23d95 100644 --- a/src/core/SkFilterShader.cpp +++ b/src/core/SkFilterShader.cpp @@ -46,9 +46,6 @@ uint32_t SkFilterShader::FilterShaderContext::getFlags() const { uint32_t shaderF = fShaderContext->getFlags(); uint32_t filterF = filterShader.fFilter->getFlags(); - // filters don't support 16bit, so clear the matching bit in the shader - shaderF &= ~SkShader::kHasSpan16_Flag; - // if the filter might change alpha, clear the opaque flag in the shader if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { shaderF &= ~SkShader::kOpaqueAlpha_Flag; diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 0ec1433a90..bd3876a69b 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -119,15 +119,6 @@ SkShader::Context::ShadeProc SkShader::Context::asAShadeProc(void** ctx) { #include "SkColorPriv.h" -void SkShader::Context::shadeSpan16(int x, int y, uint16_t span16[], int count) { - SkASSERT(span16); - SkASSERT(count > 0); - SkASSERT(this->canCallShadeSpan16()); - - // basically, if we get here, the subclass screwed up - SkDEBUGFAIL("kHasSpan16 flag is set, but shadeSpan16() not implemented"); -} - #define kTempColorQuadCount 6 // balance between speed (larger) and saving stack-space #define kTempColorCount (kTempColorQuadCount << 2) @@ -266,10 +257,6 @@ uint32_t SkColorShader::ColorShaderContext::getFlags() const { return fFlags; } -uint8_t SkColorShader::ColorShaderContext::getSpan16Alpha() const { - return SkGetPackedA32(fPMColor); -} - SkShader::Context* SkColorShader::onCreateContext(const ContextRec& rec, void* storage) const { return new (storage) ColorShaderContext(*this, rec); } @@ -285,9 +272,6 @@ SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade unsigned g = SkColorGetG(color); unsigned b = SkColorGetB(color); - // we want this before we apply any alpha - fColor16 = SkPack888ToRGB16(r, g, b); - if (a != 255) { r = SkMulDiv255Round(r, a); g = SkMulDiv255Round(g, a); @@ -298,9 +282,6 @@ SkColorShader::ColorShaderContext::ColorShaderContext(const SkColorShader& shade fFlags = kConstInY32_Flag; if (255 == a) { fFlags |= kOpaqueAlpha_Flag; - if (rec.fPaint->isDither() == false) { - fFlags |= kHasSpan16_Flag; - } } } @@ -308,10 +289,6 @@ void SkColorShader::ColorShaderContext::shadeSpan(int x, int y, SkPMColor span[] sk_memset32(span, fPMColor, count); } -void SkColorShader::ColorShaderContext::shadeSpan16(int x, int y, uint16_t span[], int count) { - sk_memset16(span, fColor16, count); -} - void SkColorShader::ColorShaderContext::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) { memset(alpha, SkGetPackedA32(fPMColor), count); } |