| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 #if SK_SUPPORT_GPU | 112 #if SK_SUPPORT_GPU |
| 113 | 113 |
| 114 bool SkXfermodeImageFilter::canFilterImageGPU() const { | 114 bool SkXfermodeImageFilter::canFilterImageGPU() const { |
| 115 return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet(); | 115 return fMode && fMode->asFragmentProcessor(NULL, NULL) && !cropRectIsSet(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, | 118 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, |
| 119 const SkBitmap& src, | 119 const SkBitmap& src, |
| 120 const Context& ctx, | 120 const Context& ctx, |
| 121 const GrClip& clip, |
| 121 SkBitmap* result, | 122 SkBitmap* result, |
| 122 SkIPoint* offset) const { | 123 SkIPoint* offset) const { |
| 123 SkBitmap background = src; | 124 SkBitmap background = src; |
| 124 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 125 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
| 125 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro
und, | 126 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro
und, |
| 126 &backgroundOffset)) { | 127 &backgroundOffset)) { |
| 127 return onFilterImage(proxy, src, ctx, result, offset); | 128 return onFilterImage(proxy, src, ctx, result, offset); |
| 128 } | 129 } |
| 129 GrTexture* backgroundTex = background.getTexture(); | 130 GrTexture* backgroundTex = background.getTexture(); |
| 130 | 131 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), | 166 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf
fset.fX), |
| 166 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); | 167 SkIntToScalar(backgroundOffset.fY-foregroundOf
fset.fY)); |
| 167 | 168 |
| 168 | 169 |
| 169 SkRect srcRect; | 170 SkRect srcRect; |
| 170 src.getBounds(&srcRect); | 171 src.getBounds(&srcRect); |
| 171 | 172 |
| 172 GrPaint paint; | 173 GrPaint paint; |
| 173 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix); | 174 paint.addColorTextureProcessor(foregroundTex, foregroundMatrix); |
| 174 paint.addColorProcessor(xferProcessor)->unref(); | 175 paint.addColorProcessor(xferProcessor)->unref(); |
| 175 context->drawRect(dst->asRenderTarget(), paint, SkMatrix::I(), srcRect); | 176 context->drawRect(dst->asRenderTarget(), clip, paint, SkMatrix::I(), srcRect
); |
| 176 | 177 |
| 177 offset->fX = backgroundOffset.fX; | 178 offset->fX = backgroundOffset.fX; |
| 178 offset->fY = backgroundOffset.fY; | 179 offset->fY = backgroundOffset.fY; |
| 179 WrapTexture(dst, src.width(), src.height(), result); | 180 WrapTexture(dst, src.width(), src.height(), result); |
| 180 return true; | 181 return true; |
| 181 } | 182 } |
| 182 | 183 |
| 183 #endif | 184 #endif |
| 184 | 185 |
| OLD | NEW |