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

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

Issue 638403003: Remove uses of GrAutoScratchTexture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 2 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
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkMorphologyImageFilter.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 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkGpuBlurUtils.h" 8 #include "SkGpuBlurUtils.h"
9 9
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() || 171 SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() ||
172 kRGBA_8888_GrPixelConfig == srcTexture->config() || 172 kRGBA_8888_GrPixelConfig == srcTexture->config() ||
173 kAlpha_8_GrPixelConfig == srcTexture->config()); 173 kAlpha_8_GrPixelConfig == srcTexture->config());
174 174
175 GrTextureDesc desc; 175 GrTextureDesc desc;
176 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 176 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
177 desc.fWidth = SkScalarFloorToInt(srcRect.width()); 177 desc.fWidth = SkScalarFloorToInt(srcRect.width());
178 desc.fHeight = SkScalarFloorToInt(srcRect.height()); 178 desc.fHeight = SkScalarFloorToInt(srcRect.height());
179 desc.fConfig = srcTexture->config(); 179 desc.fConfig = srcTexture->config();
180 180
181 GrAutoScratchTexture temp1, temp2; 181 GrTexture* dstTexture;
182 GrTexture* dstTexture = temp1.set(context, desc); 182 GrTexture* tempTexture;
183 GrTexture* tempTexture = canClobberSrc ? srcTexture : temp2.set(context, des c); 183 SkAutoTUnref<GrTexture> temp1, temp2;
184
185 temp1.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMa tch));
186 dstTexture = temp1.get();
187 if (canClobberSrc) {
188 tempTexture = srcTexture;
189 } else {
190 temp2.reset(context->refScratchTexture(desc, GrContext::kApprox_ScratchT exMatch));
191 tempTexture = temp2.get();
192 }
193
184 if (NULL == dstTexture || NULL == tempTexture) { 194 if (NULL == dstTexture || NULL == tempTexture) {
185 return NULL; 195 return NULL;
186 } 196 }
187 197
188 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { 198 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
189 GrPaint paint; 199 GrPaint paint;
190 SkMatrix matrix; 200 SkMatrix matrix;
191 matrix.setIDiv(srcTexture->width(), srcTexture->height()); 201 matrix.setIDiv(srcTexture->width(), srcTexture->height());
192 context->setRenderTarget(dstTexture->asRenderTarget()); 202 context->setRenderTarget(dstTexture->asRenderTarget());
193 SkRect dstRect(srcRect); 203 SkRect dstRect(srcRect);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode); 298 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode);
289 paint.addColorTextureProcessor(srcTexture, matrix, params); 299 paint.addColorTextureProcessor(srcTexture, matrix, params);
290 300
291 SkRect dstRect(srcRect); 301 SkRect dstRect(srcRect);
292 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); 302 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
293 context->drawRectToRect(paint, dstRect, srcRect); 303 context->drawRectToRect(paint, dstRect, srcRect);
294 srcRect = dstRect; 304 srcRect = dstRect;
295 srcTexture = dstTexture; 305 srcTexture = dstTexture;
296 SkTSwap(dstTexture, tempTexture); 306 SkTSwap(dstTexture, tempTexture);
297 } 307 }
298 if (srcTexture == temp1.texture()) { 308 return SkRef(srcTexture);
299 return temp1.detach();
300 } else if (srcTexture == temp2.texture()) {
301 return temp2.detach();
302 } else {
303 srcTexture->ref();
304 return srcTexture;
305 }
306 } 309 }
307 #endif 310 #endif
308 311
309 } 312 }
OLDNEW
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698