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

Unified Diff: ui/gl/gl_surface_ozone.cc

Issue 1333693004: Support for depth renderbuffer attachment. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: use unique_ptr Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_ozone.cc
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 2b3ed42270516e1c0b64e2a0a47ea525a4d0a645..3cdda42b3c280b3f18151dc7990f026d237f371b 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -460,8 +460,10 @@ class GL_EXPORT GLSurfaceOzoneSurfacelessSurfaceImpl
void BindFramebuffer();
bool CreatePixmaps();
+ static const int kBuffers = 2;
GLuint fbo_;
- GLuint textures_[2];
+ GLuint textures_[kBuffers];
+ std::unique_ptr<GLuint[]> rb_depth_;
jamesr 2015/09/10 18:22:27 add #include <memory> for this
scoped_refptr<GLImage> images_[2];
int current_surface_;
DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl);
@@ -519,6 +521,10 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::OnMakeCurrent(GLContext* context) {
if (!fbo_)
return false;
glGenTextures(arraysize(textures_), textures_);
+ if (get_surface_configuration().depth_bits <= 16) {
+ rb_depth_.reset(new GLuint[kBuffers]);
+ glGenRenderbuffersEXT(kBuffers, rb_depth_.get());
+ }
if (!CreatePixmaps())
return false;
}
@@ -571,6 +577,10 @@ void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
glDeleteTextures(arraysize(textures_), textures_);
for (auto& texture : textures_)
texture = 0;
+ if (rb_depth_) {
+ glDeleteRenderbuffersEXT(kBuffers, rb_depth_.get());
+ rb_depth_.reset();
+ }
glDeleteFramebuffersEXT(1, &fbo_);
fbo_ = 0;
}
@@ -584,12 +594,17 @@ GLSurfaceOzoneSurfacelessSurfaceImpl::~GLSurfaceOzoneSurfacelessSurfaceImpl() {
DCHECK(!fbo_);
for (size_t i = 0; i < arraysize(textures_); i++)
DCHECK(!textures_[i]) << "texture " << i << " not released";
+ DCHECK(!rb_depth_);
}
void GLSurfaceOzoneSurfacelessSurfaceImpl::BindFramebuffer() {
ScopedFrameBufferBinder fb(fbo_);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
textures_[current_surface_], 0);
+ if (rb_depth_) {
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
+ GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb_depth_[current_surface_]);
+ }
}
bool GLSurfaceOzoneSurfacelessSurfaceImpl::CreatePixmaps() {
@@ -617,6 +632,13 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::CreatePixmaps() {
if (!images_[i]->BindTexImage(GL_TEXTURE_2D))
return false;
}
+ if (rb_depth_) {
+ for (size_t i = 0; i < kBuffers; i++) {
+ glBindRenderbufferEXT(GL_RENDERBUFFER, rb_depth_[i]);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
+ GetSize().width(), GetSize().height());
+ }
+ }
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698