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

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

Issue 15995026: Image filters: implement offsets in GPU path. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Wrap lines at 100 chars. Created 7 years, 5 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/SkBlendImageFilter.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"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 sumR += SkGetPackedR32(r); 112 sumR += SkGetPackedR32(r);
113 sumG += SkGetPackedG32(r); 113 sumG += SkGetPackedG32(r);
114 sumB += SkGetPackedB32(r); 114 sumB += SkGetPackedB32(r);
115 } 115 }
116 sptr += srcStride; 116 sptr += srcStride;
117 dptr += dstStride; 117 dptr += dstStride;
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo wOffset, int *highOffset) 122 static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo wOffset,
123 int *highOffset)
123 { 124 {
124 float pi = SkScalarToFloat(SK_ScalarPI); 125 float pi = SkScalarToFloat(SK_ScalarPI);
125 int d = static_cast<int>(floorf(SkScalarToFloat(s) * 3.0f * sqrtf(2.0f * pi) / 4.0f + 0.5f)); 126 int d = static_cast<int>(floorf(SkScalarToFloat(s) * 3.0f * sqrtf(2.0f * pi) / 4.0f + 0.5f));
126 *kernelSize = d; 127 *kernelSize = d;
127 if (d % 2 == 1) { 128 if (d % 2 == 1) {
128 *lowOffset = *highOffset = (d - 1) / 2; 129 *lowOffset = *highOffset = (d - 1) / 2;
129 *kernelSize3 = d; 130 *kernelSize3 = d;
130 } else { 131 } else {
131 *highOffset = d / 2; 132 *highOffset = d / 2;
132 *lowOffset = *highOffset - 1; 133 *lowOffset = *highOffset - 1;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 boxBlurX(*dst, &temp, kernelSizeX, highOffsetX, lowOffsetX); 186 boxBlurX(*dst, &temp, kernelSizeX, highOffsetX, lowOffsetX);
186 boxBlurX(temp, dst, kernelSizeX3, highOffsetX, highOffsetX); 187 boxBlurX(temp, dst, kernelSizeX3, highOffsetX, highOffsetX);
187 } else if (kernelSizeY > 0) { 188 } else if (kernelSizeY > 0) {
188 boxBlurY(src, dst, kernelSizeY, lowOffsetY, highOffsetY); 189 boxBlurY(src, dst, kernelSizeY, lowOffsetY, highOffsetY);
189 boxBlurY(*dst, &temp, kernelSizeY, highOffsetY, lowOffsetY); 190 boxBlurY(*dst, &temp, kernelSizeY, highOffsetY, lowOffsetY);
190 boxBlurY(temp, dst, kernelSizeY3, highOffsetY, highOffsetY); 191 boxBlurY(temp, dst, kernelSizeY3, highOffsetY, highOffsetY);
191 } 192 }
192 return true; 193 return true;
193 } 194 }
194 195
195 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitm ap* result) { 196 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitm ap* result,
197 SkIPoint* offset) {
196 #if SK_SUPPORT_GPU 198 #if SK_SUPPORT_GPU
197 SkBitmap input; 199 SkBitmap input;
198 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &input)) { 200 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, &input, offset)) {
199 return false; 201 return false;
200 } 202 }
201 GrTexture* source = input.getTexture(); 203 GrTexture* source = input.getTexture();
202 SkRect rect; 204 SkRect rect;
203 src.getBounds(&rect); 205 src.getBounds(&rect);
204 SkAutoTUnref<GrTexture> tex(source->getContext()->gaussianBlur(source, false , rect, 206 SkAutoTUnref<GrTexture> tex(source->getContext()->gaussianBlur(source, false , rect,
205 fSigma.width(), fSigma.height())); 207 fSigma.width(), fSigma.height()));
206 return SkImageFilterUtils::WrapTexture(tex, src.width(), src.height(), resul t); 208 return SkImageFilterUtils::WrapTexture(tex, src.width(), src.height(), resul t);
207 #else 209 #else
208 SkDEBUGFAIL("Should not call in GPU-less build"); 210 SkDEBUGFAIL("Should not call in GPU-less build");
209 return false; 211 return false;
210 #endif 212 #endif
211 } 213 }
OLDNEW
« no previous file with comments | « src/effects/SkBlendImageFilter.cpp ('k') | src/effects/SkDisplacementMapEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698