| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/ui/gl_renderer.h" | 5 #include "mojo/ui/gl_renderer.h" |
| 6 | 6 |
| 7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
| 8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
| 9 #endif | 9 #endif |
| 10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 GLuint depth_buffer = 0u; | 96 GLuint depth_buffer = 0u; |
| 97 if (with_depth) { | 97 if (with_depth) { |
| 98 glGenRenderbuffers(1, &depth_buffer); | 98 glGenRenderbuffers(1, &depth_buffer); |
| 99 glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); | 99 glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); |
| 100 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.width, | 100 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.width, |
| 101 size.height); | 101 size.height); |
| 102 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 102 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
| 103 GL_RENDERBUFFER, depth_buffer); | 103 GL_RENDERBUFFER, depth_buffer); |
| 104 } | 104 } |
| 105 | 105 |
| 106 DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 106 #if DCHECK_IS_ON() |
| 107 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 107 // This check causes a flush of the GL pipeline which is too expensive |
| 108 // even in debug mode so only check it the first time as a sanity check. |
| 109 if (!checked_framebuffer_status_) { |
| 110 DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 111 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 112 checked_framebuffer_status_ = true; |
| 113 } |
| 114 #endif |
| 108 | 115 |
| 109 glViewport(0, 0, size.width, size.height); | 116 glViewport(0, 0, size.width, size.height); |
| 110 callback.Run(gl_scope, size); | 117 callback.Run(gl_scope, size); |
| 111 | 118 |
| 112 if (with_depth) | 119 if (with_depth) |
| 113 glDeleteRenderbuffers(1, &depth_buffer); | 120 glDeleteRenderbuffers(1, &depth_buffer); |
| 114 glDeleteFramebuffers(1, &fbo); | 121 glDeleteFramebuffers(1, &fbo); |
| 115 | 122 |
| 116 return BindTextureResource(gl_scope, std::move(texture)); | 123 return BindTextureResource(gl_scope, std::move(texture)); |
| 117 } | 124 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 170 |
| 164 void GLRenderer::GLTextureReleaser::Release(bool recyclable) { | 171 void GLRenderer::GLTextureReleaser::Release(bool recyclable) { |
| 165 if (provider_) { | 172 if (provider_) { |
| 166 provider_->ReleaseTexture(std::move(texture_info_), recyclable); | 173 provider_->ReleaseTexture(std::move(texture_info_), recyclable); |
| 167 provider_.reset(); | 174 provider_.reset(); |
| 168 } | 175 } |
| 169 } | 176 } |
| 170 | 177 |
| 171 } // namespace ui | 178 } // namespace ui |
| 172 } // namespace mojo | 179 } // namespace mojo |
| OLD | NEW |