diff options
-rw-r--r-- | include/core/SkColorFilter.h | 12 | ||||
-rw-r--r-- | include/effects/SkColorMatrixFilter.h | 13 | ||||
-rw-r--r-- | src/core/SkColorFilter.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkColorFilters.cpp | 23 | ||||
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 92 | ||||
-rw-r--r-- | src/effects/SkTableColorFilter.cpp | 4 |
6 files changed, 76 insertions, 76 deletions
diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index b54d5f5d21..4f67c8dbfe 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -27,14 +27,14 @@ public: * returns true, and sets (if not NULL) the color and mode appropriately. * If not, this returns false and ignores the parameters. */ - virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode); + virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode) const; /** * If the filter can be represented by a 5x4 matrix, this * returns true, and sets the matrix appropriately. * If not, this returns false and ignores the parameter. */ - virtual bool asColorMatrix(SkScalar matrix[20]); + virtual bool asColorMatrix(SkScalar matrix[20]) const; /** * If the filter can be represented by per-component table, return true, @@ -62,7 +62,7 @@ public: @param result written by the filter */ virtual void filterSpan(const SkPMColor src[], int count, - SkPMColor result[]) = 0; + SkPMColor result[]) const = 0; /** Called with a scanline of colors, as if there was a shader installed. The implementation writes out its filtered version into result[]. Note: shader and result may be the same buffer. @@ -71,7 +71,7 @@ public: @param result written by the filter */ virtual void filterSpan16(const uint16_t shader[], int count, - uint16_t result[]); + uint16_t result[]) const; enum Flags { /** If set the filter methods will not change the alpha channel of the @@ -87,7 +87,7 @@ public: /** Returns the flags for this filter. Override in subclasses to return custom flags. */ - virtual uint32_t getFlags() { return 0; } + virtual uint32_t getFlags() const { return 0; } /** * Apply this colorfilter to the specified SkColor. This routine handles @@ -95,7 +95,7 @@ public: * to SkColor. This method is not virtual, but will call filterSpan() * which is virtual. */ - SkColor filterColor(SkColor); + SkColor filterColor(SkColor) const; /** Create a colorfilter that uses the specified color and mode. If the Mode is DST, this function will return NULL (since that diff --git a/include/effects/SkColorMatrixFilter.h b/include/effects/SkColorMatrixFilter.h index 799cf8c16d..222646e032 100644 --- a/include/effects/SkColorMatrixFilter.h +++ b/include/effects/SkColorMatrixFilter.h @@ -17,10 +17,10 @@ public: SkColorMatrixFilter(const SkScalar array[20]); // overrides from SkColorFilter - virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) SK_OVERRIDE; - virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]) SK_OVERRIDE; - virtual uint32_t getFlags() SK_OVERRIDE; - virtual bool asColorMatrix(SkScalar matrix[20]) SK_OVERRIDE; + virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE; + virtual void filterSpan16(const uint16_t src[], int count, uint16_t[]) const SK_OVERRIDE; + virtual uint32_t getFlags() const SK_OVERRIDE; + virtual bool asColorMatrix(SkScalar matrix[20]) const SK_OVERRIDE; #if SK_SUPPORT_GPU virtual GrEffect* asNewEffect(GrContext*) const SK_OVERRIDE; #endif @@ -28,7 +28,6 @@ public: struct State { int32_t fArray[20]; int fShift; - int32_t fResult[4]; }; SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter) @@ -40,8 +39,8 @@ protected: private: SkColorMatrix fMatrix; - typedef void (*Proc)(State*, unsigned r, unsigned g, unsigned b, - unsigned a); + typedef void (*Proc)(const State&, unsigned r, unsigned g, unsigned b, + unsigned a, int32_t result[4]); Proc fProc; State fState; diff --git a/src/core/SkColorFilter.cpp b/src/core/SkColorFilter.cpp index 156fb8fb96..747b2fff6c 100644 --- a/src/core/SkColorFilter.cpp +++ b/src/core/SkColorFilter.cpp @@ -13,11 +13,11 @@ SK_DEFINE_INST_COUNT(SkColorFilter) -bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) { +bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) const { return false; } -bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) { +bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) const { return false; } @@ -25,7 +25,7 @@ bool SkColorFilter::asComponentTable(SkBitmap*) const { return false; } -void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) { +void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) const { SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag); SkDEBUGFAIL("missing implementation of SkColorFilter::filterSpan16"); @@ -34,7 +34,7 @@ void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) { } } -SkColor SkColorFilter::filterColor(SkColor c) { +SkColor SkColorFilter::filterColor(SkColor c) const { SkPMColor dst, src = SkPreMultiplyColor(c); this->filterSpan(&src, 1, &dst); return SkUnPreMultiply::PMColorToColor(dst); diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index aae7868c3c..2036d37c2b 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -35,7 +35,7 @@ public: bool isModeValid() const { return ILLEGAL_XFERMODE_MODE != fMode; } SkPMColor getPMColor() const { return fPMColor; } - virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode) SK_OVERRIDE { + virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode) const SK_OVERRIDE { if (ILLEGAL_XFERMODE_MODE == fMode) { return false; } @@ -49,12 +49,12 @@ public: return true; } - virtual uint32_t getFlags() SK_OVERRIDE { + virtual uint32_t getFlags() const SK_OVERRIDE { return fProc16 ? (kAlphaUnchanged_Flag | kHasFilter16_Flag) : 0; } virtual void filterSpan(const SkPMColor shader[], int count, - SkPMColor result[]) SK_OVERRIDE { + SkPMColor result[]) const SK_OVERRIDE { SkPMColor color = fPMColor; SkXfermodeProc proc = fProc; @@ -64,7 +64,7 @@ public: } virtual void filterSpan16(const uint16_t shader[], int count, - uint16_t result[]) SK_OVERRIDE { + uint16_t result[]) const SK_OVERRIDE { SkASSERT(this->getFlags() & kHasFilter16_Flag); SkPMColor color = fPMColor; @@ -238,7 +238,7 @@ public: SkLightingColorFilter(SkColor mul, SkColor add) : fMul(mul), fAdd(add) {} virtual void filterSpan(const SkPMColor shader[], int count, - SkPMColor result[]) { + SkPMColor result[]) const SK_OVERRIDE { unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); @@ -287,7 +287,7 @@ public: : INHERITED(mul, add) {} virtual void filterSpan(const SkPMColor shader[], int count, - SkPMColor result[]) { + SkPMColor result[]) const SK_OVERRIDE { unsigned addR = SkColorGetR(fAdd); unsigned addG = SkColorGetG(fAdd); unsigned addB = SkColorGetB(fAdd); @@ -322,7 +322,7 @@ public: : INHERITED(mul, add) {} virtual void filterSpan(const SkPMColor shader[], int count, - SkPMColor result[]) { + SkPMColor result[]) const SK_OVERRIDE { unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); @@ -361,12 +361,12 @@ public: SkASSERT(SkColorGetR(mul) == SkColorGetB(mul)); } - virtual uint32_t getFlags() { + virtual uint32_t getFlags() const { return this->INHERITED::getFlags() | (kAlphaUnchanged_Flag | kHasFilter16_Flag); } virtual void filterSpan16(const uint16_t shader[], int count, - uint16_t result[]) { + uint16_t result[]) const SK_OVERRIDE { // all mul components are the same unsigned scale = SkAlpha255To256(SkColorGetR(fMul)); @@ -393,7 +393,7 @@ public: : INHERITED(mul, add) {} virtual void filterSpan(const SkPMColor shader[], int count, - SkPMColor result[]) { + SkPMColor result[]) const SK_OVERRIDE { unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); @@ -435,7 +435,8 @@ public: } protected: - void filterSpan(const SkPMColor src[], int count, SkPMColor result[]) { + void filterSpan(const SkPMColor src[], int count, SkPMColor + result[]) const SK_OVERRIDE { if (result != src) { memcpy(result, src, count * sizeof(SkPMColor)); } diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 1b86d439bf..e460325de4 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -21,11 +21,11 @@ static int32_t rowmul3(const int32_t array[], unsigned r, unsigned g, return array[0] * r + array[1] * g + array[2] * b + array[4]; } -static void General(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - const int shift = state->fShift; - int32_t* SK_RESTRICT result = state->fResult; +static void General(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; + const int shift = state.fShift; result[0] = rowmul4(&array[0], r, g, b, a) >> shift; result[1] = rowmul4(&array[5], r, g, b, a) >> shift; @@ -33,10 +33,10 @@ static void General(SkColorMatrixFilter::State* state, result[3] = rowmul4(&array[15], r, g, b, a) >> shift; } -static void General16(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - int32_t* SK_RESTRICT result = state->fResult; +static void General16(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; result[0] = rowmul4(&array[0], r, g, b, a) >> 16; result[1] = rowmul4(&array[5], r, g, b, a) >> 16; @@ -44,11 +44,11 @@ static void General16(SkColorMatrixFilter::State* state, result[3] = rowmul4(&array[15], r, g, b, a) >> 16; } -static void AffineAdd(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - const int shift = state->fShift; - int32_t* SK_RESTRICT result = state->fResult; +static void AffineAdd(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; + const int shift = state.fShift; result[0] = rowmul3(&array[0], r, g, b) >> shift; result[1] = rowmul3(&array[5], r, g, b) >> shift; @@ -56,10 +56,10 @@ static void AffineAdd(SkColorMatrixFilter::State* state, result[3] = a; } -static void AffineAdd16(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - int32_t* SK_RESTRICT result = state->fResult; +static void AffineAdd16(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; result[0] = rowmul3(&array[0], r, g, b) >> 16; result[1] = rowmul3(&array[5], r, g, b) >> 16; @@ -67,11 +67,11 @@ static void AffineAdd16(SkColorMatrixFilter::State* state, result[3] = a; } -static void ScaleAdd(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - const int shift = state->fShift; - int32_t* SK_RESTRICT result = state->fResult; +static void ScaleAdd(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; + const int shift = state.fShift; // cast to (int) to keep the expression signed for the shift result[0] = (array[0] * (int)r + array[4]) >> shift; @@ -80,10 +80,10 @@ static void ScaleAdd(SkColorMatrixFilter::State* state, result[3] = a; } -static void ScaleAdd16(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - int32_t* SK_RESTRICT result = state->fResult; +static void ScaleAdd16(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; // cast to (int) to keep the expression signed for the shift result[0] = (array[0] * (int)r + array[4]) >> 16; @@ -92,11 +92,11 @@ static void ScaleAdd16(SkColorMatrixFilter::State* state, result[3] = a; } -static void Add(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - const int shift = state->fShift; - int32_t* SK_RESTRICT result = state->fResult; +static void Add(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; + const int shift = state.fShift; result[0] = r + (array[4] >> shift); result[1] = g + (array[9] >> shift); @@ -104,10 +104,10 @@ static void Add(SkColorMatrixFilter::State* state, result[3] = a; } -static void Add16(SkColorMatrixFilter::State* state, - unsigned r, unsigned g, unsigned b, unsigned a) { - const int32_t* SK_RESTRICT array = state->fArray; - int32_t* SK_RESTRICT result = state->fResult; +static void Add16(const SkColorMatrixFilter::State& state, + unsigned r, unsigned g, unsigned b, unsigned a, + int32_t* SK_RESTRICT result) { + const int32_t* SK_RESTRICT array = state.fArray; result[0] = r + (array[4] >> 16); result[1] = g + (array[9] >> 16); @@ -212,15 +212,15 @@ SkColorMatrixFilter::SkColorMatrixFilter(const SkScalar array[20]) { this->initState(array); } -uint32_t SkColorMatrixFilter::getFlags() { +uint32_t SkColorMatrixFilter::getFlags() const { return this->INHERITED::getFlags() | fFlags; } void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, - SkPMColor dst[]) { + SkPMColor dst[]) const { Proc proc = fProc; - State* state = &fState; - int32_t* result = state->fResult; + const State& state = fState; + int32_t result[4]; if (NULL == proc) { if (src != dst) { @@ -251,7 +251,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkASSERT(b <= 255); } - proc(state, r, g, b, a); + proc(state, r, g, b, a, result); r = pin(result[0], SK_R32_MASK); g = pin(result[1], SK_G32_MASK); @@ -263,12 +263,12 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, } void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count, - uint16_t dst[]) { + uint16_t dst[]) const { SkASSERT(fFlags & SkColorFilter::kHasFilter16_Flag); Proc proc = fProc; - State* state = &fState; - int32_t* result = state->fResult; + const State& state = fState; + int32_t result[4]; if (NULL == proc) { if (src != dst) { @@ -285,7 +285,7 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count, unsigned g = SkPacked16ToG32(c); unsigned b = SkPacked16ToB32(c); - proc(state, r, g, b, 0); + proc(state, r, g, b, 0, result); r = pin(result[0], SK_R32_MASK); g = pin(result[1], SK_G32_MASK); @@ -311,7 +311,7 @@ SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer) this->initState(fMatrix.fMat); } -bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) { +bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { if (matrix) { memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); } diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 0ae7e1950b..ad34fbb6c6 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -45,7 +45,7 @@ public: #endif virtual void filterSpan(const SkPMColor src[], int count, - SkPMColor dst[]) SK_OVERRIDE; + SkPMColor dst[]) const SK_OVERRIDE; SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTable_ColorFilter) @@ -104,7 +104,7 @@ static const uint8_t gIdentityTable[] = { }; void SkTable_ColorFilter::filterSpan(const SkPMColor src[], int count, - SkPMColor dst[]) { + SkPMColor dst[]) const { const uint8_t* table = fStorage; const uint8_t* tableA = gIdentityTable; const uint8_t* tableR = gIdentityTable; |