diff options
-rw-r--r-- | content/common/gpu/image_transport_surface_linux.cc | 55 | ||||
-rw-r--r-- | content/common/gpu/image_transport_surface_mac.cc | 36 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_cgl.cc | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_egl.cc | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_glx.cc | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_osmesa.cc | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_wgl.cc | 6 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.cc | 3 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.h | 5 |
9 files changed, 98 insertions, 31 deletions
diff --git a/content/common/gpu/image_transport_surface_linux.cc b/content/common/gpu/image_transport_surface_linux.cc index f003b5e..bd63e04 100644 --- a/content/common/gpu/image_transport_surface_linux.cc +++ b/content/common/gpu/image_transport_surface_linux.cc @@ -67,7 +67,7 @@ class EGLImageTransportSurface : public ImageTransportSurface, virtual bool IsOffscreen() OVERRIDE; virtual bool SwapBuffers() OVERRIDE; virtual gfx::Size GetSize() OVERRIDE; - virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; + virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; virtual void SetVisible(bool visible) OVERRIDE; @@ -87,6 +87,9 @@ class EGLImageTransportSurface : public ImageTransportSurface, scoped_refptr<EGLAcceleratedSurface> back_surface_; scoped_refptr<EGLAcceleratedSurface> front_surface_; + // Whether or not we've successfully made the surface current once. + bool made_current_; + scoped_ptr<ImageTransportHelper> helper_; DISALLOW_COPY_AND_ASSIGN(EGLImageTransportSurface); @@ -107,7 +110,7 @@ class GLXImageTransportSurface : public ImageTransportSurface, virtual void Destroy() OVERRIDE; virtual bool SwapBuffers() OVERRIDE; virtual gfx::Size GetSize() OVERRIDE; - virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; + virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; protected: // ImageTransportSurface implementation: @@ -128,8 +131,8 @@ class GLXImageTransportSurface : public ImageTransportSurface, // Whether or not the image has been bound on the browser side. bool bound_; - // Whether or not we've set the swap interval on the associated context. - bool swap_interval_set_; + // Whether or not we've successfully made the surface current once. + bool made_current_; scoped_ptr<ImageTransportHelper> helper_; @@ -218,7 +221,8 @@ EGLImageTransportSurface::EGLImageTransportSurface( int32 renderer_id, int32 command_buffer_id) : gfx::PbufferGLSurfaceEGL(false, gfx::Size(1, 1)), - fbo_id_(0) { + fbo_id_(0), + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, render_view_id, @@ -253,9 +257,15 @@ bool EGLImageTransportSurface::IsOffscreen() { return false; } -void EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { - if (fbo_id_) - return; +bool EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { + if (made_current_) + return true; + + if (!context->HasExtension("EGL_KHR_image") && + !context->HasExtension("EGL_KHR_image_pixmap")) { + LOG(ERROR) << "EGLImage from X11 pixmap not supported"; + return false; + } glGenFramebuffersEXT(1, &fbo_id_); glBindFramebufferEXT(GL_FRAMEBUFFER, fbo_id_); @@ -264,7 +274,11 @@ void EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) { LOG(ERROR) << "Framebuffer incomplete."; + return false; } + + made_current_ = true; + return true; } unsigned int EGLImageTransportSurface::GetBackingFrameBufferObject() { @@ -364,7 +378,7 @@ GLXImageTransportSurface::GLXImageTransportSurface( dummy_parent_(0), size_(1, 1), bound_(false), - swap_interval_set_(false) { + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, render_view_id, @@ -477,11 +491,26 @@ gfx::Size GLXImageTransportSurface::GetSize() { return size_; } -void GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { - if (!swap_interval_set_) { - context->SetSwapInterval(0); - swap_interval_set_ = true; +bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { + if (made_current_) + return true; + + // Check for driver support. + Display* dpy = gfx::GLSurfaceGLX::GetDisplay(); + int event_base, error_base; + if (XCompositeQueryExtension(dpy, &event_base, &error_base)) { + int major = 0, minor = 2; + XCompositeQueryVersion(dpy, &major, &minor); + if (major == 0 && minor < 2) { + LOG(ERROR) << "Pixmap from window not supported."; + return false; + } } + + context->SetSwapInterval(0); + + made_current_ = true; + return true; } void GLXImageTransportSurface::OnNewSurfaceACK( diff --git a/content/common/gpu/image_transport_surface_mac.cc b/content/common/gpu/image_transport_surface_mac.cc index de7db5e..ba91a92 100644 --- a/content/common/gpu/image_transport_surface_mac.cc +++ b/content/common/gpu/image_transport_surface_mac.cc @@ -35,7 +35,7 @@ class IOSurfaceImageTransportSurface : public gfx::PbufferGLSurfaceCGL, virtual bool IsOffscreen() OVERRIDE; virtual bool SwapBuffers() OVERRIDE; virtual gfx::Size GetSize() OVERRIDE; - virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; + virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; protected: @@ -61,6 +61,9 @@ class IOSurfaceImageTransportSurface : public gfx::PbufferGLSurfaceCGL, gfx::Size size_; + // Whether or not we've successfully made the surface current once. + bool made_current_; + scoped_ptr<ImageTransportHelper> helper_; DISALLOW_COPY_AND_ASSIGN(IOSurfaceImageTransportSurface); @@ -83,7 +86,7 @@ class TransportDIBImageTransportSurface : public gfx::PbufferGLSurfaceCGL, virtual bool IsOffscreen() OVERRIDE; virtual bool SwapBuffers() OVERRIDE; virtual gfx::Size GetSize() OVERRIDE; - virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; + virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; protected: @@ -105,6 +108,9 @@ class TransportDIBImageTransportSurface : public gfx::PbufferGLSurfaceCGL, static uint32 next_id_; + // Whether or not we've successfully made the surface current once. + bool made_current_; + scoped_ptr<ImageTransportHelper> helper_; DISALLOW_COPY_AND_ASSIGN(TransportDIBImageTransportSurface); @@ -137,7 +143,8 @@ IOSurfaceImageTransportSurface::IOSurfaceImageTransportSurface( fbo_id_(0), texture_id_(0), io_surface_id_(0), - context_(NULL) { + context_(NULL), + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, render_view_id, @@ -182,11 +189,11 @@ bool IOSurfaceImageTransportSurface::IsOffscreen() { return false; } -void IOSurfaceImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { +bool IOSurfaceImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { context_ = context; - if (fbo_id_) - return; + if (made_current_) + return true; glGenFramebuffersEXT(1, &fbo_id_); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_); @@ -195,7 +202,11 @@ void IOSurfaceImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE) { LOG(ERROR) << "Framebuffer incomplete."; + return false; } + + made_current_ = true; + return true; } unsigned int IOSurfaceImageTransportSurface::GetBackingFrameBufferObject() { @@ -325,7 +336,8 @@ TransportDIBImageTransportSurface::TransportDIBImageTransportSurface( gfx::PluginWindowHandle handle) : gfx::PbufferGLSurfaceCGL(gfx::Size(1, 1)), fbo_id_(0), - render_buffer_id_(0) { + render_buffer_id_(0), + made_current_(false) { helper_.reset(new ImageTransportHelper(this, manager, render_view_id, @@ -364,9 +376,9 @@ bool TransportDIBImageTransportSurface::IsOffscreen() { return false; } -void TransportDIBImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { - if (fbo_id_) - return; +bool TransportDIBImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { + if (made_current_) + return true; glGenFramebuffersEXT(1, &fbo_id_); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_id_); @@ -375,7 +387,11 @@ void TransportDIBImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE) { LOG(ERROR) << "Framebuffer incomplete."; + return false; } + + made_current_ = true; + return true; } unsigned int TransportDIBImageTransportSurface::GetBackingFrameBufferObject() { diff --git a/ui/gfx/gl/gl_context_cgl.cc b/ui/gfx/gl/gl_context_cgl.cc index a759793..86933b64 100644 --- a/ui/gfx/gl/gl_context_cgl.cc +++ b/ui/gfx/gl/gl_context_cgl.cc @@ -101,7 +101,11 @@ bool GLContextCGL::MakeCurrent(GLSurface* surface) { } SetCurrent(this, surface); - surface->OnMakeCurrent(this); + if (!surface->OnMakeCurrent(this)) { + LOG(ERROR) << "Unable to make gl context current."; + return false; + } + return true; } diff --git a/ui/gfx/gl/gl_context_egl.cc b/ui/gfx/gl/gl_context_egl.cc index dea684b..ffaaaea 100644 --- a/ui/gfx/gl/gl_context_egl.cc +++ b/ui/gfx/gl/gl_context_egl.cc @@ -97,7 +97,11 @@ bool GLContextEGL::MakeCurrent(GLSurface* surface) { } SetCurrent(this, surface); - surface->OnMakeCurrent(this); + if (!surface->OnMakeCurrent(this)) { + LOG(ERROR) << "Could not make current."; + return false; + } + return true; } diff --git a/ui/gfx/gl/gl_context_glx.cc b/ui/gfx/gl/gl_context_glx.cc index 071107a..0797721 100644 --- a/ui/gfx/gl/gl_context_glx.cc +++ b/ui/gfx/gl/gl_context_glx.cc @@ -177,7 +177,11 @@ bool GLContextGLX::MakeCurrent(GLSurface* surface) { } SetCurrent(this, surface); - surface->OnMakeCurrent(this); + if (!surface->OnMakeCurrent(this)) { + LOG(ERROR) << "Could not make current."; + return false; + } + return true; } diff --git a/ui/gfx/gl/gl_context_osmesa.cc b/ui/gfx/gl/gl_context_osmesa.cc index 6b56f9d..3af14ae 100644 --- a/ui/gfx/gl/gl_context_osmesa.cc +++ b/ui/gfx/gl/gl_context_osmesa.cc @@ -70,7 +70,11 @@ bool GLContextOSMesa::MakeCurrent(GLSurface* surface) { OSMesaPixelStore(OSMESA_Y_UP, 0); SetCurrent(this, surface); - surface->OnMakeCurrent(this); + if (!surface->OnMakeCurrent(this)) { + LOG(ERROR) << "Could not make current."; + return false; + } + return true; } diff --git a/ui/gfx/gl/gl_context_wgl.cc b/ui/gfx/gl/gl_context_wgl.cc index bf44450..dc75b78 100644 --- a/ui/gfx/gl/gl_context_wgl.cc +++ b/ui/gfx/gl/gl_context_wgl.cc @@ -84,7 +84,11 @@ bool GLContextWGL::MakeCurrent(GLSurface* surface) { } SetCurrent(this, surface); - surface->OnMakeCurrent(this); + if (!surface->OnMakeCurrent(this)) { + LOG(ERROR) << "Could not make current."; + return false; + } + return true; } diff --git a/ui/gfx/gl/gl_surface.cc b/ui/gfx/gl/gl_surface.cc index a47ab98..868b1b29 100644 --- a/ui/gfx/gl/gl_surface.cc +++ b/ui/gfx/gl/gl_surface.cc @@ -28,7 +28,8 @@ unsigned int GLSurface::GetBackingFrameBufferObject() { return 0; } -void GLSurface::OnMakeCurrent(GLContext* context) { +bool GLSurface::OnMakeCurrent(GLContext* context) { + return true; } void GLSurface::SetVisible(bool visible) { diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h index a1f4584..60e32c4 100644 --- a/ui/gfx/gl/gl_surface.h +++ b/ui/gfx/gl/gl_surface.h @@ -50,8 +50,9 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { static bool InitializeOneOff(); - // Called after a context is made current with this surface. - virtual void OnMakeCurrent(GLContext* context); + // Called after a context is made current with this surface. Returns false + // on error. + virtual bool OnMakeCurrent(GLContext* context); virtual void SetVisible(bool visible); |