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
diff --git a/src/effects/SkAvoidXfermode.cpp b/src/effects/SkAvoidXfermode.cpp
index 97bfeae..de3fe28 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
uint32_t sub = (fDistMul - (1 << 14)) << SK_R16_BITS;
int MAX, mask;
-
+
if (kTargetColor_Mode == fMode) {
mask = -1;
MAX = 31;
@@ -220,9 +220,9 @@
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 @@
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 @@
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 @@
// override in subclass
}
+static SkFlattenable::Registrar
+ gSkAvoidXfermodeReg("SkAvoidXfermode", SkAvoidXfermode::CreateProc);