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

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

Issue 791493003: Skia: Track the fIsWrapped separately so that we delete correctly (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Comments + GlGRTexture Created 6 years 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
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | 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 "GrGLRenderTarget.h" 8 #include "GrGLRenderTarget.h"
9 9
10 #include "GrGpuGL.h" 10 #include "GrGpuGL.h"
(...skipping 13 matching lines...) Expand all
24 Derived) 24 Derived)
25 : GrSurface(gpu, idDesc.fIsWrapped, desc) 25 : GrSurface(gpu, idDesc.fIsWrapped, desc)
26 , INHERITED(gpu, idDesc.fIsWrapped, desc) { 26 , INHERITED(gpu, idDesc.fIsWrapped, desc) {
27 this->init(desc, idDesc); 27 this->init(desc, idDesc);
28 } 28 }
29 29
30 void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { 30 void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
31 fRTFBOID = idDesc.fRTFBOID; 31 fRTFBOID = idDesc.fRTFBOID;
32 fTexFBOID = idDesc.fTexFBOID; 32 fTexFBOID = idDesc.fTexFBOID;
33 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; 33 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
34 fIsWrapped = idDesc.fIsWrapped;
34 35
35 fViewport.fLeft = 0; 36 fViewport.fLeft = 0;
36 fViewport.fBottom = 0; 37 fViewport.fBottom = 0;
37 fViewport.fWidth = desc.fWidth; 38 fViewport.fWidth = desc.fWidth;
38 fViewport.fHeight = desc.fHeight; 39 fViewport.fHeight = desc.fHeight;
39 40
40 // We own one color value for each MSAA sample. 41 // We own one color value for each MSAA sample.
41 fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt); 42 fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt);
42 if (fTexFBOID != fRTFBOID) { 43 if (fTexFBOID != fRTFBOID) {
43 // If we own the resolve buffer then that is one more sample per pixel. 44 // If we own the resolve buffer then that is one more sample per pixel.
44 fColorValuesPerPixel += 1; 45 fColorValuesPerPixel += 1;
45 } 46 }
46 } 47 }
47 48
48 size_t GrGLRenderTarget::onGpuMemorySize() const { 49 size_t GrGLRenderTarget::onGpuMemorySize() const {
49 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig); 50 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig);
50 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig)); 51 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig));
51 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig); 52 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig);
52 SkASSERT(colorBytes > 0); 53 SkASSERT(colorBytes > 0);
53 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; 54 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes;
54 } 55 }
55 56
56 void GrGLRenderTarget::onRelease() { 57 void GrGLRenderTarget::onRelease() {
57 if (!this->isWrapped()) { 58 if (!fIsWrapped) {
58 if (fTexFBOID) { 59 if (fTexFBOID) {
59 GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); 60 GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
60 } 61 }
61 if (fRTFBOID && fRTFBOID != fTexFBOID) { 62 if (fRTFBOID && fRTFBOID != fTexFBOID) {
62 GL_CALL(DeleteFramebuffers(1, &fRTFBOID)); 63 GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
63 } 64 }
64 if (fMSColorRenderbufferID) { 65 if (fMSColorRenderbufferID) {
65 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID)); 66 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
66 } 67 }
67 } 68 }
68 fRTFBOID = 0; 69 fRTFBOID = 0;
69 fTexFBOID = 0; 70 fTexFBOID = 0;
70 fMSColorRenderbufferID = 0; 71 fMSColorRenderbufferID = 0;
72 fIsWrapped = false;
71 INHERITED::onRelease(); 73 INHERITED::onRelease();
72 } 74 }
73 75
74 void GrGLRenderTarget::onAbandon() { 76 void GrGLRenderTarget::onAbandon() {
75 fRTFBOID = 0; 77 fRTFBOID = 0;
76 fTexFBOID = 0; 78 fTexFBOID = 0;
77 fMSColorRenderbufferID = 0; 79 fMSColorRenderbufferID = 0;
80 fIsWrapped = false;
78 INHERITED::onAbandon(); 81 INHERITED::onAbandon();
79 } 82 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/GrGLTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698