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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1321353002: Limit lifetime of GrDrawContext objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 5 years, 3 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 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkImage_Gpu.h" 9 #include "SkImage_Gpu.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 GrPaint paint; 249 GrPaint paint;
250 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 250 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
251 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorD ataManager(), 251 paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorD ataManager(),
252 yTex, uTex, vTex, y uvSizes, 252 yTex, uTex, vTex, y uvSizes,
253 colorSpace))->unref (); 253 colorSpace))->unref ();
254 254
255 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), 255 const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
256 SkIntToScalar(dstDesc.fHeight)); 256 SkIntToScalar(dstDesc.fHeight));
257 GrDrawContext* drawContext = ctx->drawContext(); 257 SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext());
258 if (!drawContext) {
259 return nullptr;
260 }
261
258 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa trix::I(), rect); 262 drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMa trix::I(), rect);
259 ctx->flushSurfaceWrites(dst); 263 ctx->flushSurfaceWrites(dst);
260 return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueI D, 264 return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueI D,
261 kOpaque_SkAlphaType, dst, 0, budgeted); 265 kOpaque_SkAlphaType, dst, 0, budgeted);
262 } 266 }
263 267
264 //////////////////////////////////////////////////////////////////////////////// /////////////////// 268 //////////////////////////////////////////////////////////////////////////////// ///////////////////
265 269
266 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { 270 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) {
267 GrContext* ctx = src->getContext(); 271 GrContext* ctx = src->getContext();
268 272
269 GrSurfaceDesc desc = src->desc(); 273 GrSurfaceDesc desc = src->desc();
270 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0); 274 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0);
271 if (!dst) { 275 if (!dst) {
272 return nullptr; 276 return nullptr;
273 } 277 }
274 278
275 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 279 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
276 const SkIPoint dstP = SkIPoint::Make(0, 0); 280 const SkIPoint dstP = SkIPoint::Make(0, 0);
277 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 281 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
278 return dst; 282 return dst;
279 } 283 }
280 284
OLDNEW
« src/gpu/GrRenderTarget.cpp ('K') | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698