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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 1569833004: Fix unref order in SkGpuDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 89273be9a3823e419fb19051c1c3ecafa02da799..cd678af880a723992c79cd12a1dabe05ce9da5de 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -10,7 +10,6 @@
#include "GrBlurUtils.h"
#include "GrContext.h"
#include "SkDraw.h"
-#include "GrDrawContext.h"
#include "GrGpu.h"
#include "GrGpuResourcePriv.h"
#include "GrImageIDTextureAdjuster.h"
@@ -171,13 +170,11 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, SkSurface::Budgeted budgete
SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
const SkSurfaceProps* props, unsigned flags)
: INHERITED(SkSurfacePropsCopyOrDefault(props))
-{
- fContext = SkRef(rt->getContext());
+ , fContext(SkRef(rt->getContext()))
+ , fRenderTarget(SkRef(rt)) {
fNeedClear = SkToBool(flags & kNeedClear_Flag);
fOpaque = SkToBool(flags & kIsOpaque_Flag);
- fRenderTarget = SkRef(rt);
-
SkAlphaType at = fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = rt->surfacePriv().info(at).makeWH(width, height);
SkPixelRef* pr = new SkGrPixelRef(info, rt);
@@ -226,11 +223,6 @@ GrRenderTarget* SkGpuDevice::CreateRenderTarget(GrContext* context, SkSurface::B
return texture->asRenderTarget();
}
-SkGpuDevice::~SkGpuDevice() {
- fRenderTarget->unref();
- fContext->unref();
-}
-
///////////////////////////////////////////////////////////////////////////////
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
@@ -346,8 +338,7 @@ void SkGpuDevice::replaceRenderTarget(bool shouldRetainContent) {
SkASSERT(fRenderTarget != newRT);
- fRenderTarget->unref();
- fRenderTarget = newRT.detach();
+ fRenderTarget.reset(newRT.detach());
#ifdef SK_DEBUG
SkImageInfo info = fRenderTarget->surfacePriv().info(fOpaque ? kOpaque_SkAlphaType :
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698