OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (prev != bitmap.getColor(0,0)) { | 88 if (prev != bitmap.getColor(0,0)) { |
89 layer = i; | 89 layer = i; |
90 } | 90 } |
91 prev = bitmap.getColor(0,0); | 91 prev = bitmap.getColor(0,0); |
92 } | 92 } |
93 return layer; | 93 return layer; |
94 } | 94 } |
95 | 95 |
96 class OverdrawXfermode : public SkXfermode { | 96 class OverdrawXfermode : public SkXfermode { |
97 public: | 97 public: |
98 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const SK_OVERRIDE
{ | 98 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const SK_OVERRIDE { |
99 // This table encodes the color progression of the overdraw visualizatio
n | 99 // This table encodes the color progression of the overdraw visualizatio
n |
100 static const SkPMColor gTable[] = { | 100 static const SkPMColor gTable[] = { |
101 SkPackARGB32(0x00, 0x00, 0x00, 0x00), | 101 SkPackARGB32(0x00, 0x00, 0x00, 0x00), |
102 SkPackARGB32(0xFF, 128, 158, 255), | 102 SkPackARGB32(0xFF, 128, 158, 255), |
103 SkPackARGB32(0xFF, 170, 185, 212), | 103 SkPackARGB32(0xFF, 170, 185, 212), |
104 SkPackARGB32(0xFF, 213, 195, 170), | 104 SkPackARGB32(0xFF, 213, 195, 170), |
105 SkPackARGB32(0xFF, 255, 192, 127), | 105 SkPackARGB32(0xFF, 255, 192, 127), |
106 SkPackARGB32(0xFF, 255, 185, 85), | 106 SkPackARGB32(0xFF, 255, 185, 85), |
107 SkPackARGB32(0xFF, 255, 165, 42), | 107 SkPackARGB32(0xFF, 255, 165, 42), |
108 SkPackARGB32(0xFF, 255, 135, 0), | 108 SkPackARGB32(0xFF, 255, 135, 0), |
109 SkPackARGB32(0xFF, 255, 95, 0), | 109 SkPackARGB32(0xFF, 255, 95, 0), |
110 SkPackARGB32(0xFF, 255, 50, 0), | 110 SkPackARGB32(0xFF, 255, 50, 0), |
111 SkPackARGB32(0xFF, 255, 0, 0) | 111 SkPackARGB32(0xFF, 255, 0, 0) |
112 }; | 112 }; |
113 | 113 |
114 for (size_t i = 0; i < SK_ARRAY_COUNT(gTable)-1; ++i) { | 114 for (size_t i = 0; i < SK_ARRAY_COUNT(gTable)-1; ++i) { |
115 if (gTable[i] == dst) { | 115 if (gTable[i] == dst) { |
116 return gTable[i+1]; | 116 return gTable[i+1]; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 return gTable[SK_ARRAY_COUNT(gTable)-1]; | 120 return gTable[SK_ARRAY_COUNT(gTable)-1]; |
121 } | 121 } |
122 | 122 |
123 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } | 123 Factory getFactory() const SK_OVERRIDE { return NULL; } |
124 #ifndef SK_IGNORE_TO_STRING | 124 #ifndef SK_IGNORE_TO_STRING |
125 virtual void toString(SkString* str) const { str->set("OverdrawXfermode"); } | 125 virtual void toString(SkString* str) const { str->set("OverdrawXfermode"); } |
126 #endif | 126 #endif |
127 }; | 127 }; |
128 | 128 |
129 class SkOverdrawFilter : public SkDrawFilter { | 129 class SkOverdrawFilter : public SkDrawFilter { |
130 public: | 130 public: |
131 SkOverdrawFilter() { | 131 SkOverdrawFilter() { |
132 fXferMode = SkNEW(OverdrawXfermode); | 132 fXferMode = SkNEW(OverdrawXfermode); |
133 } | 133 } |
134 | 134 |
135 virtual ~SkOverdrawFilter() { | 135 virtual ~SkOverdrawFilter() { |
136 delete fXferMode; | 136 delete fXferMode; |
137 } | 137 } |
138 | 138 |
139 virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { | 139 bool filter(SkPaint* p, Type) SK_OVERRIDE { |
140 p->setXfermode(fXferMode); | 140 p->setXfermode(fXferMode); |
141 return true; | 141 return true; |
142 } | 142 } |
143 | 143 |
144 protected: | 144 protected: |
145 SkXfermode* fXferMode; | 145 SkXfermode* fXferMode; |
146 | 146 |
147 private: | 147 private: |
148 typedef SkDrawFilter INHERITED; | 148 typedef SkDrawFilter INHERITED; |
149 }; | 149 }; |
150 | 150 |
151 // SkTexOverrideFilter modifies every paint to use the specified | 151 // SkTexOverrideFilter modifies every paint to use the specified |
152 // texture filtering mode | 152 // texture filtering mode |
153 class SkTexOverrideFilter : public SkDrawFilter { | 153 class SkTexOverrideFilter : public SkDrawFilter { |
154 public: | 154 public: |
155 SkTexOverrideFilter() : fFilterLevel(SkPaint::kNone_FilterLevel) { | 155 SkTexOverrideFilter() : fFilterLevel(SkPaint::kNone_FilterLevel) { |
156 } | 156 } |
157 | 157 |
158 void setFilterLevel(SkPaint::FilterLevel filterLevel) { | 158 void setFilterLevel(SkPaint::FilterLevel filterLevel) { |
159 fFilterLevel = filterLevel; | 159 fFilterLevel = filterLevel; |
160 } | 160 } |
161 | 161 |
162 virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { | 162 bool filter(SkPaint* p, Type) SK_OVERRIDE { |
163 p->setFilterLevel(fFilterLevel); | 163 p->setFilterLevel(fFilterLevel); |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 protected: | 167 protected: |
168 SkPaint::FilterLevel fFilterLevel; | 168 SkPaint::FilterLevel fFilterLevel; |
169 | 169 |
170 private: | 170 private: |
171 typedef SkDrawFilter INHERITED; | 171 typedef SkDrawFilter INHERITED; |
172 }; | 172 }; |
173 | 173 |
174 class SkDebugClipVisitor : public SkCanvas::ClipVisitor { | 174 class SkDebugClipVisitor : public SkCanvas::ClipVisitor { |
175 public: | 175 public: |
176 SkDebugClipVisitor(SkCanvas* canvas) : fCanvas(canvas) {} | 176 SkDebugClipVisitor(SkCanvas* canvas) : fCanvas(canvas) {} |
177 | 177 |
178 virtual void clipRect(const SkRect& r, SkRegion::Op, bool doAA) SK_OVERRIDE
{ | 178 void clipRect(const SkRect& r, SkRegion::Op, bool doAA) SK_OVERRIDE { |
179 SkPaint p; | 179 SkPaint p; |
180 p.setColor(SK_ColorRED); | 180 p.setColor(SK_ColorRED); |
181 p.setStyle(SkPaint::kStroke_Style); | 181 p.setStyle(SkPaint::kStroke_Style); |
182 p.setAntiAlias(doAA); | 182 p.setAntiAlias(doAA); |
183 fCanvas->drawRect(r, p); | 183 fCanvas->drawRect(r, p); |
184 } | 184 } |
185 virtual void clipRRect(const SkRRect& rr, SkRegion::Op, bool doAA) SK_OVERRI
DE { | 185 void clipRRect(const SkRRect& rr, SkRegion::Op, bool doAA) SK_OVERRIDE { |
186 SkPaint p; | 186 SkPaint p; |
187 p.setColor(SK_ColorGREEN); | 187 p.setColor(SK_ColorGREEN); |
188 p.setStyle(SkPaint::kStroke_Style); | 188 p.setStyle(SkPaint::kStroke_Style); |
189 p.setAntiAlias(doAA); | 189 p.setAntiAlias(doAA); |
190 fCanvas->drawRRect(rr, p); | 190 fCanvas->drawRRect(rr, p); |
191 } | 191 } |
192 virtual void clipPath(const SkPath& path, SkRegion::Op, bool doAA) SK_OVERRI
DE { | 192 void clipPath(const SkPath& path, SkRegion::Op, bool doAA) SK_OVERRIDE { |
193 SkPaint p; | 193 SkPaint p; |
194 p.setColor(SK_ColorBLUE); | 194 p.setColor(SK_ColorBLUE); |
195 p.setStyle(SkPaint::kStroke_Style); | 195 p.setStyle(SkPaint::kStroke_Style); |
196 p.setAntiAlias(doAA); | 196 p.setAntiAlias(doAA); |
197 fCanvas->drawPath(path, p); | 197 fCanvas->drawPath(path, p); |
198 } | 198 } |
199 | 199 |
200 protected: | 200 protected: |
201 SkCanvas* fCanvas; | 201 SkCanvas* fCanvas; |
202 | 202 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 689 } |
690 | 690 |
691 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 691 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
692 if (fCalledAddStackData) { | 692 if (fCalledAddStackData) { |
693 fClipStackData.appendf("<br>"); | 693 fClipStackData.appendf("<br>"); |
694 addPathData(devPath, "pathOut"); | 694 addPathData(devPath, "pathOut"); |
695 return true; | 695 return true; |
696 } | 696 } |
697 return false; | 697 return false; |
698 } | 698 } |
OLD | NEW |