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 "GrRenderTargetPriv.h" | 10 #include "GrRenderTargetPriv.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 const GrGLInterface* interface = gpu->glInterface(); | 77 const GrGLInterface* interface = gpu->glInterface(); |
78 GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment
(); | 78 GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment
(); |
79 if (nullptr == stencil) { | 79 if (nullptr == stencil) { |
80 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 80 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
81 GR_GL_STENCIL_ATTACHMENT, | 81 GR_GL_STENCIL_ATTACHMENT, |
82 GR_GL_RENDERBUFFER, 0)); | 82 GR_GL_RENDERBUFFER, 0)); |
83 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 83 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
84 GR_GL_DEPTH_ATTACHMENT, | 84 GR_GL_DEPTH_ATTACHMENT, |
85 GR_GL_RENDERBUFFER, 0)); | 85 GR_GL_RENDERBUFFER, 0)); |
86 #ifdef SK_DEBUG | 86 #ifdef SK_DEBUG |
87 GrGLenum status; | 87 if (kChromium_GrGLDriver != gpu->glContext().driver()) { |
88 GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAMEBUFF
ER)); | 88 // This check can cause problems in Chromium if the context has been
asynchronously |
89 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); | 89 // abandoned (see skbug.com/5200) |
| 90 GrGLenum status; |
| 91 GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAME
BUFFER)); |
| 92 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); |
| 93 } |
90 #endif | 94 #endif |
91 return true; | 95 return true; |
92 } else { | 96 } else { |
93 const GrGLStencilAttachment* glStencil = static_cast<const GrGLStencilAt
tachment*>(stencil); | 97 const GrGLStencilAttachment* glStencil = static_cast<const GrGLStencilAt
tachment*>(stencil); |
94 GrGLuint rb = glStencil->renderbufferID(); | 98 GrGLuint rb = glStencil->renderbufferID(); |
95 | 99 |
96 gpu->invalidateBoundRenderTarget(); | 100 gpu->invalidateBoundRenderTarget(); |
97 gpu->stats()->incRenderTargetBinds(); | 101 gpu->stats()->incRenderTargetBinds(); |
98 GR_GL_CALL(interface, BindFramebuffer(GR_GL_FRAMEBUFFER, this->renderFBO
ID())); | 102 GR_GL_CALL(interface, BindFramebuffer(GR_GL_FRAMEBUFFER, this->renderFBO
ID())); |
99 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 103 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
100 GR_GL_STENCIL_ATTACHMENT, | 104 GR_GL_STENCIL_ATTACHMENT, |
101 GR_GL_RENDERBUFFER, rb)); | 105 GR_GL_RENDERBUFFER, rb)); |
102 if (glStencil->format().fPacked) { | 106 if (glStencil->format().fPacked) { |
103 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 107 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
104 GR_GL_DEPTH_ATTACHMENT
, | 108 GR_GL_DEPTH_ATTACHMENT
, |
105 GR_GL_RENDERBUFFER, rb
)); | 109 GR_GL_RENDERBUFFER, rb
)); |
106 } else { | 110 } else { |
107 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 111 GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
108 GR_GL_DEPTH_ATTACHMENT
, | 112 GR_GL_DEPTH_ATTACHMENT
, |
109 GR_GL_RENDERBUFFER, 0)
); | 113 GR_GL_RENDERBUFFER, 0)
); |
110 } | 114 } |
111 | 115 |
112 #ifdef SK_DEBUG | 116 #ifdef SK_DEBUG |
113 GrGLenum status; | 117 if (kChromium_GrGLDriver != gpu->glContext().driver()) { |
114 GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAMEBUFF
ER)); | 118 // This check can cause problems in Chromium if the context has been
asynchronously |
115 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); | 119 // abandoned (see skbug.com/5200) |
| 120 GrGLenum status; |
| 121 GR_GL_CALL_RET(interface, status, CheckFramebufferStatus(GR_GL_FRAME
BUFFER)); |
| 122 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); |
| 123 } |
116 #endif | 124 #endif |
117 return true; | 125 return true; |
118 } | 126 } |
119 } | 127 } |
120 | 128 |
121 void GrGLRenderTarget::onRelease() { | 129 void GrGLRenderTarget::onRelease() { |
122 if (kBorrowed_LifeCycle != fRTLifecycle) { | 130 if (kBorrowed_LifeCycle != fRTLifecycle) { |
123 if (fTexFBOID) { | 131 if (fTexFBOID) { |
124 GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); | 132 GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); |
125 } | 133 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 int GrGLRenderTarget::totalSamples() const { | 208 int GrGLRenderTarget::totalSamples() const { |
201 int total_samples = this->msaaSamples(); | 209 int total_samples = this->msaaSamples(); |
202 | 210 |
203 if (fTexFBOID != kUnresolvableFBOID) { | 211 if (fTexFBOID != kUnresolvableFBOID) { |
204 // If we own the resolve buffer then that is one more sample per pixel. | 212 // If we own the resolve buffer then that is one more sample per pixel. |
205 total_samples += 1; | 213 total_samples += 1; |
206 } | 214 } |
207 | 215 |
208 return total_samples; | 216 return total_samples; |
209 } | 217 } |
OLD | NEW |