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 return false; |
213 } | 216 } |
214 | 217 |
215 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { | 218 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { |
216 return NULL; | 219 return NULL; |
217 } | 220 } |
218 | 221 |
219 SkShader* SkShader::CreateEmptyShader() { | 222 SkShader* SkShader::CreateEmptyShader() { |
220 return SkNEW(SkEmptyShader); | 223 return SkNEW(SkEmptyShader); |
221 } | 224 } |
222 | 225 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 if (info) { | 337 if (info) { |
335 if (info->fColors && info->fColorCount >= 1) { | 338 if (info->fColors && info->fColorCount >= 1) { |
336 info->fColors[0] = fColor; | 339 info->fColors[0] = fColor; |
337 } | 340 } |
338 info->fColorCount = 1; | 341 info->fColorCount = 1; |
339 info->fTileMode = SkShader::kRepeat_TileMode; | 342 info->fTileMode = SkShader::kRepeat_TileMode; |
340 } | 343 } |
341 return kColor_GradientType; | 344 return kColor_GradientType; |
342 } | 345 } |
343 | 346 |
| 347 #if SK_SUPPORT_GPU |
| 348 |
| 349 bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint, |
| 350 const SkMatrix* localMatrix, GrColor* grColor, |
| 351 GrEffectRef** grEffect) const { |
| 352 *grEffect = NULL; |
| 353 SkColor skColor = fColor; |
| 354 U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha()); |
| 355 *grColor = SkColor2GrColor(SkColorSetA(skColor, newA)); |
| 356 return true; |
| 357 } |
| 358 |
| 359 #else |
| 360 |
| 361 bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint, |
| 362 const SkMatrix* localMatrix, GrColor* grCol
or, |
| 363 GrEffectRef** grEffect) const { |
| 364 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 365 return false; |
| 366 } |
| 367 |
| 368 #endif |
| 369 |
344 #ifndef SK_IGNORE_TO_STRING | 370 #ifndef SK_IGNORE_TO_STRING |
345 void SkColorShader::toString(SkString* str) const { | 371 void SkColorShader::toString(SkString* str) const { |
346 str->append("SkColorShader: ("); | 372 str->append("SkColorShader: ("); |
347 | 373 |
348 str->append("Color: "); | 374 str->append("Color: "); |
349 str->appendHex(fColor); | 375 str->appendHex(fColor); |
350 | 376 |
351 this->INHERITED::toString(str); | 377 this->INHERITED::toString(str); |
352 | 378 |
353 str->append(")"); | 379 str->append(")"); |
354 } | 380 } |
355 #endif | 381 #endif |
356 | 382 |
357 /////////////////////////////////////////////////////////////////////////////// | 383 /////////////////////////////////////////////////////////////////////////////// |
358 | 384 |
359 #ifndef SK_IGNORE_TO_STRING | 385 #ifndef SK_IGNORE_TO_STRING |
360 #include "SkEmptyShader.h" | 386 #include "SkEmptyShader.h" |
361 | 387 |
362 void SkEmptyShader::toString(SkString* str) const { | 388 void SkEmptyShader::toString(SkString* str) const { |
363 str->append("SkEmptyShader: ("); | 389 str->append("SkEmptyShader: ("); |
364 | 390 |
365 this->INHERITED::toString(str); | 391 this->INHERITED::toString(str); |
366 | 392 |
367 str->append(")"); | 393 str->append(")"); |
368 } | 394 } |
369 #endif | 395 #endif |
OLD | NEW |