diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 13:52:25 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 13:52:25 +0000 |
commit | aa258822cb53d55894583a5a0e458a6401b4fc4a (patch) | |
tree | 6772ac542208209a68c0300c346deeb966bf36bf | |
parent | cfa6ea988964c65b9a2f5208dd8c9c3fbe5b78ec (diff) | |
download | chromium_src-aa258822cb53d55894583a5a0e458a6401b4fc4a.zip chromium_src-aa258822cb53d55894583a5a0e458a6401b4fc4a.tar.gz chromium_src-aa258822cb53d55894583a5a0e458a6401b4fc4a.tar.bz2 |
Allow GLSurface to indicate that it supports a specific extension.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/8566041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111147 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 12 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 2 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context.cc | 16 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.cc | 9 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface.h | 5 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.cc | 9 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_egl.h | 2 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_glx.cc | 18 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_glx.h | 2 | ||||
-rw-r--r-- | webkit/gpu/webgraphicscontext3d_in_process_impl.cc | 2 |
10 files changed, 54 insertions, 23 deletions
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 64c7222..6b26b91 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -6,8 +6,8 @@ #include <string> #include "gpu/command_buffer/service/feature_info.h" #include "gpu/command_buffer/service/gl_utils.h" +#include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_implementation.h" -#include "ui/gfx/gl/gl_surface.h" namespace gpu { namespace gles2 { @@ -97,7 +97,11 @@ bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features, void FeatureInfo::AddFeatures(const char* desired_features) { // Figure out what extensions to turn on. ExtensionHelper ext( - reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), + // Some unittests execute without a context made current + // so fall back to glGetString + gfx::GLContext::GetCurrent() ? + gfx::GLContext::GetCurrent()->GetExtensions().c_str() : + reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), desired_features); bool npot_ok = false; @@ -359,9 +363,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) { enable_texture_half_float_linear; feature_flags_.npot_ok = npot_ok; - if (ext.Desire("GL_CHROMIUM_post_sub_buffer") && - gfx::GLSurface::GetCurrent() && - gfx::GLSurface::GetCurrent()->SupportsPostSubBuffer()) { + if (ext.HaveAndDesire("GL_CHROMIUM_post_sub_buffer")) { AddExtensionString("GL_CHROMIUM_post_sub_buffer"); } } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index e8deed6..70c7484 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -5741,7 +5741,7 @@ error::Error GLES2DecoderImpl::HandlePixelStorei( error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); - if (!surface_->SupportsPostSubBuffer()) { + if (!context_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { SetGLError(GL_INVALID_OPERATION, "glPostSubBufferCHROMIUM: command not supported by surface"); return error::kNoError; diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc index 998614fb..9fc5411 100644 --- a/ui/gfx/gl/gl_context.cc +++ b/ui/gfx/gl/gl_context.cc @@ -39,8 +39,20 @@ GLContext::~GLContext() { std::string GLContext::GetExtensions() { DCHECK(IsCurrent(NULL)); - const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); - return std::string(ext ? ext : ""); + + std::string extensions; + if (GLSurface::GetCurrent()) { + extensions = GLSurface::GetCurrent()->GetExtensions(); + } + + const char* gl_ext = reinterpret_cast<const char*>( + glGetString(GL_EXTENSIONS)); + if (gl_ext) { + extensions += (!extensions.empty() && gl_ext[0]) ? " " : ""; + extensions += gl_ext; + } + + return extensions; } bool GLContext::HasExtension(const char* name) { diff --git a/ui/gfx/gl/gl_surface.cc b/ui/gfx/gl/gl_surface.cc index 1064878..9276d00 100644 --- a/ui/gfx/gl/gl_surface.cc +++ b/ui/gfx/gl/gl_surface.cc @@ -90,12 +90,13 @@ bool GLSurface::Resize(const gfx::Size& size) { return false; } -unsigned int GLSurface::GetBackingFrameBufferObject() { - return 0; +std::string GLSurface::GetExtensions() { + DCHECK_EQ(GetCurrent(), this); + return std::string(""); } -bool GLSurface::SupportsPostSubBuffer() { - return false; +unsigned int GLSurface::GetBackingFrameBufferObject() { + return 0; } bool GLSurface::PostSubBuffer(int x, int y, int width, int height) { diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h index 95a34668..8318368 100644 --- a/ui/gfx/gl/gl_surface.h +++ b/ui/gfx/gl/gl_surface.h @@ -46,12 +46,15 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { // Get the underlying platform specific surface "handle". virtual void* GetHandle() = 0; + // Returns space separated list of surface specific extensions. + // The surface must be current. + virtual std::string GetExtensions(); + // Returns the internal frame buffer object name if the surface is backed by // FBO. Otherwise returns 0. virtual unsigned int GetBackingFrameBufferObject(); // Copy part of the backbuffer to the frontbuffer. - virtual bool SupportsPostSubBuffer(); virtual bool PostSubBuffer(int x, int y, int width, int height); static bool InitializeOneOff(); diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc index e18966b..f1d0750 100644 --- a/ui/gfx/gl/gl_surface_egl.cc +++ b/ui/gfx/gl/gl_surface_egl.cc @@ -273,8 +273,13 @@ EGLSurface NativeViewGLSurfaceEGL::GetHandle() { return surface_; } -bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { - return supports_post_sub_buffer_; +std::string NativeViewGLSurfaceEGL::GetExtensions() { + std::string extensions = GLSurface::GetExtensions(); + if (supports_post_sub_buffer_) { + extensions += extensions.empty() ? "" : " "; + extensions += "GL_CHROMIUM_post_sub_buffer"; + } + return extensions; } bool NativeViewGLSurfaceEGL::PostSubBuffer( diff --git a/ui/gfx/gl/gl_surface_egl.h b/ui/gfx/gl/gl_surface_egl.h index 7967f8e..2ebe276 100644 --- a/ui/gfx/gl/gl_surface_egl.h +++ b/ui/gfx/gl/gl_surface_egl.h @@ -65,7 +65,7 @@ class NativeViewGLSurfaceEGL : public GLSurfaceEGL { virtual bool SwapBuffers(); virtual gfx::Size GetSize(); virtual EGLSurface GetHandle(); - virtual bool SupportsPostSubBuffer(); + virtual std::string GetExtensions(); virtual bool PostSubBuffer(int x, int y, int width, int height); private: diff --git a/ui/gfx/gl/gl_surface_glx.cc b/ui/gfx/gl/gl_surface_glx.cc index 373bc85..3b8cbe9 100644 --- a/ui/gfx/gl/gl_surface_glx.cc +++ b/ui/gfx/gl/gl_surface_glx.cc @@ -73,10 +73,12 @@ bool GLSurfaceGLX::InitializeOneOff() { return true; } +// static const char* GLSurfaceGLX::GetGLXExtensions() { return g_glx_extensions; } +// static bool GLSurfaceGLX::HasGLXExtension(const char* name) { DCHECK(name); const char* c_extensions = GetGLXExtensions(); @@ -91,6 +93,7 @@ bool GLSurfaceGLX::HasGLXExtension(const char* name) { return extensions.find(delimited_name) != std::string::npos; } +// static bool GLSurfaceGLX::IsCreateContextRobustnessSupported() { return g_glx_create_context_robustness_supported; } @@ -142,6 +145,15 @@ void* NativeViewGLSurfaceGLX::GetHandle() { return reinterpret_cast<void*>(window_); } +std::string NativeViewGLSurfaceGLX::GetExtensions() { + std::string extensions = GLSurface::GetExtensions(); + if (g_GLX_MESA_copy_sub_buffer) { + extensions += extensions.empty() ? "" : " "; + extensions += "GL_CHROMIUM_post_sub_buffer"; + } + return extensions; +} + void* NativeViewGLSurfaceGLX::GetConfig() { if (!config_) { // This code path is expensive, but we only take it when @@ -203,13 +215,9 @@ void* NativeViewGLSurfaceGLX::GetConfig() { return config_; } -bool NativeViewGLSurfaceGLX::SupportsPostSubBuffer() { - return g_GLX_MESA_copy_sub_buffer; -} - bool NativeViewGLSurfaceGLX::PostSubBuffer( int x, int y, int width, int height) { - DCHECK(SupportsPostSubBuffer()); + DCHECK(g_GLX_MESA_copy_sub_buffer); glXCopySubBufferMESA(g_display, window_, x, y, width, height); return true; } diff --git a/ui/gfx/gl/gl_surface_glx.h b/ui/gfx/gl/gl_surface_glx.h index f880b66..d54260f 100644 --- a/ui/gfx/gl/gl_surface_glx.h +++ b/ui/gfx/gl/gl_surface_glx.h @@ -52,8 +52,8 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { virtual bool SwapBuffers(); virtual gfx::Size GetSize(); virtual void* GetHandle(); + virtual std::string GetExtensions(); virtual void* GetConfig(); - virtual bool SupportsPostSubBuffer(); virtual bool PostSubBuffer(int x, int y, int width, int height); protected: diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc index a1c8fef..89d7683c 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc @@ -335,7 +335,7 @@ void WebGraphicsContext3DInProcessImpl::prepareTexture() { void WebGraphicsContext3DInProcessImpl::postSubBufferCHROMIUM( int x, int y, int width, int height) { - DCHECK(gl_surface_->SupportsPostSubBuffer()); + DCHECK(gl_context_->HasExtension("GL_CHROMIUM_post_sub_buffer")); gl_surface_->PostSubBuffer(x, y, width, height); } |