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 "SkEmptyShader.h" | 9 #include "SkEmptyShader.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkMallocPixelRef.h" | 11 #include "SkMallocPixelRef.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
14 #include "SkPictureShader.h" | 14 #include "SkPictureShader.h" |
15 #include "SkScalar.h" | 15 #include "SkScalar.h" |
16 #include "SkShader.h" | 16 #include "SkShader.h" |
17 #include "SkThread.h" | 17 #include "SkThread.h" |
18 #include "SkWriteBuffer.h" | 18 #include "SkWriteBuffer.h" |
19 #include "SkGr.h" | |
19 | 20 |
20 //#define SK_TRACK_SHADER_LIFETIME | 21 //#define SK_TRACK_SHADER_LIFETIME |
21 | 22 |
22 #ifdef SK_TRACK_SHADER_LIFETIME | 23 #ifdef SK_TRACK_SHADER_LIFETIME |
23 static int32_t gShaderCounter; | 24 static int32_t gShaderCounter; |
24 #endif | 25 #endif |
25 | 26 |
26 static inline void inc_shader_counter() { | 27 static inline void inc_shader_counter() { |
27 #ifdef SK_TRACK_SHADER_LIFETIME | 28 #ifdef SK_TRACK_SHADER_LIFETIME |
28 int32_t prev = sk_atomic_inc(&gShaderCounter); | 29 int32_t prev = sk_atomic_inc(&gShaderCounter); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 ////////////////////////////////////////////////////////////////////////////// | 202 ////////////////////////////////////////////////////////////////////////////// |
202 | 203 |
203 SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, TileMode*) const { | 204 SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, TileMode*) const { |
204 return kNone_BitmapType; | 205 return kNone_BitmapType; |
205 } | 206 } |
206 | 207 |
207 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { | 208 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { |
208 return kNone_GradientType; | 209 return kNone_GradientType; |
209 } | 210 } |
210 | 211 |
211 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const { | 212 bool SkShader::asNewEffect(GrContext* context, const SkPaint& paint, |
212 return NULL; | 213 const SkMatrix* localMatrixOrNull, GrColor* grColor, |
214 GrEffectRef** grEffect) const { | |
215 *grEffect = NULL; | |
bsalomon
2014/06/09 14:11:30
I'd feel better if this did nothing other than ret
dandov
2014/06/09 19:10:55
Done.
| |
216 *grColor = SkColor2GrColor(paint.getColor()); | |
dandov
2014/06/06 21:50:44
default grColor value is the paint's color
bsalomon
2014/06/09 14:11:31
I think this default should be implemented by the
| |
217 return false; | |
218 } | |
219 | |
220 GrColor SkShader::getColorAsAlpha(SkPaint paint) const { | |
bsalomon
2014/06/09 14:11:31
Having this as a function doesn't seem to add much
dandov
2014/06/09 19:10:55
Done.
| |
221 return SkColor2GrColorJustAlpha(paint.getColor()); | |
213 } | 222 } |
214 | 223 |
215 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { | 224 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { |
216 return NULL; | 225 return NULL; |
217 } | 226 } |
218 | 227 |
219 SkShader* SkShader::CreateEmptyShader() { | 228 SkShader* SkShader::CreateEmptyShader() { |
220 return SkNEW(SkEmptyShader); | 229 return SkNEW(SkEmptyShader); |
221 } | 230 } |
222 | 231 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 if (info) { | 343 if (info) { |
335 if (info->fColors && info->fColorCount >= 1) { | 344 if (info->fColors && info->fColorCount >= 1) { |
336 info->fColors[0] = fColor; | 345 info->fColors[0] = fColor; |
337 } | 346 } |
338 info->fColorCount = 1; | 347 info->fColorCount = 1; |
339 info->fTileMode = SkShader::kRepeat_TileMode; | 348 info->fTileMode = SkShader::kRepeat_TileMode; |
340 } | 349 } |
341 return kColor_GradientType; | 350 return kColor_GradientType; |
342 } | 351 } |
343 | 352 |
353 bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint, | |
354 const SkMatrix* localMatrix, GrColor* grColor, | |
355 GrEffectRef** grEffect) const { | |
dandov
2014/06/06 21:50:44
Use the SkColorShader's color as the grColor, modu
| |
356 *grEffect = NULL; | |
357 SkColor skColor = fColor; | |
358 U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha()); | |
359 *grColor = SkColor2GrColor(SkColorSetA(skColor, newA)); | |
360 return false; | |
bsalomon
2014/06/09 14:11:31
This should return true since it succeeded. Otherw
dandov
2014/06/09 19:10:55
Done.
| |
361 } | |
362 | |
344 #ifndef SK_IGNORE_TO_STRING | 363 #ifndef SK_IGNORE_TO_STRING |
345 void SkColorShader::toString(SkString* str) const { | 364 void SkColorShader::toString(SkString* str) const { |
346 str->append("SkColorShader: ("); | 365 str->append("SkColorShader: ("); |
347 | 366 |
348 str->append("Color: "); | 367 str->append("Color: "); |
349 str->appendHex(fColor); | 368 str->appendHex(fColor); |
350 | 369 |
351 this->INHERITED::toString(str); | 370 this->INHERITED::toString(str); |
352 | 371 |
353 str->append(")"); | 372 str->append(")"); |
354 } | 373 } |
355 #endif | 374 #endif |
356 | 375 |
357 /////////////////////////////////////////////////////////////////////////////// | 376 /////////////////////////////////////////////////////////////////////////////// |
358 | 377 |
359 #ifndef SK_IGNORE_TO_STRING | 378 #ifndef SK_IGNORE_TO_STRING |
360 #include "SkEmptyShader.h" | 379 #include "SkEmptyShader.h" |
361 | 380 |
362 void SkEmptyShader::toString(SkString* str) const { | 381 void SkEmptyShader::toString(SkString* str) const { |
363 str->append("SkEmptyShader: ("); | 382 str->append("SkEmptyShader: ("); |
364 | 383 |
365 this->INHERITED::toString(str); | 384 this->INHERITED::toString(str); |
366 | 385 |
367 str->append(")"); | 386 str->append(")"); |
368 } | 387 } |
369 #endif | 388 #endif |
OLD | NEW |