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

Side by Side Diff: src/gpu/SkGr.cpp

Issue 638403003: Remove uses of GrAutoScratchTexture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment change 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 "SkGr.h" 8 #include "SkGr.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkConfig8888.h" 10 #include "SkConfig8888.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 result = ctx->createTexture(params, desc, cacheID, pixels, rowBytes, &ke y); 152 result = ctx->createTexture(params, desc, cacheID, pixels, rowBytes, &ke y);
153 if (result) { 153 if (result) {
154 add_genID_listener(key, bm.pixelRef()); 154 add_genID_listener(key, bm.pixelRef());
155 } 155 }
156 } else { 156 } else {
157 // This texture is unlikely to be used again (in its present form) so 157 // This texture is unlikely to be used again (in its present form) so
158 // just use a scratch texture. This will remove the texture from the 158 // just use a scratch texture. This will remove the texture from the
159 // cache so no one else can find it. Additionally, once unlocked, the 159 // cache so no one else can find it. Additionally, once unlocked, the
160 // scratch texture will go to the end of the list for purging so will 160 // scratch texture will go to the end of the list for purging so will
161 // likely be available for this volatile bitmap the next time around. 161 // likely be available for this volatile bitmap the next time around.
162 result = ctx->lockAndRefScratchTexture(desc, GrContext::kExact_ScratchTe xMatch); 162 result = ctx->refScratchTexture(desc, GrContext::kExact_ScratchTexMatch) ;
163 if (pixels) { 163 if (pixels) {
164 result->writePixels(0, 0, bm.width(), bm.height(), desc.fConfig, pix els, rowBytes); 164 result->writePixels(0, 0, bm.width(), bm.height(), desc.fConfig, pix els, rowBytes);
165 } 165 }
166 } 166 }
167 return result; 167 return result;
168 } 168 }
169 169
170 #ifndef SK_IGNORE_ETC1_SUPPORT 170 #ifndef SK_IGNORE_ETC1_SUPPORT
171 static GrTexture *load_etc1_texture(GrContext* ctx, bool cache, 171 static GrTexture *load_etc1_texture(GrContext* ctx, bool cache,
172 const GrTextureParams* params, 172 const GrTextureParams* params,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 SkYUVColorSpace colorSpace; 242 SkYUVColorSpace colorSpace;
243 243
244 // Get the YUV planes 244 // Get the YUV planes
245 if (!pixelRef->getYUV8Planes(yuvSizes, planes, rowBytes, &colorSpace)) { 245 if (!pixelRef->getYUV8Planes(yuvSizes, planes, rowBytes, &colorSpace)) {
246 return NULL; 246 return NULL;
247 } 247 }
248 248
249 GrTextureDesc yuvDesc; 249 GrTextureDesc yuvDesc;
250 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; 250 yuvDesc.fConfig = kAlpha_8_GrPixelConfig;
251 GrAutoScratchTexture yuvTextures[3]; 251 SkAutoTUnref<GrTexture> yuvTextures[3];
252 for (int i = 0; i < 3; ++i) { 252 for (int i = 0; i < 3; ++i) {
253 yuvDesc.fWidth = yuvSizes[i].fWidth; 253 yuvDesc.fWidth = yuvSizes[i].fWidth;
254 yuvDesc.fHeight = yuvSizes[i].fHeight; 254 yuvDesc.fHeight = yuvSizes[i].fHeight;
255 yuvTextures[i].set(ctx, yuvDesc); 255 yuvTextures[i].reset(
256 if ((NULL == yuvTextures[i].texture()) || 256 ctx->refScratchTexture(yuvDesc, GrContext::kApprox_ScratchTexMatch)) ;
257 !ctx->writeTexturePixels(yuvTextures[i].texture(), 257 if (!yuvTextures[i] ||
258 0, 0, yuvDesc.fWidth, yuvDesc.fHeight, 258 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
259 yuvDesc.fConfig, planes[i], rowBytes[i])) { 259 yuvDesc.fConfig, planes[i], rowBytes[i] )) {
260 return NULL; 260 return NULL;
261 } 261 }
262 } 262 }
263 263
264 GrTextureDesc rtDesc = desc; 264 GrTextureDesc rtDesc = desc;
265 rtDesc.fFlags = rtDesc.fFlags | 265 rtDesc.fFlags = rtDesc.fFlags |
266 kRenderTarget_GrTextureFlagBit | 266 kRenderTarget_GrTextureFlagBit |
267 kNoStencil_GrTextureFlagBit; 267 kNoStencil_GrTextureFlagBit;
268 268
269 GrTexture* result = sk_gr_allocate_texture(ctx, cache, params, bm, rtDesc, N ULL, 0); 269 GrTexture* result = sk_gr_allocate_texture(ctx, cache, params, bm, rtDesc, N ULL, 0);
270 270
271 GrRenderTarget* renderTarget = result ? result->asRenderTarget() : NULL; 271 GrRenderTarget* renderTarget = result ? result->asRenderTarget() : NULL;
272 if (renderTarget) { 272 if (renderTarget) {
273 SkAutoTUnref<GrFragmentProcessor> yuvToRgbProcessor(GrYUVtoRGBEffect::Cr eate( 273 SkAutoTUnref<GrFragmentProcessor> yuvToRgbProcessor(GrYUVtoRGBEffect::Cr eate(
274 yuvTextures[0].texture(), yuvTextures[1].texture(), yuvTextures[2].t exture(), 274 yuvTextures[0], yuvTextures[1], yuvTextures[2],
275 colorSpace)); 275 colorSpace));
276 GrPaint paint; 276 GrPaint paint;
277 paint.addColorProcessor(yuvToRgbProcessor); 277 paint.addColorProcessor(yuvToRgbProcessor);
278 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvSizes[0].fWidth), 278 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvSizes[0].fWidth),
279 SkIntToScalar(yuvSizes[0].fHeight)); 279 SkIntToScalar(yuvSizes[0].fHeight));
280 GrContext::AutoRenderTarget autoRT(ctx, renderTarget); 280 GrContext::AutoRenderTarget autoRT(ctx, renderTarget);
281 GrContext::AutoMatrix am; 281 GrContext::AutoMatrix am;
282 am.setIdentity(ctx); 282 am.setIdentity(ctx);
283 GrContext::AutoClip ac(ctx, GrContext::AutoClip::kWideOpen_InitialClip); 283 GrContext::AutoClip ac(ctx, GrContext::AutoClip::kWideOpen_InitialClip);
284 ctx->drawRect(paint, r); 284 ctx->drawRect(paint, r);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { 570 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) {
571 grPaint->addColorProcessor(fp)->unref(); 571 grPaint->addColorProcessor(fp)->unref();
572 constantColor = false; 572 constantColor = false;
573 } 573 }
574 } 574 }
575 575
576 // The grcolor is automatically set when calling asFragmentProcessor. 576 // The grcolor is automatically set when calling asFragmentProcessor.
577 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. 577 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint.
578 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); 578 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint );
579 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698