OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "effects/GrTextureDomainEffect.h" | 10 #include "effects/GrTextureDomainEffect.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // color once while converting to GrPaint and then ignored. | 486 // color once while converting to GrPaint and then ignored. |
487 inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev, | 487 inline bool skPaint2GrPaintNoShader(SkGpuDevice* dev, |
488 const SkPaint& skPaint, | 488 const SkPaint& skPaint, |
489 bool justAlpha, | 489 bool justAlpha, |
490 bool constantColor, | 490 bool constantColor, |
491 GrPaint* grPaint) { | 491 GrPaint* grPaint) { |
492 | 492 |
493 grPaint->setDither(skPaint.isDither()); | 493 grPaint->setDither(skPaint.isDither()); |
494 grPaint->setAntiAlias(skPaint.isAntiAlias()); | 494 grPaint->setAntiAlias(skPaint.isAntiAlias()); |
495 | 495 |
496 SkXfermode::Coeff sm = SkXfermode::kOne_Coeff; | 496 SkXfermode::Coeff sm; |
497 SkXfermode::Coeff dm = SkXfermode::kISA_Coeff; | 497 SkXfermode::Coeff dm; |
498 | 498 |
499 SkXfermode* mode = skPaint.getXfermode(); | 499 SkXfermode* mode = skPaint.getXfermode(); |
500 GrEffectRef* xferEffect = NULL; | 500 GrEffectRef* xferEffect = NULL; |
501 if (SkXfermode::AsNewEffect(mode, dev->context(), &xferEffect, &sm, &dm)) { | 501 if (SkXfermode::AsNewEffectOrCoeff(mode, dev->context(), &xferEffect, &sm, &
dm)) { |
502 SkSafeUnref(grPaint->colorStage(kXfermodeEffectIdx)->setEffect(xferEffec
t)); | 502 if (NULL != xferEffect) { |
| 503 grPaint->colorStage(kXfermodeEffectIdx)->setEffect(xferEffect)->unre
f(); |
| 504 // This may not be the right place to have this logic but we set the
GPU blend to |
| 505 // src-over so that fractional coverage will be accounted for correc
tly. |
| 506 sm = SkXfermode::kOne_Coeff; |
| 507 dm = SkXfermode::kISA_Coeff; |
| 508 } |
503 } else { | 509 } else { |
504 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");) | 510 //SkDEBUGCODE(SkDebugf("Unsupported xfer mode.\n");) |
505 #if 0 | 511 #if 0 |
506 return false; | 512 return false; |
| 513 #else |
| 514 // Fall back to src-over |
| 515 sm = SkXfermode::kOne_Coeff; |
| 516 dm = SkXfermode::kISA_Coeff; |
507 #endif | 517 #endif |
508 } | 518 } |
509 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); | 519 grPaint->setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblend(dm)); |
510 | 520 |
511 if (justAlpha) { | 521 if (justAlpha) { |
512 uint8_t alpha = skPaint.getAlpha(); | 522 uint8_t alpha = skPaint.getAlpha(); |
513 grPaint->setColor(GrColorPackRGBA(alpha, alpha, alpha, alpha)); | 523 grPaint->setColor(GrColorPackRGBA(alpha, alpha, alpha, alpha)); |
514 // justAlpha is currently set to true only if there is a texture, | 524 // justAlpha is currently set to true only if there is a texture, |
515 // so constantColor should not also be true. | 525 // so constantColor should not also be true. |
516 GrAssert(!constantColor); | 526 GrAssert(!constantColor); |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 GrTexture* texture, | 1858 GrTexture* texture, |
1849 bool needClear) | 1859 bool needClear) |
1850 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { | 1860 : SkDevice(make_bitmap(context, texture->asRenderTarget())) { |
1851 | 1861 |
1852 GrAssert(texture && texture->asRenderTarget()); | 1862 GrAssert(texture && texture->asRenderTarget()); |
1853 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1863 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1854 // cache. We pass true for the third argument so that it will get unlocked. | 1864 // cache. We pass true for the third argument so that it will get unlocked. |
1855 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1865 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1856 fNeedClear = needClear; | 1866 fNeedClear = needClear; |
1857 } | 1867 } |
OLD | NEW |