Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 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 "SkGr.h" | 8 #include "SkGr.h" |
| 9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
| 10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 dm = SkXfermode::kZero_Coeff; | 423 dm = SkXfermode::kZero_Coeff; |
| 424 } | 424 } |
| 425 } else { | 425 } else { |
| 426 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");) | 426 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");) |
| 427 // Fall back to src-over | 427 // Fall back to src-over |
| 428 sm = SkXfermode::kOne_Coeff; | 428 sm = SkXfermode::kOne_Coeff; |
| 429 dm = SkXfermode::kISA_Coeff; | 429 dm = SkXfermode::kISA_Coeff; |
| 430 } | 430 } |
| 431 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); | 431 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); |
| 432 | 432 |
| 433 if (justAlpha) { | 433 if (justAlpha) { |
|
bsalomon
2014/06/05 17:32:44
Can we kill this?
dandov
2014/06/06 21:50:43
I removed this by modifying the arguments that thi
| |
| 434 uint8_t alpha = skPaint.getAlpha(); | 434 uint8_t alpha = skPaint.getAlpha(); |
| 435 grPaint->setColor(GrColorPackRGBA(alpha, alpha, alpha, alpha)); | 435 grPaint->setColor(GrColorPackRGBA(alpha, alpha, alpha, alpha)); |
| 436 // justAlpha is currently set to true only if there is a texture, | 436 // justAlpha is currently set to true only if there is a texture, |
| 437 // so constantColor should not also be true. | 437 // so constantColor should not also be true. |
| 438 SkASSERT(!constantColor); | 438 SkASSERT(!constantColor); |
| 439 } else { | 439 } else { |
| 440 grPaint->setColor(SkColor2GrColor(skPaint.getColor())); | 440 grPaint->setColor(SkColor2GrColor(skPaint.getColor())); |
| 441 } | 441 } |
| 442 | 442 |
| 443 SkColorFilter* colorFilter = skPaint.getColorFilter(); | 443 SkColorFilter* colorFilter = skPaint.getColorFilter(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 } | 485 } |
| 486 | 486 |
| 487 // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and | 487 // SkShader::asNewEffect() may do offscreen rendering. Save off the current RT, clip, and |
| 488 // matrix. We don't reset the matrix on the context because SkShader::asNewE ffect may use | 488 // matrix. We don't reset the matrix on the context because SkShader::asNewE ffect may use |
| 489 // GrContext::getMatrix() to know the transformation from local coords to de vice space. | 489 // GrContext::getMatrix() to know the transformation from local coords to de vice space. |
| 490 GrContext::AutoRenderTarget art(context, NULL); | 490 GrContext::AutoRenderTarget art(context, NULL); |
| 491 GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip); | 491 GrContext::AutoClip ac(context, GrContext::AutoClip::kWideOpen_InitialClip); |
| 492 AutoMatrix am(context); | 492 AutoMatrix am(context); |
| 493 | 493 |
| 494 // setup the shader as the first color effect on the paint | 494 // setup the shader as the first color effect on the paint |
| 495 SkAutoTUnref<GrEffectRef> effect(shader->asNewEffect(context, skPaint, NULL) ); | 495 GrColor grColor; |
| 496 GrEffectRef* grEffect; | |
| 497 grEffect = NULL; | |
| 498 shader->asNewEffect(context, skPaint, &grColor, &grEffect, NULL); | |
|
jvanverth1
2014/06/05 17:03:07
The bool return value isn't checked here. Also, in
bsalomon
2014/06/05 17:32:44
I can't think of a better way other than sending d
jvanverth1
2014/06/05 17:36:31
If it does succeed, it should also use the returne
dandov
2014/06/06 21:50:44
When the call to asNewEffect returns true (if noth
| |
| 499 SkAutoTUnref<GrEffectRef> effect(grEffect); | |
| 496 if (NULL != effect.get()) { | 500 if (NULL != effect.get()) { |
| 497 grPaint->addColorEffect(effect); | 501 grPaint->addColorEffect(effect); |
| 498 // Now setup the rest of the paint. | 502 // Now setup the rest of the paint. |
| 499 SkPaint2GrPaintNoShader(context, skPaint, true, false, grPaint); | 503 SkPaint2GrPaintNoShader(context, skPaint, true, false, grPaint); |
| 500 } else { | 504 } else { |
| 501 // We still don't have SkColorShader::asNewEffect() implemented. | 505 // We still don't have SkColorShader::asNewEffect() implemented. |
| 502 SkShader::GradientInfo info; | 506 SkShader::GradientInfo info; |
| 503 SkColor color; | 507 SkColor color; |
| 504 | 508 |
| 505 info.fColors = &color; | 509 info.fColors = &color; |
| 506 info.fColorOffsets = NULL; | 510 info.fColorOffsets = NULL; |
| 507 info.fColorCount = 1; | 511 info.fColorCount = 1; |
| 508 if (SkShader::kColor_GradientType == shader->asAGradient(&info)) { | 512 if (SkShader::kColor_GradientType == shader->asAGradient(&info)) { |
| 509 SkPaint copy(skPaint); | 513 SkPaint copy(skPaint); |
| 510 copy.setShader(NULL); | 514 copy.setShader(NULL); |
| 511 // modulate the paint alpha by the shader's solid color alpha | 515 // modulate the paint alpha by the shader's solid color alpha |
| 512 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); | 516 U8CPU newA = SkMulDiv255Round(SkColorGetA(color), copy.getAlpha()); |
| 513 copy.setColor(SkColorSetA(color, newA)); | 517 copy.setColor(SkColorSetA(color, newA)); |
| 514 SkPaint2GrPaintNoShader(context, copy, false, constantColor, grPaint ); | 518 SkPaint2GrPaintNoShader(context, copy, false, constantColor, grPaint ); |
| 515 } else { | 519 } else { |
| 516 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPa int); | 520 SkPaint2GrPaintNoShader(context, skPaint, false, constantColor, grPa int); |
| 517 } | 521 } |
| 518 } | 522 } |
| 519 } | 523 } |
| OLD | NEW |