Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: src/core/SkColorFilter.cpp

Issue 973593002: change colorfilter to return an array of frag processors (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update gm Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 19 matching lines...) Expand all
30 memcpy(d, s, count * sizeof(uint16_t)); 30 memcpy(d, s, count * sizeof(uint16_t));
31 } 31 }
32 } 32 }
33 33
34 SkColor SkColorFilter::filterColor(SkColor c) const { 34 SkColor SkColorFilter::filterColor(SkColor c) const {
35 SkPMColor dst, src = SkPreMultiplyColor(c); 35 SkPMColor dst, src = SkPreMultiplyColor(c);
36 this->filterSpan(&src, 1, &dst); 36 this->filterSpan(&src, 1, &dst);
37 return SkUnPreMultiply::PMColorToColor(dst); 37 return SkUnPreMultiply::PMColorToColor(dst);
38 } 38 }
39 39
40 GrFragmentProcessor* SkColorFilter::asFragmentProcessor(GrContext*) const {
41 return NULL;
42 }
43
44 //////////////////////////////////////////////////////////////////////////////// /////////////////// 40 //////////////////////////////////////////////////////////////////////////////// ///////////////////
45 41
46 class SkComposeColorFilter : public SkColorFilter { 42 class SkComposeColorFilter : public SkColorFilter {
47 public: 43 public:
48 SkComposeColorFilter(SkColorFilter* outer, SkColorFilter* inner) 44 SkComposeColorFilter(SkColorFilter* outer, SkColorFilter* inner)
49 : fOuter(SkRef(outer)) 45 : fOuter(SkRef(outer))
50 , fInner(SkRef(inner)) 46 , fInner(SkRef(inner))
51 {} 47 {}
52 48
53 uint32_t getFlags() const SK_OVERRIDE { 49 uint32_t getFlags() const SK_OVERRIDE {
(...skipping 14 matching lines...) Expand all
68 64
69 #ifndef SK_IGNORE_TO_STRING 65 #ifndef SK_IGNORE_TO_STRING
70 void toString(SkString* str) const SK_OVERRIDE { 66 void toString(SkString* str) const SK_OVERRIDE {
71 SkString outerS, innerS; 67 SkString outerS, innerS;
72 fOuter->toString(&outerS); 68 fOuter->toString(&outerS);
73 fInner->toString(&innerS); 69 fInner->toString(&innerS);
74 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str() , innerS.c_str()); 70 str->appendf("SkComposeColorFilter: outer(%s) inner(%s)", outerS.c_str() , innerS.c_str());
75 } 71 }
76 #endif 72 #endif
77 73
78 #if 0 // TODO: should we support composing the fragments?
79 #if SK_SUPPORT_GPU 74 #if SK_SUPPORT_GPU
80 GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE; 75 bool asFragmentProcessors(GrContext* context,
81 #endif 76 SkTDArray<GrFragmentProcessor*>* array) const SK_O VERRIDE {
77 bool hasFrags = fInner->asFragmentProcessors(context, array);
78 hasFrags |= fOuter->asFragmentProcessors(context, array);
79 return hasFrags;
80 }
82 #endif 81 #endif
83 82
84 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter) 83 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeColorFilter)
85 84
86 protected: 85 protected:
87 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 86 void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
88 buffer.writeFlattenable(fOuter); 87 buffer.writeFlattenable(fOuter);
89 buffer.writeFlattenable(fInner); 88 buffer.writeFlattenable(fInner);
90 } 89 }
91 90
(...skipping 27 matching lines...) Expand all
119 if (NULL == composition) { 118 if (NULL == composition) {
120 composition = SkNEW_ARGS(SkComposeColorFilter, (outer, inner)); 119 composition = SkNEW_ARGS(SkComposeColorFilter, (outer, inner));
121 } 120 }
122 return composition; 121 return composition;
123 } 122 }
124 123
125 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter) 124 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkColorFilter)
126 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter) 125 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkComposeColorFilter)
127 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 126 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
128 127
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698