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

Side by Side Diff: src/effects/SkBicubicImageFilter.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/SkArithmeticMode.cpp ('k') | 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 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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.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 "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkRect.h" 14 #include "SkRect.h"
15 #include "SkUnPreMultiply.h" 15 #include "SkUnPreMultiply.h"
16 16
17 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
18 #include "effects/GrBicubicEffect.h" 18 #include "effects/GrBicubicEffect.h"
19 #include "GrContext.h" 19 #include "GrContext.h"
20 #include "GrTexture.h" 20 #include "GrTexture.h"
21 #include "SkImageFilterUtils.h"
22 #endif 21 #endif
23 22
24 #define DS(x) SkDoubleToScalar(x) 23 #define DS(x) SkDoubleToScalar(x)
25 24
26 static const SkScalar gMitchellCoefficients[16] = { 25 static const SkScalar gMitchellCoefficients[16] = {
27 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), 26 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0),
28 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), 27 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0),
29 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), 28 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0),
30 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), 29 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0),
31 }; 30 };
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 offset->fY = dstIRect.fTop; 163 offset->fY = dstIRect.fTop;
165 return true; 164 return true;
166 } 165 }
167 166
168 /////////////////////////////////////////////////////////////////////////////// 167 ///////////////////////////////////////////////////////////////////////////////
169 168
170 #if SK_SUPPORT_GPU 169 #if SK_SUPPORT_GPU
171 170
172 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, con st SkMatrix& ctm, 171 bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, con st SkMatrix& ctm,
173 SkBitmap* result, SkIPoint* offset) co nst { 172 SkBitmap* result, SkIPoint* offset) co nst {
174 SkBitmap srcBM; 173 SkBitmap srcBM = src;
175 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &sr cBM, offset)) { 174 if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctm, &srcBM, offset)) {
176 return false; 175 return false;
177 } 176 }
178 GrTexture* srcTexture = srcBM.getTexture(); 177 GrTexture* srcTexture = srcBM.getTexture();
179 GrContext* context = srcTexture->getContext(); 178 GrContext* context = srcTexture->getContext();
180 179
181 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth, 180 SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth,
182 srcBM.height() * fScale.fHeight); 181 srcBM.height() * fScale.fHeight);
183 182
184 GrTextureDesc desc; 183 GrTextureDesc desc;
185 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 184 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
186 desc.fWidth = SkScalarCeilToInt(dstRect.width()); 185 desc.fWidth = SkScalarCeilToInt(dstRect.width());
187 desc.fHeight = SkScalarCeilToInt(dstRect.height()); 186 desc.fHeight = SkScalarCeilToInt(dstRect.height());
188 desc.fConfig = kSkia8888_GrPixelConfig; 187 desc.fConfig = kSkia8888_GrPixelConfig;
189 188
190 GrAutoScratchTexture ast(context, desc); 189 GrAutoScratchTexture ast(context, desc);
191 SkAutoTUnref<GrTexture> dst(ast.detach()); 190 SkAutoTUnref<GrTexture> dst(ast.detach());
192 if (!dst) { 191 if (!dst) {
193 return false; 192 return false;
194 } 193 }
195 GrContext::AutoRenderTarget art(context, dst->asRenderTarget()); 194 GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
196 GrPaint paint; 195 GrPaint paint;
197 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref(); 196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref();
198 SkRect srcRect; 197 SkRect srcRect;
199 srcBM.getBounds(&srcRect); 198 srcBM.getBounds(&srcRect);
200 context->drawRectToRect(paint, dstRect, srcRect); 199 context->drawRectToRect(paint, dstRect, srcRect);
201 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t); 200 WrapTexture(dst, desc.fWidth, desc.fHeight, result);
201 return true;
202 } 202 }
203 #endif 203 #endif
204 204
205 /////////////////////////////////////////////////////////////////////////////// 205 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698