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 "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
| 9 #include "SkColorShader.h" |
9 #include "SkEmptyShader.h" | 10 #include "SkEmptyShader.h" |
10 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
11 #include "SkMallocPixelRef.h" | 12 #include "SkMallocPixelRef.h" |
12 #include "SkPaint.h" | 13 #include "SkPaint.h" |
13 #include "SkPicture.h" | 14 #include "SkPicture.h" |
14 #include "SkPictureShader.h" | 15 #include "SkPictureShader.h" |
15 #include "SkScalar.h" | 16 #include "SkScalar.h" |
16 #include "SkShader.h" | 17 #include "SkShader.h" |
17 #include "SkThread.h" | 18 #include "SkThread.h" |
18 #include "SkWriteBuffer.h" | 19 #include "SkWriteBuffer.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 total.setConcat(*rec.fMatrix, fLocalMatrix); | 75 total.setConcat(*rec.fMatrix, fLocalMatrix); |
75 | 76 |
76 const SkMatrix* m = &total; | 77 const SkMatrix* m = &total; |
77 if (rec.fLocalMatrix) { | 78 if (rec.fLocalMatrix) { |
78 total.setConcat(*m, *rec.fLocalMatrix); | 79 total.setConcat(*m, *rec.fLocalMatrix); |
79 m = &total; | 80 m = &total; |
80 } | 81 } |
81 return m->invert(totalInverse); | 82 return m->invert(totalInverse); |
82 } | 83 } |
83 | 84 |
| 85 bool SkShader::asLuminanceColor(SkColor* colorPtr) const { |
| 86 SkColor storage; |
| 87 if (NULL == colorPtr) { |
| 88 colorPtr = &storage; |
| 89 } |
| 90 if (this->onAsLuminanceColor(colorPtr)) { |
| 91 *colorPtr = SkColorSetA(*colorPtr, 0xFF); // we only return opaque |
| 92 return true; |
| 93 } |
| 94 return false; |
| 95 } |
| 96 |
84 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { | 97 SkShader::Context* SkShader::createContext(const ContextRec& rec, void* storage)
const { |
85 if (!this->computeTotalInverse(rec, NULL)) { | 98 if (!this->computeTotalInverse(rec, NULL)) { |
86 return NULL; | 99 return NULL; |
87 } | 100 } |
88 return this->onCreateContext(rec, storage); | 101 return this->onCreateContext(rec, storage); |
89 } | 102 } |
90 | 103 |
91 SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const
{ | 104 SkShader::Context* SkShader::onCreateContext(const ContextRec& rec, void*) const
{ |
92 return NULL; | 105 return NULL; |
93 } | 106 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 230 } |
218 | 231 |
219 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { | 232 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { |
220 return NULL; | 233 return NULL; |
221 } | 234 } |
222 | 235 |
223 SkShader* SkShader::CreateEmptyShader() { | 236 SkShader* SkShader::CreateEmptyShader() { |
224 return SkNEW(SkEmptyShader); | 237 return SkNEW(SkEmptyShader); |
225 } | 238 } |
226 | 239 |
| 240 SkShader* SkShader::CreateColorShader(SkColor color) { |
| 241 return SkNEW_ARGS(SkColorShader, (color)); |
| 242 } |
| 243 |
227 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, | 244 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMo
de tmy, |
228 const SkMatrix* localMatrix) { | 245 const SkMatrix* localMatrix) { |
229 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); | 246 return ::CreateBitmapShader(src, tmx, tmy, localMatrix, NULL); |
230 } | 247 } |
231 | 248 |
232 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my, | 249 SkShader* SkShader::CreatePictureShader(SkPicture* src, TileMode tmx, TileMode t
my, |
233 const SkMatrix* localMatrix, const SkRec
t* tile) { | 250 const SkMatrix* localMatrix, const SkRec
t* tile) { |
234 return SkPictureShader::Create(src, tmx, tmy, localMatrix, tile); | 251 return SkPictureShader::Create(src, tmx, tmy, localMatrix, tile); |
235 } | 252 } |
236 | 253 |
237 #ifndef SK_IGNORE_TO_STRING | 254 #ifndef SK_IGNORE_TO_STRING |
238 void SkShader::toString(SkString* str) const { | 255 void SkShader::toString(SkString* str) const { |
239 if (!fLocalMatrix.isIdentity()) { | 256 if (!fLocalMatrix.isIdentity()) { |
240 str->append(" "); | 257 str->append(" "); |
241 fLocalMatrix.toString(str); | 258 fLocalMatrix.toString(str); |
242 } | 259 } |
243 } | 260 } |
244 #endif | 261 #endif |
245 | 262 |
246 ////////////////////////////////////////////////////////////////////////////// | 263 ////////////////////////////////////////////////////////////////////////////// |
247 | 264 |
248 #include "SkColorShader.h" | |
249 #include "SkUtils.h" | 265 #include "SkUtils.h" |
250 | 266 |
251 SkColorShader::SkColorShader(SkColor c) | 267 SkColorShader::SkColorShader(SkColor c) |
252 : fColor(c) { | 268 : fColor(c) { |
253 } | 269 } |
254 | 270 |
255 bool SkColorShader::isOpaque() const { | 271 bool SkColorShader::isOpaque() const { |
256 return SkColorGetA(fColor) == 255; | 272 return SkColorGetA(fColor) == 255; |
257 } | 273 } |
258 | 274 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 #include "SkEmptyShader.h" | 414 #include "SkEmptyShader.h" |
399 | 415 |
400 void SkEmptyShader::toString(SkString* str) const { | 416 void SkEmptyShader::toString(SkString* str) const { |
401 str->append("SkEmptyShader: ("); | 417 str->append("SkEmptyShader: ("); |
402 | 418 |
403 this->INHERITED::toString(str); | 419 this->INHERITED::toString(str); |
404 | 420 |
405 str->append(")"); | 421 str->append(")"); |
406 } | 422 } |
407 #endif | 423 #endif |
OLD | NEW |