diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-27 14:09:52 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-27 14:09:52 +0000 |
commit | 1447c6f7f4579942b32af6ffff1eadede40b42bc (patch) | |
tree | c5230b0da5dc8daf680ec21af0fc71de9e2c80d4 /src/effects | |
parent | 938d60402617de4d1cef29cc1e991df77b4a4ecc (diff) |
Add missing flattenable registrations and CreateProc() functions;
fixes gm --serialize xfermode test case.
git-svn-id: http://skia.googlecode.com/svn/trunk@1199 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkAvoidXfermode.cpp | 48 | ||||
-rw-r--r-- | src/effects/SkColorFilters.cpp | 113 | ||||
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 53 | ||||
-rw-r--r-- | src/effects/SkPixelXorXfermode.cpp | 3 |
4 files changed, 122 insertions, 95 deletions
diff --git a/src/effects/SkAvoidXfermode.cpp b/src/effects/SkAvoidXfermode.cpp index 97bfeae0b2..de3fe285c5 100644 --- a/src/effects/SkAvoidXfermode.cpp +++ b/src/effects/SkAvoidXfermode.cpp @@ -2,16 +2,16 @@ ** ** Copyright 2006, The Android Open Source Project ** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at ** -** http://www.apache.org/licenses/LICENSE-2.0 +** http://www.apache.org/licenses/LICENSE-2.0 ** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and ** limitations under the License. */ @@ -19,7 +19,7 @@ #include "SkColorPriv.h" SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) -{ +{ if (tolerance > 255) { tolerance = 255; } @@ -66,7 +66,7 @@ static unsigned color_dist16(uint16_t c, unsigned r, unsigned g, unsigned b) unsigned dr = SkAbs32(SkGetPackedR16(c) - r); unsigned dg = SkAbs32(SkGetPackedG16(c) - g) >> (SK_G16_BITS - SK_R16_BITS); unsigned db = SkAbs32(SkGetPackedB16(c) - b); - + return SkMax32(dr, SkMax32(dg, db)); } @@ -76,11 +76,11 @@ static unsigned color_dist4444(uint16_t c, unsigned r, unsigned g, unsigned b) SkASSERT(r <= 0xF); SkASSERT(g <= 0xF); SkASSERT(b <= 0xF); - + unsigned dr = SkAbs32(SkGetPackedR4444(c) - r); unsigned dg = SkAbs32(SkGetPackedG4444(c) - g); unsigned db = SkAbs32(SkGetPackedB4444(c) - b); - + return SkMax32(dr, SkMax32(dg, db)); } @@ -94,7 +94,7 @@ static unsigned color_dist32(SkPMColor c, U8CPU r, U8CPU g, U8CPU b) unsigned dr = SkAbs32(SkGetPackedR32(c) - r); unsigned dg = SkAbs32(SkGetPackedG32(c) - g); unsigned db = SkAbs32(SkGetPackedB32(c) - b); - + return SkMax32(dr, SkMax32(dg, db)); } @@ -128,9 +128,9 @@ void SkAvoidXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, unsigned opB = SkColorGetB(fOpColor); uint32_t mul = fDistMul; uint32_t sub = (fDistMul - (1 << 14)) << 8; - + int MAX, mask; - + if (kTargetColor_Mode == fMode) { mask = -1; MAX = 255; @@ -138,17 +138,17 @@ void SkAvoidXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, mask = 0; MAX = 0; } - + for (int i = 0; i < count; i++) { int d = color_dist32(dst[i], opR, opG, opB); // now reverse d if we need to d = MAX + (d ^ mask) - mask; SkASSERT((unsigned)d <= 255); d = Accurate255To256(d); - + d = scale_dist_14(d, mul, sub); SkASSERT(d <= 256); - + if (d > 0) { if (NULL != aa) { d = SkAlphaMul(d, Accurate255To256(*aa++)); @@ -181,7 +181,7 @@ void SkAvoidXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count, uint32_t sub = (fDistMul - (1 << 14)) << SK_R16_BITS; int MAX, mask; - + if (kTargetColor_Mode == fMode) { mask = -1; MAX = 31; @@ -220,9 +220,9 @@ void SkAvoidXfermode::xfer4444(uint16_t dst[], const SkPMColor src[], int count, unsigned opB = SkColorGetB(fOpColor) >> 4; uint32_t mul = fDistMul; uint32_t sub = (fDistMul - (1 << 14)) << 4; - + int MAX, mask; - + if (kTargetColor_Mode == fMode) { mask = -1; MAX = 15; @@ -230,7 +230,7 @@ void SkAvoidXfermode::xfer4444(uint16_t dst[], const SkPMColor src[], int count, mask = 0; MAX = 0; } - + for (int i = 0; i < count; i++) { int d = color_dist4444(dst[i], opR, opG, opB); // now reverse d if we need to @@ -240,7 +240,7 @@ void SkAvoidXfermode::xfer4444(uint16_t dst[], const SkPMColor src[], int count, d += d >> 3; d = scale_dist_14(d, mul, sub); SkASSERT(d <= 16); - + if (d > 0) { if (NULL != aa) { d = SkAlphaMul(d, Accurate255To256(*aa++)); @@ -258,3 +258,5 @@ void SkAvoidXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, co // override in subclass } +static SkFlattenable::Registrar + gSkAvoidXfermodeReg("SkAvoidXfermode", SkAvoidXfermode::CreateProc); diff --git a/src/effects/SkColorFilters.cpp b/src/effects/SkColorFilters.cpp index 64445a9390..0f8e2270bc 100644 --- a/src/effects/SkColorFilters.cpp +++ b/src/effects/SkColorFilters.cpp @@ -37,7 +37,7 @@ public: fPMColor = SkPreMultiplyColor(fColor); }; - + virtual bool asColorMode(SkColor* color, SkXfermode::Mode* mode) { if (ILLEGAL_XFERMODE_MODE == fMode) { return false; @@ -58,10 +58,11 @@ public: protected: virtual void flatten(SkFlattenableWriteBuffer& buffer) { + this->INHERITED::flatten(buffer); buffer.write32(fColor); buffer.write32(fMode); } - + SkModeColorFilter(SkFlattenableReadBuffer& buffer) { fColor = buffer.readU32(); fMode = (SkXfermode::Mode)buffer.readU32(); @@ -75,6 +76,8 @@ protected: private: SkColor fColor; SkXfermode::Mode fMode; + + typedef SkColorFilter INHERITED; }; class Src_SkModeColorFilter : public SkModeColorFilter { @@ -100,17 +103,17 @@ public: sk_memset16(result, SkPixel32ToPixel16(fPMColor), count); } + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(Src_SkModeColorFilter, (buffer)); + } + protected: virtual Factory getFactory() { return CreateProc; } Src_SkModeColorFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} - -private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { - return SkNEW_ARGS(Src_SkModeColorFilter, (buffer)); - } +private: typedef SkModeColorFilter INHERITED; }; @@ -128,7 +131,7 @@ public: return 0; } } - + virtual void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) { if (NULL == fColor32Proc) { @@ -142,18 +145,19 @@ public: SkASSERT(this->getFlags() & kHasFilter16_Flag); sk_memset16(result, SkPixel32ToPixel16(fPMColor), count); } - + + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(SrcOver_SkModeColorFilter, (buffer)); + } + protected: virtual Factory getFactory() { return CreateProc; } - + SrcOver_SkModeColorFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer), fColor32Proc(NULL) {} - + private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { - return SkNEW_ARGS(SrcOver_SkModeColorFilter, (buffer)); - } - + SkBlitRow::ColorProc fColor32Proc; typedef SkModeColorFilter INHERITED; @@ -167,14 +171,14 @@ public: fProc = SkXfermode::GetProc(mode); fProc16 = SkXfermode::GetProc16(mode, color); } - + Proc_SkModeColorFilter(SkColor color, SkXfermodeProc proc, SkXfermodeProc16 proc16) : INHERITED(color, ILLEGAL_XFERMODE_MODE) { fProc = proc; fProc16 = proc16; } - + virtual uint32_t getFlags() { return fProc16 ? (kAlphaUnchanged_Flag | kHasFilter16_Flag) : 0; } @@ -188,27 +192,31 @@ public: result[i] = proc(color, shader[i]); } } - + virtual void filterSpan16(const uint16_t shader[], int count, uint16_t result[]) { SkASSERT(this->getFlags() & kHasFilter16_Flag); - + SkPMColor color = fPMColor; SkXfermodeProc16 proc16 = fProc16; - + for (int i = 0; i < count; i++) { result[i] = proc16(color, shader[i]); } } - + + static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { + return SkNEW_ARGS(Proc_SkModeColorFilter, (buffer)); + } + protected: virtual void flatten(SkFlattenableWriteBuffer& buffer) { this->INHERITED::flatten(buffer); buffer.writeFunctionPtr((void*)fProc); buffer.writeFunctionPtr((void*)fProc16); } - - virtual Factory getFactory() { + + virtual Factory getFactory() { return CreateProc; } @@ -218,13 +226,9 @@ protected: } private: - static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { - return SkNEW_ARGS(Proc_SkModeColorFilter, (buffer)); - } - SkXfermodeProc fProc; SkXfermodeProc16 fProc16; - + typedef SkModeColorFilter INHERITED; }; @@ -267,7 +271,7 @@ SkColorFilter* SkColorFilter::CreateModeFilter(SkColor color, (0xFF == alpha && SkXfermode::kDstIn_Mode == mode)) { return NULL; } - + switch (mode) { case SkXfermode::kSrc_Mode: return SkNEW_ARGS(Src_SkModeColorFilter, (color)); @@ -307,7 +311,7 @@ public: unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); - + unsigned addR = SkColorGetR(fAdd); unsigned addG = SkColorGetG(fAdd); unsigned addB = SkColorGetB(fAdd); @@ -316,7 +320,7 @@ public: SkPMColor c = shader[i]; if (c) { unsigned a = SkGetPackedA32(c); - unsigned scaleA = SkAlpha255To256(a); + unsigned scaleA = SkAlpha255To256(a); unsigned r = pin(SkAlphaMul(SkGetPackedR32(c), scaleR) + SkAlphaMul(addR, scaleA), a); unsigned g = pin(SkAlphaMul(SkGetPackedG32(c), scaleG) + SkAlphaMul(addG, scaleA), a); unsigned b = pin(SkAlphaMul(SkGetPackedB32(c), scaleB) + SkAlphaMul(addB, scaleA), a); @@ -328,10 +332,11 @@ public: protected: virtual void flatten(SkFlattenableWriteBuffer& buffer) { + this->INHERITED::flatten(buffer); buffer.write32(fMul); buffer.write32(fAdd); } - + virtual Factory getFactory() { return CreateProc; } @@ -340,13 +345,15 @@ protected: fMul = buffer.readU32(); fAdd = buffer.readU32(); } - + SkColor fMul, fAdd; private: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkLightingColorFilter, (buffer)); } + + typedef SkColorFilter INHERITED; }; class SkLightingColorFilter_JustAdd : public SkLightingColorFilter { @@ -364,7 +371,7 @@ public: SkPMColor c = shader[i]; if (c) { unsigned a = SkGetPackedA32(c); - unsigned scaleA = SkAlpha255To256(a); + unsigned scaleA = SkAlpha255To256(a); unsigned r = pin(SkGetPackedR32(c) + SkAlphaMul(addR, scaleA), a); unsigned g = pin(SkGetPackedG32(c) + SkAlphaMul(addG, scaleA), a); unsigned b = pin(SkGetPackedB32(c) + SkAlphaMul(addB, scaleA), a); @@ -384,6 +391,7 @@ private: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkLightingColorFilter_JustAdd, (buffer)); } + typedef SkLightingColorFilter INHERITED; }; @@ -397,7 +405,7 @@ public: unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); - + for (int i = 0; i < count; i++) { SkPMColor c = shader[i]; if (c) { @@ -416,7 +424,7 @@ protected: SkLightingColorFilter_JustMul(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} - + private: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkLightingColorFilter_JustMul, (buffer)); @@ -435,7 +443,7 @@ public: SkASSERT(SkColorGetR(mul) == SkColorGetG(mul)); SkASSERT(SkColorGetR(mul) == SkColorGetB(mul)); } - + virtual uint32_t getFlags() { return this->INHERITED::getFlags() | (kAlphaUnchanged_Flag | kHasFilter16_Flag); } @@ -462,7 +470,7 @@ private: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkLightingColorFilter_SingleMul, (buffer)); } - + typedef SkLightingColorFilter INHERITED; }; @@ -470,22 +478,22 @@ class SkLightingColorFilter_NoPin : public SkLightingColorFilter { public: SkLightingColorFilter_NoPin(SkColor mul, SkColor add) : INHERITED(mul, add) {} - + virtual void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) { unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul)); unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul)); unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul)); - + unsigned addR = SkColorGetR(fAdd); unsigned addG = SkColorGetG(fAdd); unsigned addB = SkColorGetB(fAdd); - + for (int i = 0; i < count; i++) { SkPMColor c = shader[i]; if (c) { unsigned a = SkGetPackedA32(c); - unsigned scaleA = SkAlpha255To256(a); + unsigned scaleA = SkAlpha255To256(a); unsigned r = SkAlphaMul(SkGetPackedR32(c), scaleR) + SkAlphaMul(addR, scaleA); unsigned g = SkAlphaMul(SkGetPackedG32(c), scaleG) + SkAlphaMul(addG, scaleA); unsigned b = SkAlphaMul(SkGetPackedB32(c), scaleB) + SkAlphaMul(addB, scaleA); @@ -494,18 +502,18 @@ public: result[i] = c; } } - + protected: virtual Factory getFactory() { return CreateProc; } - + SkLightingColorFilter_NoPin(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {} - + private: static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) { return SkNEW_ARGS(SkLightingColorFilter_NoPin, (buffer)); } - + typedef SkLightingColorFilter INHERITED; }; @@ -520,7 +528,7 @@ protected: } virtual void flatten(SkFlattenableWriteBuffer& buffer) {} - + virtual Factory getFactory() { return CreateProc; } @@ -560,3 +568,14 @@ SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) { return SkNEW_ARGS(SkLightingColorFilter, (mul, add)); } +static SkFlattenable::Registrar + gSrcColorFilterReg("Src_SkModeColorFilterReg", + Src_SkModeColorFilter::CreateProc); + +static SkFlattenable::Registrar + gSrcOverColorFilterReg("SrcOver_SkModeColorFilterReg", + SrcOver_SkModeColorFilter::CreateProc); + +static SkFlattenable::Registrar + gProcColorFilterReg("Proc_SkModeColorFilterReg", + Proc_SkModeColorFilter::CreateProc); diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 07c8d2f342..9270052544 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -18,7 +18,7 @@ static void General(SkColorMatrixFilter::State* state, const int32_t* SK_RESTRICT array = state->fArray; const int shift = state->fShift; int32_t* SK_RESTRICT result = state->fResult; - + result[0] = rowmul4(&array[0], r, g, b, a) >> shift; result[1] = rowmul4(&array[5], r, g, b, a) >> shift; result[2] = rowmul4(&array[10], r, g, b, a) >> shift; @@ -29,7 +29,7 @@ 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; - + result[0] = rowmul4(&array[0], r, g, b, a) >> 16; result[1] = rowmul4(&array[5], r, g, b, a) >> 16; result[2] = rowmul4(&array[10], r, g, b, a) >> 16; @@ -41,7 +41,7 @@ static void AffineAdd(SkColorMatrixFilter::State* state, const int32_t* SK_RESTRICT array = state->fArray; const int shift = state->fShift; int32_t* SK_RESTRICT result = state->fResult; - + result[0] = rowmul3(&array[0], r, g, b) >> shift; result[1] = rowmul3(&array[5], r, g, b) >> shift; result[2] = rowmul3(&array[10], r, g, b) >> shift; @@ -52,7 +52,7 @@ 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; - + result[0] = rowmul3(&array[0], r, g, b) >> 16; result[1] = rowmul3(&array[5], r, g, b) >> 16; result[2] = rowmul3(&array[10], r, g, b) >> 16; @@ -64,7 +64,7 @@ static void ScaleAdd(SkColorMatrixFilter::State* state, const int32_t* SK_RESTRICT array = state->fArray; const int shift = state->fShift; int32_t* SK_RESTRICT result = state->fResult; - + // cast to (int) to keep the expression signed for the shift result[0] = (array[0] * (int)r + array[4]) >> shift; result[1] = (array[6] * (int)g + array[9]) >> shift; @@ -76,7 +76,7 @@ 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; - + // cast to (int) to keep the expression signed for the shift result[0] = (array[0] * (int)r + array[4]) >> 16; result[1] = (array[6] * (int)g + array[9]) >> 16; @@ -89,7 +89,7 @@ static void Add(SkColorMatrixFilter::State* state, const int32_t* SK_RESTRICT array = state->fArray; const int shift = state->fShift; int32_t* SK_RESTRICT result = state->fResult; - + result[0] = r + (array[4] >> shift); result[1] = g + (array[9] >> shift); result[2] = b + (array[14] >> shift); @@ -100,7 +100,7 @@ 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; - + result[0] = r + (array[4] >> 16); result[1] = g + (array[9] >> 16); result[2] = b + (array[14] >> 16); @@ -117,7 +117,7 @@ void SkColorMatrixFilter::setup(const SkScalar SK_RESTRICT src[20]) { // fState is undefined, but that is OK, since we shouldn't look at it return; } - + int32_t* SK_RESTRICT array = fState.fArray; int i; @@ -129,7 +129,7 @@ void SkColorMatrixFilter::setup(const SkScalar SK_RESTRICT src[20]) { value = SkAbs32(value); max = SkMax32(max, value); } - + /* All of fArray[] values must fit in 23 bits, to safely allow me to multiply them by 8bit unsigned values, and get a signed answer without overflow. This means clz needs to be 9 or bigger @@ -146,7 +146,7 @@ void SkColorMatrixFilter::setup(const SkScalar SK_RESTRICT src[20]) { } one >>= bits; } - + // check if we have to munge Alpha int32_t changesAlpha = (array[15] | array[16] | array[17] | (array[18] - one) | array[19]); @@ -224,36 +224,36 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, Proc proc = fProc; State* state = &fState; int32_t* SK_RESTRICT result = state->fResult; - + if (NULL == proc) { if (src != dst) { memcpy(dst, src, count * sizeof(SkPMColor)); } return; } - + const SkUnPreMultiply::Scale* table = SkUnPreMultiply::GetScaleTable(); for (int i = 0; i < count; i++) { SkPMColor c = src[i]; - + unsigned r = SkGetPackedR32(c); unsigned g = SkGetPackedG32(c); unsigned b = SkGetPackedB32(c); unsigned a = SkGetPackedA32(c); - + // need our components to be un-premultiplied if (255 != a) { SkUnPreMultiply::Scale scale = table[a]; r = SkUnPreMultiply::ApplyScale(scale, r); g = SkUnPreMultiply::ApplyScale(scale, g); b = SkUnPreMultiply::ApplyScale(scale, b); - + SkASSERT(r <= 255); SkASSERT(g <= 255); SkASSERT(b <= 255); } - + proc(state, r, g, b, a); r = pin(result[0], SK_R32_MASK); @@ -278,7 +278,7 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count, Proc proc = fProc; State* state = &fState; int32_t* SK_RESTRICT result = state->fResult; - + if (NULL == proc) { if (src != dst) { memcpy(dst, src, count * sizeof(uint16_t)); @@ -288,18 +288,18 @@ void SkColorMatrixFilter::filterSpan16(const uint16_t src[], int count, for (int i = 0; i < count; i++) { uint16_t c = src[i]; - + // expand to 8bit components (since our matrix translate is 8bit biased unsigned r = SkPacked16ToR32(c); unsigned g = SkPacked16ToG32(c); unsigned b = SkPacked16ToB32(c); - + proc(state, r, g, b, 0); - + r = pin(result[0], SK_R32_MASK); g = pin(result[1], SK_G32_MASK); b = pin(result[2], SK_B32_MASK); - + // now packed it back down to 16bits (hmmm, could dither...) dst[i] = SkPack888ToRGB16(r, g, b); } @@ -314,17 +314,20 @@ void SkColorMatrixFilter::flatten(SkFlattenableWriteBuffer& buffer) { buffer.writeMul4(&fState, sizeof(fState)); buffer.write32(fFlags); } - + SkFlattenable::Factory SkColorMatrixFilter::getFactory() { return CreateProc; } - + SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { fProc = (Proc)buffer.readFunctionPtr(); buffer.read(&fState, sizeof(fState)); fFlags = buffer.readU32(); } - + SkFlattenable* SkColorMatrixFilter::CreateProc(SkFlattenableReadBuffer& buf) { return SkNEW_ARGS(SkColorMatrixFilter, (buf)); } +static SkFlattenable::Registrar + gSkColorMatrixFilterReg("SkColorMatrixFilter", + SkColorMatrixFilter::CreateProc); diff --git a/src/effects/SkPixelXorXfermode.cpp b/src/effects/SkPixelXorXfermode.cpp index 0fb0494d5a..f4a74eebc5 100644 --- a/src/effects/SkPixelXorXfermode.cpp +++ b/src/effects/SkPixelXorXfermode.cpp @@ -43,3 +43,6 @@ SkFlattenable* SkPixelXorXfermode::Create(SkFlattenableReadBuffer& rb) { return SkNEW_ARGS(SkPixelXorXfermode, (rb)); } +static SkFlattenable::Registrar + gSkPixelXorXfermodeReg("SkPixelXorXfermode", + SkPixelXorXfermode::CreateProc); |