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

Side by Side Diff: src/effects/SkBlurImageFilter.cpp

Issue 185973003: Cleanup patch to move all of SkImageFilterUtils into SkImageFilter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Oh, the Rietveld suckage Created 6 years, 9 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 | « src/effects/SkBicubicImageFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.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 2011 The Android Open Source Project 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkReadBuffer.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
13 #include "SkGpuBlurUtils.h" 13 #include "SkGpuBlurUtils.h"
14 #include "SkBlurImage_opts.h" 14 #include "SkBlurImage_opts.h"
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #include "SkImageFilterUtils.h"
18 #endif 17 #endif
19 18
20 SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer) 19 SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
21 : INHERITED(1, buffer) { 20 : INHERITED(1, buffer) {
22 fSigma.fWidth = buffer.readScalar(); 21 fSigma.fWidth = buffer.readScalar();
23 fSigma.fHeight = buffer.readScalar(); 22 fSigma.fHeight = buffer.readScalar();
24 buffer.validate(SkScalarIsFinite(fSigma.fWidth) && 23 buffer.validate(SkScalarIsFinite(fSigma.fWidth) &&
25 SkScalarIsFinite(fSigma.fHeight) && 24 SkScalarIsFinite(fSigma.fHeight) &&
26 (fSigma.fWidth >= 0) && 25 (fSigma.fWidth >= 0) &&
27 (fSigma.fHeight >= 0)); 26 (fSigma.fHeight >= 0));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ctm.mapVectors(&sigma, &localSigma, 1); 246 ctm.mapVectors(&sigma, &localSigma, 1);
248 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), 247 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
249 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); 248 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
250 *dst = bounds; 249 *dst = bounds;
251 return true; 250 return true;
252 } 251 }
253 252
254 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, 253 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
255 SkBitmap* result, SkIPoint* offset) const { 254 SkBitmap* result, SkIPoint* offset) const {
256 #if SK_SUPPORT_GPU 255 #if SK_SUPPORT_GPU
257 SkBitmap input; 256 SkBitmap input = src;
258 SkIPoint srcOffset = SkIPoint::Make(0, 0); 257 SkIPoint srcOffset = SkIPoint::Make(0, 0);
259 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &in put, &srcOffset)) { 258 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &input, &srcOffset)) {
260 return false; 259 return false;
261 } 260 }
262 GrTexture* source = input.getTexture(); 261 GrTexture* source = input.getTexture();
263 SkIRect rect; 262 SkIRect rect;
264 src.getBounds(&rect); 263 src.getBounds(&rect);
265 rect.offset(srcOffset); 264 rect.offset(srcOffset);
266 if (!this->applyCropRect(&rect, ctm)) { 265 if (!this->applyCropRect(&rect, ctm)) {
267 return false; 266 return false;
268 } 267 }
269 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height()) ; 268 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height()) ;
270 ctm.mapVectors(&sigma, &localSigma, 1); 269 ctm.mapVectors(&sigma, &localSigma, 1);
271 offset->fX = rect.fLeft; 270 offset->fX = rect.fLeft;
272 offset->fY = rect.fTop; 271 offset->fY = rect.fTop;
273 rect.offset(-srcOffset); 272 rect.offset(-srcOffset);
274 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext( ), 273 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext( ),
275 source, 274 source,
276 false, 275 false,
277 SkRect::Make(rect), 276 SkRect::Make(rect),
278 true, 277 true,
279 sigma.x(), 278 sigma.x(),
280 sigma.y())); 279 sigma.y()));
281 return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), res ult); 280 WrapTexture(tex, rect.width(), rect.height(), result);
281 return true;
282 #else 282 #else
283 SkDEBUGFAIL("Should not call in GPU-less build"); 283 SkDEBUGFAIL("Should not call in GPU-less build");
284 return false; 284 return false;
285 #endif 285 #endif
286 } 286 }
OLDNEW
« no previous file with comments | « src/effects/SkBicubicImageFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698