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" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 GrSurfaceDesc desc; | 147 GrSurfaceDesc desc; |
148 desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag; | 148 desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag; |
149 desc.fWidth = src.width(); | 149 desc.fWidth = src.width(); |
150 desc.fHeight = src.height(); | 150 desc.fHeight = src.height(); |
151 desc.fConfig = kSkia8888_GrPixelConfig; | 151 desc.fConfig = kSkia8888_GrPixelConfig; |
152 SkAutoTUnref<GrTexture> dst( | 152 SkAutoTUnref<GrTexture> dst( |
153 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); | 153 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); |
154 if (!dst) { | 154 if (!dst) { |
155 return false; | 155 return false; |
156 } | 156 } |
157 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); | |
158 | 157 |
159 if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) { | 158 if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) { |
160 // canFilterImageGPU() should've taken care of this | 159 // canFilterImageGPU() should've taken care of this |
161 SkASSERT(false); | 160 SkASSERT(false); |
162 return false; | 161 return false; |
163 } | 162 } |
164 | 163 |
165 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg
roundTex); | 164 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg
roundTex); |
166 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), | 165 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), |
167 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); | 166 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); |
168 | 167 |
169 | 168 |
170 SkRect srcRect; | 169 SkRect srcRect; |
171 src.getBounds(&srcRect); | 170 src.getBounds(&srcRect); |
172 | 171 |
173 GrPaint paint; | 172 GrPaint paint; |
174 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix); | 173 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix); |
175 paint.addColorProcessor(xferProcessor)->unref(); | 174 paint.addColorProcessor(xferProcessor)->unref(); |
176 context->drawRect(paint, SkMatrix::I(), srcRect); | 175 context->drawRect(dst->asRenderTarget(), paint, SkMatrix::I(), srcRect); |
177 | 176 |
178 offset->fX = backgroundOffset.fX; | 177 offset->fX = backgroundOffset.fX; |
179 offset->fY = backgroundOffset.fY; | 178 offset->fY = backgroundOffset.fY; |
180 WrapTexture(dst, src.width(), src.height(), result); | 179 WrapTexture(dst, src.width(), src.height(), result); |
181 return true; | 180 return true; |
182 } | 181 } |
183 | 182 |
184 #endif | 183 #endif |
185 | 184 |
OLD | NEW |