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 |
25 SkColor SkColorFilter::filterColor(SkColor c) const { | 34 SkColor SkColorFilter::filterColor(SkColor c) const { |
26 SkPMColor dst, src = SkPreMultiplyColor(c); | 35 SkPMColor dst, src = SkPreMultiplyColor(c); |
27 this->filterSpan(&src, 1, &dst); | 36 this->filterSpan(&src, 1, &dst); |
28 return SkUnPreMultiply::PMColorToColor(dst); | 37 return SkUnPreMultiply::PMColorToColor(dst); |
29 } | 38 } |
30 | 39 |
31 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 40 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
32 | 41 |
33 /* | 42 /* |
34 * Since colorfilters may be used on the GPU backend, and in that case we may s
tring together | 43 * 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... |
45 uint32_t getFlags() const SK_OVERRIDE { | 54 uint32_t getFlags() const SK_OVERRIDE { |
46 // Can only claim alphaunchanged and 16bit support if both our proxys do
. | 55 // Can only claim alphaunchanged and 16bit support if both our proxys do
. |
47 return fOuter->getFlags() & fInner->getFlags(); | 56 return fOuter->getFlags() & fInner->getFlags(); |
48 } | 57 } |
49 | 58 |
50 void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) con
st SK_OVERRIDE { | 59 void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) con
st SK_OVERRIDE { |
51 fInner->filterSpan(shader, count, result); | 60 fInner->filterSpan(shader, count, result); |
52 fOuter->filterSpan(result, count, result); | 61 fOuter->filterSpan(result, count, result); |
53 } | 62 } |
54 | 63 |
| 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 |
55 #ifndef SK_IGNORE_TO_STRING | 70 #ifndef SK_IGNORE_TO_STRING |
56 void toString(SkString* str) const SK_OVERRIDE { | 71 void toString(SkString* str) const SK_OVERRIDE { |
57 SkString outerS, innerS; | 72 SkString outerS, innerS; |
58 fOuter->toString(&outerS); | 73 fOuter->toString(&outerS); |
59 fInner->toString(&innerS); | 74 fInner->toString(&innerS); |
60 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str()
, innerS.c_str()); | 75 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str()
, innerS.c_str()); |
61 } | 76 } |
62 #endif | 77 #endif |
63 | 78 |
64 #if SK_SUPPORT_GPU | 79 #if SK_SUPPORT_GPU |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (count > SK_MAX_COMPOSE_COLORFILTER_COUNT) { | 142 if (count > SK_MAX_COMPOSE_COLORFILTER_COUNT) { |
128 return NULL; | 143 return NULL; |
129 } | 144 } |
130 return SkNEW_ARGS(SkComposeColorFilter, (outer, inner, count)); | 145 return SkNEW_ARGS(SkComposeColorFilter, (outer, inner, count)); |
131 } | 146 } |
132 | 147 |
133 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) | 148 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) |
134 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) | 149 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) |
135 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 150 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
136 | 151 |
OLD | NEW |