diff options
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/gl/gl_context_cgl.cc | 1 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_cgl.cc | 39 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_cgl.h | 14 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_mac.cc | 2 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_mac.cc | 45 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_mac.h | 7 |
6 files changed, 34 insertions, 74 deletions
diff --git a/ui/gfx/gl/gl_context_cgl.cc b/ui/gfx/gl/gl_context_cgl.cc index b95f7ff..f530f3a 100644 --- a/ui/gfx/gl/gl_context_cgl.cc +++ b/ui/gfx/gl/gl_context_cgl.cc @@ -38,7 +38,6 @@ bool GLContextCGL::Initialize( } std::vector<CGLPixelFormatAttribute> attribs; - attribs.push_back(kCGLPFAPBuffer); bool using_offline_renderer = SupportsDualGpus() && gpu_preference == PreferIntegratedGpu; if (using_offline_renderer) { diff --git a/ui/gfx/gl/gl_surface_cgl.cc b/ui/gfx/gl/gl_surface_cgl.cc index 5f3ec58..e734523 100644 --- a/ui/gfx/gl/gl_surface_cgl.cc +++ b/ui/gfx/gl/gl_surface_cgl.cc @@ -68,53 +68,36 @@ void* GLSurfaceCGL::GetPixelFormat() { return g_pixel_format; } -PbufferGLSurfaceCGL::PbufferGLSurfaceCGL(const gfx::Size& size) - : size_(size), - pbuffer_(NULL) { +NoOpGLSurfaceCGL::NoOpGLSurfaceCGL(const gfx::Size& size) + : size_(size) { } -PbufferGLSurfaceCGL::~PbufferGLSurfaceCGL() { +NoOpGLSurfaceCGL::~NoOpGLSurfaceCGL() { Destroy(); } -bool PbufferGLSurfaceCGL::Initialize() { - if (CGLCreatePBuffer(size_.width(), - size_.height(), - GL_TEXTURE_2D, - GL_RGBA, - 0, - reinterpret_cast<CGLPBufferObj*>(&pbuffer_)) - != kCGLNoError) { - LOG(ERROR) << "Error creating pbuffer."; - Destroy(); - return false; - } - +bool NoOpGLSurfaceCGL::Initialize() { return true; } -void PbufferGLSurfaceCGL::Destroy() { - if (pbuffer_) { - CGLDestroyPBuffer(static_cast<CGLPBufferObj>(pbuffer_)); - pbuffer_ = NULL; - } +void NoOpGLSurfaceCGL::Destroy() { } -bool PbufferGLSurfaceCGL::IsOffscreen() { +bool NoOpGLSurfaceCGL::IsOffscreen() { return true; } -bool PbufferGLSurfaceCGL::SwapBuffers() { - NOTREACHED() << "Cannot call SwapBuffers on a PbufferGLSurfaceCGL."; +bool NoOpGLSurfaceCGL::SwapBuffers() { + NOTREACHED() << "Cannot call SwapBuffers on a NoOpGLSurfaceCGL."; return false; } -gfx::Size PbufferGLSurfaceCGL::GetSize() { +gfx::Size NoOpGLSurfaceCGL::GetSize() { return size_; } -void* PbufferGLSurfaceCGL::GetHandle() { - return pbuffer_; +void* NoOpGLSurfaceCGL::GetHandle() { + return NULL; } } // namespace gfx diff --git a/ui/gfx/gl/gl_surface_cgl.h b/ui/gfx/gl/gl_surface_cgl.h index 6924c69..4e31c40 100644 --- a/ui/gfx/gl/gl_surface_cgl.h +++ b/ui/gfx/gl/gl_surface_cgl.h @@ -23,11 +23,14 @@ class GLSurfaceCGL : public GLSurface { DISALLOW_COPY_AND_ASSIGN(GLSurfaceCGL); }; -// A surface used to render to an offscreen pbuffer. -class PbufferGLSurfaceCGL : public GLSurfaceCGL { +// A "no-op" surface. It is not required that a CGLContextObj have an +// associated drawable (pbuffer or fullscreen context) in order to be +// made current. Everywhere this surface type is used, we allocate an +// FBO at the user level as the drawable of the associated context. +class NoOpGLSurfaceCGL : public GLSurfaceCGL { public: - explicit PbufferGLSurfaceCGL(const gfx::Size& size); - virtual ~PbufferGLSurfaceCGL(); + explicit NoOpGLSurfaceCGL(const gfx::Size& size); + virtual ~NoOpGLSurfaceCGL(); // Implement GLSurface. virtual bool Initialize() OVERRIDE; @@ -39,9 +42,8 @@ class PbufferGLSurfaceCGL : public GLSurfaceCGL { private: gfx::Size size_; - void* pbuffer_; - DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceCGL); + DISALLOW_COPY_AND_ASSIGN(NoOpGLSurfaceCGL); }; } // namespace gfx diff --git a/ui/gfx/gl/gl_surface_mac.cc b/ui/gfx/gl/gl_surface_mac.cc index 40b7f03..aeb3366 100644 --- a/ui/gfx/gl/gl_surface_mac.cc +++ b/ui/gfx/gl/gl_surface_mac.cc @@ -78,7 +78,7 @@ scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( } case kGLImplementationDesktopGL: case kGLImplementationAppleGL: { - scoped_refptr<GLSurface> surface(new PbufferGLSurfaceCGL(size)); + scoped_refptr<GLSurface> surface(new NoOpGLSurfaceCGL(size)); if (!surface->Initialize()) return NULL; diff --git a/ui/gfx/surface/accelerated_surface_mac.cc b/ui/gfx/surface/accelerated_surface_mac.cc index 1a0fd31..6978c57 100644 --- a/ui/gfx/surface/accelerated_surface_mac.cc +++ b/ui/gfx/surface/accelerated_surface_mac.cc @@ -18,8 +18,7 @@ AcceleratedSurface::AcceleratedSurface() : io_surface_id_(0), allocate_fbo_(false), texture_(0), - fbo_(0), - depth_stencil_renderbuffer_(0) { + fbo_(0) { } AcceleratedSurface::~AcceleratedSurface() {} @@ -34,9 +33,10 @@ bool AcceleratedSurface::Initialize( if (!gfx::GLSurface::InitializeOneOff()) return false; - // Drawing to IOSurfaces via OpenGL only works with desktop GL and + // Drawing to IOSurfaces via OpenGL only works with Apple's GL and // not with the OSMesa software renderer. - if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) + if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL && + gfx::GetGLImplementation() != gfx::kGLImplementationAppleGL) return false; gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( @@ -167,21 +167,8 @@ void AcceleratedSurface::AllocateRenderBuffers(GLenum target, // Generate and bind the framebuffer object. glGenFramebuffersEXT(1, &fbo_); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_); - // Generate (but don't bind) the depth buffer -- we don't need - // this bound in order to do offscreen rendering. - glGenRenderbuffersEXT(1, &depth_stencil_renderbuffer_); } - // Reallocate the depth buffer. - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_stencil_renderbuffer_); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, - GL_DEPTH24_STENCIL8_EXT, - size.width(), - size.height()); - - // Unbind the renderbuffers. - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); - // Make sure that subsequent set-up code affects the render texture. glBindTexture(target, texture_); } @@ -195,21 +182,6 @@ bool AcceleratedSurface::SetupFrameBufferObject(GLenum target) { texture_, 0); fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - if (fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, - GL_DEPTH_ATTACHMENT_EXT, - GL_RENDERBUFFER_EXT, - depth_stencil_renderbuffer_); - fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - } - // Attach the depth and stencil buffer. - if (fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT) { - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, - 0x8D20, // GL_STENCIL_ATTACHMENT, - GL_RENDERBUFFER_EXT, - depth_stencil_renderbuffer_); - fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - } return fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT; } @@ -290,7 +262,7 @@ uint32 AcceleratedSurface::SetSurfaceSize(const gfx::Size& size) { // Don't think we need to identify a plane. GLuint plane = 0; - io_surface_support->CGLTexImageIOSurface2D( + CGLError error = io_surface_support->CGLTexImageIOSurface2D( static_cast<CGLContextObj>(gl_context_->GetHandle()), target, GL_RGBA, @@ -300,9 +272,14 @@ uint32 AcceleratedSurface::SetSurfaceSize(const gfx::Size& size) { GL_UNSIGNED_INT_8_8_8_8_REV, io_surface_.get(), plane); + if (error != kCGLNoError) { + DLOG(ERROR) << "CGL error " << error << " during CGLTexImageIOSurface2D"; + } if (allocate_fbo_) { // Set up the frame buffer object. - SetupFrameBufferObject(target); + if (!SetupFrameBufferObject(target)) { + DLOG(ERROR) << "Failed to set up frame buffer object"; + } } surface_size_ = size; real_surface_size_ = clamped_size; diff --git a/ui/gfx/surface/accelerated_surface_mac.h b/ui/gfx/surface/accelerated_surface_mac.h index 37f50a7..e63154b 100644 --- a/ui/gfx/surface/accelerated_surface_mac.h +++ b/ui/gfx/surface/accelerated_surface_mac.h @@ -119,9 +119,9 @@ class SURFACE_EXPORT AcceleratedSurface { gfx::Size GetSize() const { return surface_size_; } private: - // Helper function to generate names for the backing texture, render buffers - // and FBO. On return, the resulting buffer names can be attached to |fbo_|. - // |target| is the target type for the color buffer. + // Helper function to generate names for the backing texture and FBO. On + // return, the resulting names can be attached to |fbo_|. |target| is + // the target type for the color buffer. void AllocateRenderBuffers(GLenum target, const gfx::Size& size); // Helper function to attach the buffers previously allocated by a call to @@ -173,7 +173,6 @@ class SURFACE_EXPORT AcceleratedSurface { // The FBO and renderbuffer are only allocated if allocate_fbo_ is // true. GLuint fbo_; - GLuint depth_stencil_renderbuffer_; // Allocate a TransportDIB in the renderer. base::Callback<void(size_t, TransportDIB::Handle*)> dib_alloc_callback_; base::Callback<void(TransportDIB::Id)> dib_free_callback_; |