OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkBlendImageFilter.h" | 8 #include "SkBlendImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 desc.fWidth = src.width(); | 187 desc.fWidth = src.width(); |
188 desc.fHeight = src.height(); | 188 desc.fHeight = src.height(); |
189 desc.fConfig = kSkia8888_GrPixelConfig; | 189 desc.fConfig = kSkia8888_GrPixelConfig; |
190 | 190 |
191 GrAutoScratchTexture ast(context, desc); | 191 GrAutoScratchTexture ast(context, desc); |
192 SkAutoTUnref<GrTexture> dst(ast.detach()); | 192 SkAutoTUnref<GrTexture> dst(ast.detach()); |
193 | 193 |
194 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | 194 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); |
195 | 195 |
196 GrPaint paint; | 196 GrPaint paint; |
197 paint.colorStage(0)->setEffect( | 197 paint.addColorEffect(GrBlendEffect::Create(fMode, |
198 GrBlendEffect::Create(fMode, foreground, foregroundOffset, background, b
ackgroundOffset))->unref(); | 198 foreground, foregroundOffset, |
| 199 background, backgroundOffset))->u
nref(); |
199 SkRect srcRect; | 200 SkRect srcRect; |
200 src.getBounds(&srcRect); | 201 src.getBounds(&srcRect); |
201 context->drawRect(paint, srcRect); | 202 context->drawRect(paint, srcRect); |
202 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul
t); | 203 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul
t); |
203 } | 204 } |
204 | 205 |
205 /////////////////////////////////////////////////////////////////////////////// | 206 /////////////////////////////////////////////////////////////////////////////// |
206 | 207 |
207 GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode, | 208 GrBlendEffect::GrBlendEffect(SkBlendImageFilter::Mode mode, |
208 GrTexture* foreground, | 209 GrTexture* foreground, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 EffectKey bgKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatri
x(bgTex), | 340 EffectKey bgKey = GrGLEffectMatrix::GenKey(GrEffect::MakeDivByTextureWHMatri
x(bgTex), |
340 drawEffect, | 341 drawEffect, |
341 kCoordsType, | 342 kCoordsType, |
342 bgTex); | 343 bgTex); |
343 bgKey <<= GrGLEffectMatrix::kKeyBits; | 344 bgKey <<= GrGLEffectMatrix::kKeyBits; |
344 EffectKey modeKey = blend.mode() << (2 * GrGLEffectMatrix::kKeyBits); | 345 EffectKey modeKey = blend.mode() << (2 * GrGLEffectMatrix::kKeyBits); |
345 | 346 |
346 return modeKey | bgKey | fgKey; | 347 return modeKey | bgKey | fgKey; |
347 } | 348 } |
348 #endif | 349 #endif |
OLD | NEW |