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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 if (NULL != colorFilter) { | 501 if (NULL != colorFilter) { |
502 // if the source color is a constant then apply the filter here once rat
her than per pixel | 502 // if the source color is a constant then apply the filter here once rat
her than per pixel |
503 // in a shader. | 503 // in a shader. |
504 if (constantColor) { | 504 if (constantColor) { |
505 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); | 505 SkColor filtered = colorFilter->filterColor(skPaint.getColor()); |
506 grPaint->setColor(SkColor2GrColor(filtered)); | 506 grPaint->setColor(SkColor2GrColor(filtered)); |
507 } else { | 507 } else { |
508 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(dev->conte
xt())); | 508 SkAutoTUnref<GrEffectRef> effect(colorFilter->asNewEffect(dev->conte
xt())); |
509 if (NULL != effect.get()) { | 509 if (NULL != effect.get()) { |
510 grPaint->addColorEffect(effect); | 510 grPaint->addColorEffect(effect); |
511 } else { | |
512 // TODO: rewrite this using asNewEffect() | |
513 SkColor color; | |
514 SkXfermode::Mode filterMode; | |
515 if (colorFilter->asColorMode(&color, &filterMode)) { | |
516 grPaint->setXfermodeColorFilter(filterMode, SkColor2GrColor(
color)); | |
517 } | |
518 } | 511 } |
519 } | 512 } |
520 } | 513 } |
521 | 514 |
522 return true; | 515 return true; |
523 } | 516 } |
524 | 517 |
525 // This function is similar to skPaint2GrPaintNoShader but also converts | 518 // This function is similar to skPaint2GrPaintNoShader but also converts |
526 // skPaint's shader to a GrTexture/GrEffectStage if possible. The texture to | 519 // skPaint's shader to a GrTexture/GrEffectStage if possible. The texture to |
527 // be used is set on grPaint and returned in param act. constantColor has the | 520 // be used is set on grPaint and returned in param act. constantColor has the |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 GrTexture* texture, | 1871 GrTexture* texture, |
1879 bool needClear) | 1872 bool needClear) |
1880 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1873 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1881 | 1874 |
1882 SkASSERT(texture && texture->asRenderTarget()); | 1875 SkASSERT(texture && texture->asRenderTarget()); |
1883 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture | 1876 // This constructor is called from onCreateCompatibleDevice. It has locked t
he RT in the texture |
1884 // cache. We pass true for the third argument so that it will get unlocked. | 1877 // cache. We pass true for the third argument so that it will get unlocked. |
1885 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1878 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1886 fNeedClear = needClear; | 1879 fNeedClear = needClear; |
1887 } | 1880 } |
OLD | NEW |