OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkColorFilter.h" | 8 #include "SkColorFilter.h" |
9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
11 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
12 | 12 |
13 bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) const { | 13 bool SkColorFilter::asColorMode(SkColor* color, SkXfermode::Mode* mode) const { |
14 return false; | 14 return false; |
15 } | 15 } |
16 | 16 |
17 bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) const { | 17 bool SkColorFilter::asColorMatrix(SkScalar matrix[20]) const { |
18 return false; | 18 return false; |
19 } | 19 } |
20 | 20 |
21 bool SkColorFilter::asComponentTable(SkBitmap*) const { | 21 bool SkColorFilter::asComponentTable(SkBitmap*) const { |
22 return false; | 22 return false; |
23 } | 23 } |
24 | 24 |
25 void SkColorFilter::filterSpan16(const uint16_t s[], int count, uint16_t d[]) co
nst { | |
26 SkASSERT(this->getFlags() & SkColorFilter::kHasFilter16_Flag); | |
27 SkDEBUGFAIL("missing implementation of SkColorFilter::filterSpan16"); | |
28 | |
29 if (d != s) { | |
30 memcpy(d, s, count * sizeof(uint16_t)); | |
31 } | |
32 } | |
33 | |
34 SkColor SkColorFilter::filterColor(SkColor c) const { | 25 SkColor SkColorFilter::filterColor(SkColor c) const { |
35 SkPMColor dst, src = SkPreMultiplyColor(c); | 26 SkPMColor dst, src = SkPreMultiplyColor(c); |
36 this->filterSpan(&src, 1, &dst); | 27 this->filterSpan(&src, 1, &dst); |
37 return SkUnPreMultiply::PMColorToColor(dst); | 28 return SkUnPreMultiply::PMColorToColor(dst); |
38 } | 29 } |
39 | 30 |
40 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 31 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
41 | 32 |
42 /* | 33 /* |
43 * Since colorfilters may be used on the GPU backend, and in that case we may s
tring together | 34 * Since colorfilters may be used on the GPU backend, and in that case we may s
tring together |
(...skipping 10 matching lines...) Expand all Loading... |
54 uint32_t getFlags() const SK_OVERRIDE { | 45 uint32_t getFlags() const SK_OVERRIDE { |
55 // Can only claim alphaunchanged and 16bit support if both our proxys do
. | 46 // Can only claim alphaunchanged and 16bit support if both our proxys do
. |
56 return fOuter->getFlags() & fInner->getFlags(); | 47 return fOuter->getFlags() & fInner->getFlags(); |
57 } | 48 } |
58 | 49 |
59 void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) con
st SK_OVERRIDE { | 50 void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) con
st SK_OVERRIDE { |
60 fInner->filterSpan(shader, count, result); | 51 fInner->filterSpan(shader, count, result); |
61 fOuter->filterSpan(result, count, result); | 52 fOuter->filterSpan(result, count, result); |
62 } | 53 } |
63 | 54 |
64 void filterSpan16(const uint16_t shader[], int count, uint16_t result[]) con
st SK_OVERRIDE { | |
65 SkASSERT(this->getFlags() & kHasFilter16_Flag); | |
66 fInner->filterSpan16(shader, count, result); | |
67 fOuter->filterSpan16(result, count, result); | |
68 } | |
69 | |
70 #ifndef SK_IGNORE_TO_STRING | 55 #ifndef SK_IGNORE_TO_STRING |
71 void toString(SkString* str) const SK_OVERRIDE { | 56 void toString(SkString* str) const SK_OVERRIDE { |
72 SkString outerS, innerS; | 57 SkString outerS, innerS; |
73 fOuter->toString(&outerS); | 58 fOuter->toString(&outerS); |
74 fInner->toString(&innerS); | 59 fInner->toString(&innerS); |
75 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str()
, innerS.c_str()); | 60 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str()
, innerS.c_str()); |
76 } | 61 } |
77 #endif | 62 #endif |
78 | 63 |
79 #if SK_SUPPORT_GPU | 64 #if SK_SUPPORT_GPU |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (count > SK_MAX_COMPOSE_COLORFILTER_COUNT) { | 127 if (count > SK_MAX_COMPOSE_COLORFILTER_COUNT) { |
143 return NULL; | 128 return NULL; |
144 } | 129 } |
145 return SkNEW_ARGS(SkComposeColorFilter, (outer, inner, count)); | 130 return SkNEW_ARGS(SkComposeColorFilter, (outer, inner, count)); |
146 } | 131 } |
147 | 132 |
148 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) | 133 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) |
149 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) | 134 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) |
150 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 135 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
151 | 136 |
OLD | NEW |