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

Side by Side Diff: src/gpu/SkGpuDevice.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 2011 Google Inc. 2 * Copyright 2011 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 "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 fOpaque = SkToBool(flags & kIsOpaque_Flag); 189 fOpaque = SkToBool(flags & kIsOpaque_Flag);
190 190
191 fRenderTarget = SkRef(rt); 191 fRenderTarget = SkRef(rt);
192 192
193 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 193 SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
194 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height); 194 SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
195 SkPixelRef* pr = new SkGrPixelRef(info, rt); 195 SkPixelRef* pr = new SkGrPixelRef(info, rt);
196 fLegacyBitmap.setInfo(info); 196 fLegacyBitmap.setInfo(info);
197 fLegacyBitmap.setPixelRef(pr)->unref(); 197 fLegacyBitmap.setPixelRef(pr)->unref();
198 198
199 fDrawContext.reset(SkRef(fContext->drawContext(&this->surfaceProps()))); 199 fDrawContext.reset(fContext->drawContext(&this->surfaceProps()));
200 } 200 }
201 201
202 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted, 202 GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B udgeted budgeted,
203 const SkImageInfo& origInfo, int sampleCount) { 203 const SkImageInfo& origInfo, int sampleCount) {
204 if (kUnknown_SkColorType == origInfo.colorType() || 204 if (kUnknown_SkColorType == origInfo.colorType() ||
205 origInfo.width() < 0 || origInfo.height() < 0) { 205 origInfo.width() < 0 || origInfo.height() < 0) {
206 return nullptr; 206 return nullptr;
207 } 207 }
208 208
209 if (!context) { 209 if (!context) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 fRenderTarget = newRT.detach(); 366 fRenderTarget = newRT.detach();
367 367
368 #ifdef SK_DEBUG 368 #ifdef SK_DEBUG
369 SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlp haType : 369 SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlp haType :
370 kPremul_SkAlp haType); 370 kPremul_SkAlp haType);
371 SkASSERT(info == fLegacyBitmap.info()); 371 SkASSERT(info == fLegacyBitmap.info());
372 #endif 372 #endif
373 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget); 373 SkPixelRef* pr = new SkGrPixelRef(fLegacyBitmap.info(), fRenderTarget);
374 fLegacyBitmap.setPixelRef(pr)->unref(); 374 fLegacyBitmap.setPixelRef(pr)->unref();
375 375
376 fDrawContext.reset(SkRef(fRenderTarget->getContext()->drawContext(&this->sur faceProps()))); 376 fDrawContext.reset(fRenderTarget->getContext()->drawContext(&this->surfacePr ops()));
377 } 377 }
378 378
379 /////////////////////////////////////////////////////////////////////////////// 379 ///////////////////////////////////////////////////////////////////////////////
380 380
381 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { 381 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
382 CHECK_SHOULD_DRAW(draw); 382 CHECK_SHOULD_DRAW(draw);
383 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext); 383 GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
384 384
385 GrPaint grPaint; 385 GrPaint grPaint;
386 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t rue, &grPaint)) { 386 if (!SkPaint2GrPaint(this->context(), fRenderTarget, paint, *draw.fMatrix, t rue, &grPaint)) {
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 #endif 1900 #endif
1901 } 1901 }
1902 1902
1903 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1903 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1904 // We always return a transient cache, so it is freed after each 1904 // We always return a transient cache, so it is freed after each
1905 // filter traversal. 1905 // filter traversal.
1906 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1906 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1907 } 1907 }
1908 1908
1909 #endif 1909 #endif
OLDNEW
« src/gpu/GrRenderTarget.cpp ('K') | « src/gpu/GrRenderTarget.cpp ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698