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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 if (NULL != colorFilter) { | 465 if (NULL != colorFilter) { |
466 // if the source color is a constant then apply the filter here once rat
her than per pixel | 466 // if the source color is a constant then apply the filter here once rat
her than per pixel |
467 // in a shader. | 467 // in a shader. |
468 if (constantColor) { | 468 if (constantColor) { |
469 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); | 469 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); |
470 grPaint->setColor(SkColor2GrColor(filtered)); | 470 grPaint->setColor(SkColor2GrColor(filtered)); |
471 } else { | 471 } else { |
472 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(dev->conte
xt())); | 472 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(dev->conte
xt())); |
473 if (NULL != effect.get()) { | 473 if (NULL != effect.get()) { |
474 grPaint->addColorEffect(effect); | 474 grPaint->addColorEffect(effect); |
475 } else { | |
476 // TODO: rewrite this using asNewEffect() | |
477 SkColor color; | |
478 SkXfermode::Mode filterMode; | |
479 if (colorFilter->asColorMode(&color, &filterMode)) { | |
480 grPaint->setXfermodeColorFilter(filterMode, SkColor2GrColor(
color)); | |
481 } | |
482 } | 475 } |
483 } | 476 } |
484 } | 477 } |
485 | 478 |
486 return true; | 479 return true; |
487 } | 480 } |
488 | 481 |
489 // This function is similar to skPaint2GrPaintNoShader but also converts | 482 // This function is similar to skPaint2GrPaintNoShader but also converts |
490 // skPaint's shader to a GrTexture/GrEffectStage if possible. The texture to | 483 // skPaint's shader to a GrTexture/GrEffectStage if possible. The texture to |
491 // be used is set on grPaint and returned in param act. constantColor has the | 484 // be used is set on grPaint and returned in param act. constantColor has the |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 GrTexture* texture, | 1844 GrTexture* texture, |
1852 bool needClear) | 1845 bool needClear) |
1853 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1846 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1854 | 1847 |
1855 SkASSERT(texture && texture->asRenderTarget()); | 1848 SkASSERT(texture && texture->asRenderTarget()); |
1856 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1849 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1857 // cache. We pass true for the third argument so that it will get unlocked. | 1850 // cache. We pass true for the third argument so that it will get unlocked. |
1858 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1851 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1859 fNeedClear = needClear; | 1852 fNeedClear = needClear; |
1860 } | 1853 } |
OLD | NEW |