OLD | NEW |
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" |
11 | 11 |
12 #define GPUGL static_cast<GrGpuGL*>(getGpu()) | 12 #define GPUGL static_cast<GrGpuGL*>(getGpu()) |
13 | 13 |
14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) | 14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X) |
15 | 15 |
16 void GrGLRenderTarget::init(const Desc& desc, | 16 void GrGLRenderTarget::init(const Desc& desc, |
17 const GrGLIRect& viewport, | 17 const GrGLIRect& viewport, |
18 GrGLTexID* texID) { | 18 GrGLTexID* texID) { |
19 fRTFBOID = desc.fRTFBOID; | 19 fRTFBOID = desc.fRTFBOID; |
20 fTexFBOID = desc.fTexFBOID; | 20 fTexFBOID = desc.fTexFBOID; |
21 fMSColorRenderbufferID = desc.fMSColorRenderbufferID; | 21 fMSColorRenderbufferID = desc.fMSColorRenderbufferID; |
22 fViewport = viewport; | 22 fViewport = viewport; |
23 fTexIDObj = texID; | 23 fTexIDObj.reset(SkSafeRef(texID)); |
24 GrSafeRef(fTexIDObj); | |
25 } | 24 } |
26 | 25 |
27 namespace { | 26 namespace { |
28 GrTextureDesc MakeDesc(GrTextureFlags flags, | 27 GrTextureDesc MakeDesc(GrTextureFlags flags, |
29 int width, int height, | 28 int width, int height, |
30 GrPixelConfig config, int sampleCnt, | 29 GrPixelConfig config, int sampleCnt, |
31 GrSurfaceOrigin origin) { | 30 GrSurfaceOrigin origin) { |
32 GrTextureDesc temp; | 31 GrTextureDesc temp; |
33 temp.fFlags = flags; | 32 temp.fFlags = flags; |
34 temp.fWidth = width; | 33 temp.fWidth = width; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 if (fRTFBOID && fRTFBOID != fTexFBOID) { | 87 if (fRTFBOID && fRTFBOID != fTexFBOID) { |
89 GL_CALL(DeleteFramebuffers(1, &fRTFBOID)); | 88 GL_CALL(DeleteFramebuffers(1, &fRTFBOID)); |
90 } | 89 } |
91 if (fMSColorRenderbufferID) { | 90 if (fMSColorRenderbufferID) { |
92 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID)); | 91 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID)); |
93 } | 92 } |
94 } | 93 } |
95 fRTFBOID = 0; | 94 fRTFBOID = 0; |
96 fTexFBOID = 0; | 95 fTexFBOID = 0; |
97 fMSColorRenderbufferID = 0; | 96 fMSColorRenderbufferID = 0; |
98 GrSafeUnref(fTexIDObj); | 97 fTexIDObj.reset(NULL); |
99 fTexIDObj = NULL; | |
100 INHERITED::onRelease(); | 98 INHERITED::onRelease(); |
101 } | 99 } |
102 | 100 |
103 void GrGLRenderTarget::onAbandon() { | 101 void GrGLRenderTarget::onAbandon() { |
104 fRTFBOID = 0; | 102 fRTFBOID = 0; |
105 fTexFBOID = 0; | 103 fTexFBOID = 0; |
106 fMSColorRenderbufferID = 0; | 104 fMSColorRenderbufferID = 0; |
107 if (NULL != fTexIDObj) { | 105 if (NULL != fTexIDObj.get()) { |
108 fTexIDObj->abandon(); | 106 fTexIDObj->abandon(); |
109 fTexIDObj = NULL; | 107 fTexIDObj.reset(NULL); |
110 } | 108 } |
111 INHERITED::onAbandon(); | 109 INHERITED::onAbandon(); |
112 } | 110 } |
OLD | NEW |