OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 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 "SkXfermodeImageFilter.h" | 8 #include "SkXfermodeImageFilter.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkXfermode.h" | 14 #include "SkXfermode.h" |
15 #if SK_SUPPORT_GPU | 15 #if SK_SUPPORT_GPU |
16 #include "GrContext.h" | 16 #include "GrContext.h" |
17 #include "effects/GrSimpleTextureEffect.h" | 17 #include "effects/GrTextureDomain.h" |
18 #include "SkGr.h" | 18 #include "SkGr.h" |
19 #endif | 19 #endif |
20 | 20 |
21 /////////////////////////////////////////////////////////////////////////////// | 21 /////////////////////////////////////////////////////////////////////////////// |
22 | 22 |
23 SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode, | 23 SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode, |
24 SkImageFilter* inputs[2], | 24 SkImageFilter* inputs[2], |
25 const CropRect* cropRect) | 25 const CropRect* cropRect) |
26 : INHERITED(2, inputs, cropRect), fMode(mode) { | 26 : INHERITED(2, inputs, cropRect), fMode(mode) { |
27 SkSafeRef(fMode); | 27 SkSafeRef(fMode); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg
roundTex); | 163 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg
roundTex); |
164 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), | 164 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), |
165 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); | 165 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); |
166 | 166 |
167 | 167 |
168 SkRect srcRect; | 168 SkRect srcRect; |
169 src.getBounds(&srcRect); | 169 src.getBounds(&srcRect); |
170 | 170 |
171 GrPaint paint; | 171 GrPaint paint; |
172 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix); | 172 SkAutoTUnref<GrFragmentProcessor> foregroundDomain(GrTextureDomainEffect::Cr
eate( |
| 173 foregroundTex, foregroundMatrix, |
| 174 GrTextureDomain::MakeTexelDomain(foregroundTex, foreground.bounds()), |
| 175 GrTextureDomain::kDecal_Mode, |
| 176 GrTextureParams::kNone_FilterMode) |
| 177 ); |
| 178 |
| 179 paint.addColorProcessor(foregroundDomain.get()); |
173 paint.addColorProcessor(xferProcessor)->unref(); | 180 paint.addColorProcessor(xferProcessor)->unref(); |
174 context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix
::I(), srcRect); | 181 context->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix
::I(), srcRect); |
175 | 182 |
176 offset->fX = backgroundOffset.fX; | 183 offset->fX = backgroundOffset.fX; |
177 offset->fY = backgroundOffset.fY; | 184 offset->fY = backgroundOffset.fY; |
178 WrapTexture(dst, src.width(), src.height(), result); | 185 WrapTexture(dst, src.width(), src.height(), result); |
179 return true; | 186 return true; |
180 } | 187 } |
181 | 188 |
182 #endif | 189 #endif |
183 | 190 |
OLD | NEW |