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

Side by Side Diff: src/gpu/gl/GrGLTexture.cpp

Issue 19580003: Fix leak of GrGLTexID when its owning GrGLTexture has been abandoned. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix Created 7 years, 5 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 | Annotate | Revision Log
« src/gpu/gl/GrGLRenderTarget.h ('K') | « src/gpu/gl/GrGLTexture.h ('k') | no next file » | 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 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 "GrGLTexture.h" 8 #include "GrGLTexture.h"
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 10
11 SK_DEFINE_INST_COUNT(GrGLTexID) 11 SK_DEFINE_INST_COUNT(GrGLTexID)
12 12
13 #define GPUGL static_cast<GrGpuGL*>(getGpu()) 13 #define GPUGL static_cast<GrGpuGL*>(getGpu())
14 14
15 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) 15 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
16 16
17 void GrGLTexture::init(GrGpuGL* gpu, 17 void GrGLTexture::init(GrGpuGL* gpu,
18 const Desc& textureDesc, 18 const Desc& textureDesc,
19 const GrGLRenderTarget::Desc* rtDesc) { 19 const GrGLRenderTarget::Desc* rtDesc) {
20 20
21 GrAssert(0 != textureDesc.fTextureID); 21 GrAssert(0 != textureDesc.fTextureID);
22 22
23 fTexParams.invalidate(); 23 fTexParams.invalidate();
24 fTexParamsTimestamp = GrGpu::kExpiredTimestamp; 24 fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
25 fTexIDObj = SkNEW_ARGS(GrGLTexID, 25 fTexIDObj.reset(SkNEW_ARGS(GrGLTexID, (GPUGL->glInterface(),
26 (GPUGL->glInterface(), 26 textureDesc.fTextureID,
27 textureDesc.fTextureID, 27 textureDesc.fIsWrapped)));
28 textureDesc.fIsWrapped));
29 28
30 if (NULL != rtDesc) { 29 if (NULL != rtDesc) {
31 GrGLIRect vp; 30 GrGLIRect vp;
32 vp.fLeft = 0; 31 vp.fLeft = 0;
33 vp.fWidth = textureDesc.fWidth; 32 vp.fWidth = textureDesc.fWidth;
34 vp.fBottom = 0; 33 vp.fBottom = 0;
35 vp.fHeight = textureDesc.fHeight; 34 vp.fHeight = textureDesc.fHeight;
36 35
37 fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTex IDObj, this))); 36 fRenderTarget.reset(SkNEW_ARGS(GrGLRenderTarget, (gpu, *rtDesc, vp, fTex IDObj, this)));
38 } 37 }
39 } 38 }
40 39
41 GrGLTexture::GrGLTexture(GrGpuGL* gpu, 40 GrGLTexture::GrGLTexture(GrGpuGL* gpu,
42 const Desc& textureDesc) 41 const Desc& textureDesc)
43 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { 42 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) {
44 this->init(gpu, textureDesc, NULL); 43 this->init(gpu, textureDesc, NULL);
45 } 44 }
46 45
47 GrGLTexture::GrGLTexture(GrGpuGL* gpu, 46 GrGLTexture::GrGLTexture(GrGpuGL* gpu,
48 const Desc& textureDesc, 47 const Desc& textureDesc,
49 const GrGLRenderTarget::Desc& rtDesc) 48 const GrGLRenderTarget::Desc& rtDesc)
50 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) { 49 : INHERITED(gpu, textureDesc.fIsWrapped, textureDesc) {
51 this->init(gpu, textureDesc, &rtDesc); 50 this->init(gpu, textureDesc, &rtDesc);
52 } 51 }
53 52
54 void GrGLTexture::onRelease() { 53 void GrGLTexture::onRelease() {
55 GPUGL->notifyTextureDelete(this); 54 GPUGL->notifyTextureDelete(this);
56 if (NULL != fTexIDObj) { 55 fTexIDObj.reset(NULL);
57 fTexIDObj->unref();
58 fTexIDObj = NULL;
59 }
60
61 INHERITED::onRelease(); 56 INHERITED::onRelease();
62 } 57 }
63 58
64 void GrGLTexture::onAbandon() { 59 void GrGLTexture::onAbandon() {
65 if (NULL != fTexIDObj) { 60 if (NULL != fTexIDObj.get()) {
66 fTexIDObj->abandon(); 61 fTexIDObj->abandon();
62 fTexIDObj.reset(NULL);
67 } 63 }
68 64
69 INHERITED::onAbandon(); 65 INHERITED::onAbandon();
70 } 66 }
71 67
72 GrBackendObject GrGLTexture::getTextureHandle() const { 68 GrBackendObject GrGLTexture::getTextureHandle() const {
73 return fTexIDObj->id(); 69 return static_cast<GrBackendObject>(this->textureID());
74 } 70 }
OLDNEW
« src/gpu/gl/GrGLRenderTarget.h ('K') | « src/gpu/gl/GrGLTexture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698