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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 this->INHERITED::flatten(buffer); | 42 this->INHERITED::flatten(buffer); |
43 buffer.writeFlattenable(fMode); | 43 buffer.writeFlattenable(fMode); |
44 } | 44 } |
45 | 45 |
46 bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy, | 46 bool SkXfermodeImageFilter::onFilterImage(Proxy* proxy, |
47 const SkBitmap& src, | 47 const SkBitmap& src, |
48 const Context& ctx, | 48 const Context& ctx, |
49 SkBitmap* dst, | 49 SkBitmap* dst, |
50 SkIPoint* offset) const { | 50 SkIPoint* offset) const { |
51 SkBitmap background = src, foreground = src; | 51 SkBitmap background = src, foreground = src; |
52 SkImageFilter* backgroundInput = getInput(0); | 52 SkImageFilter* backgroundInput = this->getInput(0); |
53 SkImageFilter* foregroundInput = getInput(1); | 53 SkImageFilter* foregroundInput = this->getInput(1); |
54 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 54 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
55 if (backgroundInput && | 55 if (backgroundInput && |
56 !backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundO
ffset)) { | 56 !backgroundInput->filterImage(proxy, src, ctx, &background, &backgroundO
ffset)) { |
57 background.reset(); | 57 background.reset(); |
58 } | 58 } |
59 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 59 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
60 if (foregroundInput && | 60 if (foregroundInput && |
61 !foregroundInput->filterImage(proxy, src, ctx, &foreground, &foregroundO
ffset)) { | 61 !foregroundInput->filterImage(proxy, src, ctx, &foreground, &foregroundO
ffset)) { |
62 foreground.reset(); | 62 foreground.reset(); |
63 } | 63 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return fMode && fMode->asFragmentProcessor(NULL, NULL, NULL) && !cropRectIsS
et(); | 126 return fMode && fMode->asFragmentProcessor(NULL, NULL, NULL) && !cropRectIsS
et(); |
127 } | 127 } |
128 | 128 |
129 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, | 129 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, |
130 const SkBitmap& src, | 130 const SkBitmap& src, |
131 const Context& ctx, | 131 const Context& ctx, |
132 SkBitmap* result, | 132 SkBitmap* result, |
133 SkIPoint* offset) const { | 133 SkIPoint* offset) const { |
134 SkBitmap background = src; | 134 SkBitmap background = src; |
135 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); | 135 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); |
136 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &backgro
und, | 136 if (this->getInput(0) && |
137 &backgroundOffset)) { | 137 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &background, &bac
kgroundOffset)) { |
138 return onFilterImage(proxy, src, ctx, result, offset); | 138 return this->onFilterImage(proxy, src, ctx, result, offset); |
139 } | 139 } |
| 140 |
140 GrTexture* backgroundTex = background.getTexture(); | 141 GrTexture* backgroundTex = background.getTexture(); |
141 | |
142 if (NULL == backgroundTex) { | 142 if (NULL == backgroundTex) { |
143 SkASSERT(false); | 143 SkASSERT(false); |
144 return false; | 144 return false; |
145 } | 145 } |
146 | 146 |
147 SkBitmap foreground = src; | 147 SkBitmap foreground = src; |
148 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); | 148 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); |
149 if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foregro
und, | 149 if (this->getInput(1) && |
150 &foregroundOffset)) { | 150 !this->getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground, &for
egroundOffset)) { |
151 return onFilterImage(proxy, src, ctx, result, offset); | 151 return this->onFilterImage(proxy, src, ctx, result, offset); |
152 } | 152 } |
153 GrTexture* foregroundTex = foreground.getTexture(); | 153 GrTexture* foregroundTex = foreground.getTexture(); |
154 GrContext* context = foregroundTex->getContext(); | 154 GrContext* context = foregroundTex->getContext(); |
155 | 155 |
156 GrFragmentProcessor* xferProcessor = NULL; | 156 GrFragmentProcessor* xferProcessor = NULL; |
157 | 157 |
158 GrSurfaceDesc desc; | 158 GrSurfaceDesc desc; |
159 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 159 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
160 desc.fWidth = src.width(); | 160 desc.fWidth = src.width(); |
161 desc.fHeight = src.height(); | 161 desc.fHeight = src.height(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 SkMatrix::I(), srcRect); | 202 SkMatrix::I(), srcRect); |
203 | 203 |
204 offset->fX = backgroundOffset.fX; | 204 offset->fX = backgroundOffset.fX; |
205 offset->fY = backgroundOffset.fY; | 205 offset->fY = backgroundOffset.fY; |
206 WrapTexture(dst, src.width(), src.height(), result); | 206 WrapTexture(dst, src.width(), src.height(), result); |
207 return true; | 207 return true; |
208 } | 208 } |
209 | 209 |
210 #endif | 210 #endif |
211 | 211 |
OLD | NEW |