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

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: 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..d85a3b3d847cb59abc7e1a2b289661de24082ac5 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];
+ GLuint* rb_depth_;
scoped_refptr<GLImage> images_[2];
int current_surface_;
DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl);
@@ -503,6 +505,7 @@ GLSurfaceOzoneSurfacelessSurfaceImpl::GLSurfaceOzoneSurfacelessSurfaceImpl(
: GLSurfaceOzoneSurfaceless(
ozone_surface.Pass(), widget, requested_configuration),
fbo_(0),
+ rb_depth_(nullptr),
current_surface_(0) {
for (auto& texture : textures_)
texture = 0;
@@ -519,6 +522,10 @@ bool GLSurfaceOzoneSurfacelessSurfaceImpl::OnMakeCurrent(GLContext* context) {
if (!fbo_)
return false;
glGenTextures(arraysize(textures_), textures_);
+ if (get_surface_configuration().depth_bits <= 16) {
+ rb_depth_ = new GLuint[kBuffers];
+ glGenRenderbuffersEXT(kBuffers, rb_depth_);
+ }
if (!CreatePixmaps())
return false;
}
@@ -571,6 +578,11 @@ void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
glDeleteTextures(arraysize(textures_), textures_);
for (auto& texture : textures_)
texture = 0;
+ if (rb_depth_) {
+ glDeleteRenderbuffersEXT(kBuffers, rb_depth_);
+ delete rb_depth_;
jamesr 2015/09/10 00:38:21 you called operator new[] so you can't call operat
cdotstout 2015/09/10 18:19:47 Done.
+ rb_depth_ = nullptr;
jamesr 2015/09/10 00:38:21 a real smart pointer will handle this for you too
cdotstout 2015/09/10 18:19:47 Done.
+ }
glDeleteFramebuffersEXT(1, &fbo_);
fbo_ = 0;
}
@@ -584,12 +596,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 +634,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