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

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

Issue 970613003: Revert of Improve tracking of bound FBOs in GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('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 "GrGLGpu.h" 10 #include "GrGLGpu.h"
11 11
12 void GrGLFBO::release(const GrGLInterface* gl) { 12 #define GPUGL static_cast<GrGLGpu*>(this->getGpu())
13 SkASSERT(gl); 13 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
14 if (this->isValid()) {
15 GR_GL_CALL(gl, DeleteFramebuffers(1, &fID));
16 fIsValid = false;
17 }
18 }
19
20 void GrGLFBO::abandon() { fIsValid = false; }
21
22 //////////////////////////////////////////////////////////////////////////////
23
24 #define GLGPU static_cast<GrGLGpu*>(this->getGpu())
25 #define GL_CALL(X) GR_GL_CALL(GLGPU->glInterface(), X)
26 14
27 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor. 15 // Because this class is virtually derived from GrSurface we must explicitly cal l its constructor.
28 GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons t IDDesc& idDesc) 16 GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons t IDDesc& idDesc)
29 : GrSurface(gpu, idDesc.fLifeCycle, desc) 17 : GrSurface(gpu, idDesc.fLifeCycle, desc)
30 , INHERITED(gpu, idDesc.fLifeCycle, desc) { 18 , INHERITED(gpu, idDesc.fLifeCycle, desc) {
31 this->init(desc, idDesc); 19 this->init(desc, idDesc);
32 this->registerWithCache(); 20 this->registerWithCache();
33 } 21 }
34 22
35 GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons t IDDesc& idDesc, 23 GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, cons t IDDesc& idDesc,
36 Derived) 24 Derived)
37 : GrSurface(gpu, idDesc.fLifeCycle, desc) 25 : GrSurface(gpu, idDesc.fLifeCycle, desc)
38 , INHERITED(gpu, idDesc.fLifeCycle, desc) { 26 , INHERITED(gpu, idDesc.fLifeCycle, desc) {
39 this->init(desc, idDesc); 27 this->init(desc, idDesc);
40 } 28 }
41 29
42 void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { 30 void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
43 fRenderFBO.reset(SkRef(idDesc.fRenderFBO.get())); 31 fRTFBOID = idDesc.fRTFBOID;
44 fTextureFBO.reset(SkSafeRef(idDesc.fTextureFBO.get())); 32 fTexFBOID = idDesc.fTexFBOID;
45 SkASSERT(fRenderFBO->isValid());
46 SkASSERT(!fTextureFBO || fTextureFBO->isValid());
47 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; 33 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
48 fIsWrapped = kWrapped_LifeCycle == idDesc.fLifeCycle; 34 fIsWrapped = kWrapped_LifeCycle == idDesc.fLifeCycle;
49 35
50 fViewport.fLeft = 0; 36 fViewport.fLeft = 0;
51 fViewport.fBottom = 0; 37 fViewport.fBottom = 0;
52 fViewport.fWidth = desc.fWidth; 38 fViewport.fWidth = desc.fWidth;
53 fViewport.fHeight = desc.fHeight; 39 fViewport.fHeight = desc.fHeight;
54 40
55 // We own one color value for each MSAA sample. 41 // We own one color value for each MSAA sample.
56 fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt); 42 fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt);
57 if (fTextureFBO && fTextureFBO != fRenderFBO) { 43 if (fTexFBOID != fRTFBOID) {
58 // 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.
59 fColorValuesPerPixel += 1; 45 fColorValuesPerPixel += 1;
60 } 46 }
61 } 47 }
62 48
63 size_t GrGLRenderTarget::onGpuMemorySize() const { 49 size_t GrGLRenderTarget::onGpuMemorySize() const {
64 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig); 50 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig);
65 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig)); 51 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig));
66 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig); 52 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig);
67 SkASSERT(colorBytes > 0); 53 SkASSERT(colorBytes > 0);
68 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; 54 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes;
69 } 55 }
70 56
71 void GrGLRenderTarget::onRelease() { 57 void GrGLRenderTarget::onRelease() {
72 if (!fIsWrapped) { 58 if (!fIsWrapped) {
73 const GrGLInterface* gl = GLGPU->glInterface(); 59 if (fTexFBOID) {
74 if (fRenderFBO) { 60 GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
75 fRenderFBO->release(gl);
76 fRenderFBO.reset(NULL);
77 } 61 }
78 if (fTextureFBO) { 62 if (fRTFBOID && fRTFBOID != fTexFBOID) {
79 fTextureFBO->release(gl); 63 GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
80 fTextureFBO.reset(NULL);
81 } 64 }
82 if (fMSColorRenderbufferID) { 65 if (fMSColorRenderbufferID) {
83 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID)); 66 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
84 fMSColorRenderbufferID = 0;
85 } 67 }
86 } else {
87 if (fRenderFBO) {
88 fRenderFBO->abandon();
89 fRenderFBO.reset(NULL);
90 }
91 if (fTextureFBO) {
92 fTextureFBO->abandon();
93 fTextureFBO.reset(NULL);
94 }
95 fMSColorRenderbufferID = 0;
96 } 68 }
69 fRTFBOID = 0;
70 fTexFBOID = 0;
71 fMSColorRenderbufferID = 0;
72 fIsWrapped = false;
97 INHERITED::onRelease(); 73 INHERITED::onRelease();
98 } 74 }
99 75
100 void GrGLRenderTarget::onAbandon() { 76 void GrGLRenderTarget::onAbandon() {
101 if (fRenderFBO) { 77 fRTFBOID = 0;
102 fRenderFBO->abandon(); 78 fTexFBOID = 0;
103 fRenderFBO.reset(NULL);
104 }
105 if (fTextureFBO) {
106 fTextureFBO->abandon();
107 fTextureFBO.reset(NULL);
108 }
109 fMSColorRenderbufferID = 0; 79 fMSColorRenderbufferID = 0;
80 fIsWrapped = false;
110 INHERITED::onAbandon(); 81 INHERITED::onAbandon();
111 } 82 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | src/gpu/gl/debug/GrGLCreateDebugInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698