Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 153113003: Fix image filter crop offsets for GPU path. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 bool SkImageFilter::canFilterImageGPU() const { 142 bool SkImageFilter::canFilterImageGPU() const {
143 return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect()); 143 return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect());
144 } 144 }
145 145
146 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa trix& ctm, 146 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa trix& ctm,
147 SkBitmap* result, SkIPoint* offset) { 147 SkBitmap* result, SkIPoint* offset) {
148 #if SK_SUPPORT_GPU 148 #if SK_SUPPORT_GPU
149 SkBitmap input; 149 SkBitmap input;
150 SkASSERT(fInputCount == 1); 150 SkASSERT(fInputCount == 1);
151 if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ct m, &input, offset)) { 151 SkIPoint srcOffset = SkIPoint::Make(0, 0);
152 if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ct m, &input, &srcOffset)) {
bsalomon 2014/02/03 21:31:08 if all the callers now pass a non-NULL value maybe
152 return false; 153 return false;
153 } 154 }
154 GrTexture* srcTexture = input.getTexture(); 155 GrTexture* srcTexture = input.getTexture();
155 SkIRect bounds; 156 SkIRect bounds;
156 src.getBounds(&bounds); 157 src.getBounds(&bounds);
158 bounds.offset(srcOffset);
157 if (!this->applyCropRect(&bounds, ctm)) { 159 if (!this->applyCropRect(&bounds, ctm)) {
158 return false; 160 return false;
159 } 161 }
160 SkRect srcRect = SkRect::Make(bounds); 162 SkRect srcRect = SkRect::Make(bounds);
161 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); 163 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
162 GrContext* context = srcTexture->getContext(); 164 GrContext* context = srcTexture->getContext();
163 165
164 GrTextureDesc desc; 166 GrTextureDesc desc;
165 desc.fFlags = kRenderTarget_GrTextureFlagBit, 167 desc.fFlags = kRenderTarget_GrTextureFlagBit,
166 desc.fWidth = bounds.width(); 168 desc.fWidth = bounds.width();
167 desc.fHeight = bounds.height(); 169 desc.fHeight = bounds.height();
168 desc.fConfig = kRGBA_8888_GrPixelConfig; 170 desc.fConfig = kRGBA_8888_GrPixelConfig;
169 171
170 GrAutoScratchTexture dst(context, desc); 172 GrAutoScratchTexture dst(context, desc);
171 GrContext::AutoMatrix am; 173 GrContext::AutoMatrix am;
172 am.setIdentity(context); 174 am.setIdentity(context);
173 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget()); 175 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
174 GrContext::AutoClip acs(context, dstRect); 176 GrContext::AutoClip acs(context, dstRect);
175 GrEffectRef* effect; 177 GrEffectRef* effect;
178 offset->fX = bounds.left();
179 offset->fY = bounds.top();
180 bounds.offset(-srcOffset);
176 SkMatrix matrix(ctm); 181 SkMatrix matrix(ctm);
177 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); 182 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p()));
178 this->asNewEffect(&effect, srcTexture, matrix, bounds); 183 this->asNewEffect(&effect, srcTexture, matrix, bounds);
179 SkASSERT(effect); 184 SkASSERT(effect);
180 SkAutoUnref effectRef(effect); 185 SkAutoUnref effectRef(effect);
181 GrPaint paint; 186 GrPaint paint;
182 paint.addColorEffect(effect); 187 paint.addColorEffect(effect);
183 context->drawRectToRect(paint, dstRect, srcRect); 188 context->drawRectToRect(paint, dstRect, srcRect);
184 189
185 SkAutoTUnref<GrTexture> resultTex(dst.detach()); 190 SkAutoTUnref<GrTexture> resultTex(dst.detach());
186 SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(), result); 191 SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(), result);
187 offset->fX += bounds.left();
188 offset->fY += bounds.top();
189 return true; 192 return true;
190 #else 193 #else
191 return false; 194 return false;
192 #endif 195 #endif
193 } 196 }
194 197
195 bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const { 198 bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
196 SkRect cropRect; 199 SkRect cropRect;
197 matrix.mapRect(&cropRect, fCropRect.rect()); 200 matrix.mapRect(&cropRect, fCropRect.rect());
198 SkIRect cropRectI; 201 SkIRect cropRectI;
(...skipping 13 matching lines...) Expand all
212 return true; 215 return true;
213 } 216 }
214 217
215 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons t SkIRect&) const { 218 bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&, cons t SkIRect&) const {
216 return false; 219 return false;
217 } 220 }
218 221
219 bool SkImageFilter::asColorFilter(SkColorFilter**) const { 222 bool SkImageFilter::asColorFilter(SkColorFilter**) const {
220 return false; 223 return false;
221 } 224 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698