diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-06 00:00:07 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-06 00:00:07 +0000 |
commit | 5aa6a312dc935c3392e025e97daded48f5363a05 (patch) | |
tree | 2c1a286841459eba6b8b38528e2a18057f03c9d4 /chrome/renderer/ggl | |
parent | 7bc4b5d06145e8753fdc8b2db04a5fb20ab86299 (diff) | |
download | chromium_src-5aa6a312dc935c3392e025e97daded48f5363a05.zip chromium_src-5aa6a312dc935c3392e025e97daded48f5363a05.tar.gz chromium_src-5aa6a312dc935c3392e025e97daded48f5363a05.tar.bz2 |
Reland r65152 with mac and linux fix.
Original review URL: http://codereview.chromium.org/3531008
TEST=try, ui_tests
BUG=none
Review URL: http://codereview.chromium.org/4545003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/ggl')
-rw-r--r-- | chrome/renderer/ggl/ggl.cc | 50 | ||||
-rw-r--r-- | chrome/renderer/ggl/ggl.h | 18 |
2 files changed, 37 insertions, 31 deletions
diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc index 0589852..cfe6743 100644 --- a/chrome/renderer/ggl/ggl.cc +++ b/chrome/renderer/ggl/ggl.cc @@ -6,7 +6,6 @@ #include "base/ref_counted.h" #include "base/singleton.h" -#include "base/thread_local.h" #include "base/weak_ptr.h" #include "chrome/renderer/command_buffer_proxy.h" #include "chrome/renderer/ggl/ggl.h" @@ -35,8 +34,6 @@ const int32 kCommandBufferSize = 1024 * 1024; // creation attributes. const int32 kTransferBufferSize = 1024 * 1024; -base::ThreadLocalPointer<Context> g_current_context; - // Singleton used to initialize and terminate the gles2 library. class GLES2Initializer { public: @@ -77,7 +74,7 @@ class Context : public base::SupportsWeakPtr<Context> { // Provides a callback that will be invoked when SwapBuffers has completed // service side. - void SetSwapBuffersCallback(Callback1<Context*>::Type* callback) { + void SetSwapBuffersCallback(Callback0::Type* callback) { swap_buffers_callback_.reset(callback); } @@ -117,17 +114,22 @@ class Context : public base::SupportsWeakPtr<Context> { // TODO(gman): Remove this. void DisableShaderTranslation(); + gpu::gles2::GLES2Implementation* gles2_implementation() const { + return gles2_implementation_; + } private: void OnSwapBuffers(); scoped_refptr<GpuChannelHost> channel_; base::WeakPtr<Context> parent_; - scoped_ptr<Callback1<Context*>::Type> swap_buffers_callback_; + scoped_ptr<Callback0::Type> swap_buffers_callback_; uint32 parent_texture_id_; CommandBufferProxy* command_buffer_; gpu::gles2::GLES2CmdHelper* gles2_helper_; int32 transfer_buffer_id_; gpu::gles2::GLES2Implementation* gles2_implementation_; + gfx::Size size_; + Error last_error_; DISALLOW_COPY_AND_ASSIGN(Context); @@ -262,19 +264,25 @@ bool Context::Initialize(gfx::NativeViewId view, transfer_buffer_id_, false); + size_ = size; + return true; } #if defined(OS_MACOSX) void Context::ResizeOnscreen(const gfx::Size& size) { DCHECK(size.width() > 0 && size.height() > 0); + size_ = size; command_buffer_->SetWindowSize(size); } #endif void Context::ResizeOffscreen(const gfx::Size& size) { DCHECK(size.width() > 0 && size.height() > 0); - command_buffer_->ResizeOffscreenFrameBuffer(size); + if (size_ != size) { + command_buffer_->ResizeOffscreenFrameBuffer(size); + size_ = size; + } } uint32 Context::CreateParentTexture(const gfx::Size& size) const { @@ -343,7 +351,6 @@ void Context::Destroy() { } bool Context::MakeCurrent(Context* context) { - g_current_context.Set(context); if (context) { gles2::SetGLContext(context->gles2_implementation_); @@ -405,7 +412,7 @@ void Context::DisableShaderTranslation() { void Context::OnSwapBuffers() { if (swap_buffers_callback_.get()) - swap_buffers_callback_->Run(this); + swap_buffers_callback_->Run(); } #endif // ENABLE_GPU @@ -480,7 +487,7 @@ void DeleteParentTexture(Context* context, uint32 texture) { } void SetSwapBuffersCallback(Context* context, - Callback1<Context*>::Type* callback) { + Callback0::Type* callback) { #if defined(ENABLE_GPU) context->SetSwapBuffersCallback(callback); #endif @@ -494,14 +501,6 @@ bool MakeCurrent(Context* context) { #endif } -Context* GetCurrentContext() { -#if defined(ENABLE_GPU) - return g_current_context.Get(); -#else - return NULL; -#endif -} - bool SwapBuffers(Context* context) { #if defined(ENABLE_GPU) if (!context) @@ -518,9 +517,6 @@ bool DestroyContext(Context* context) { if (!context) return false; - if (context == GetCurrentContext()) - MakeCurrent(NULL); - delete context; return true; #else @@ -537,12 +533,8 @@ media::VideoDecodeContext* CreateVideoDecodeContext( return context->CreateVideoDecodeContext(message_loop, hardware_decoder); } -Error GetError() { +Error GetError(Context* context) { #if defined(ENABLE_GPU) - Context* context = GetCurrentContext(); - if (!context) - return BAD_CONTEXT; - return context->GetError(); #else return NOT_INITIALIZED; @@ -557,4 +549,12 @@ void DisableShaderTranslation(Context* context) { } #endif } + +gpu::gles2::GLES2Implementation* GetImplementation(Context* context) { + if (!context) + return NULL; + + return context->gles2_implementation(); +} + } // namespace ggl diff --git a/chrome/renderer/ggl/ggl.h b/chrome/renderer/ggl/ggl.h index 1d53f57..54a7f8e 100644 --- a/chrome/renderer/ggl/ggl.h +++ b/chrome/renderer/ggl/ggl.h @@ -18,6 +18,12 @@ class GpuChannelHost; class MessageLoop; +namespace gpu { +namespace gles2 { +class GLES2Implementation; +} +} + namespace media { class VideoDecodeContext; class VideoDecodeEngine; @@ -120,15 +126,11 @@ void DeleteParentTexture(Context* context, uint32 texture); // Provides a callback that will be invoked when SwapBuffers has completed // service side. -void SetSwapBuffersCallback(Context* context, - Callback1<Context*>::Type* callback); +void SetSwapBuffersCallback(Context* context, Callback0::Type* callback); // Set the current GGL context for the calling thread. bool MakeCurrent(Context* context); -// Get the calling thread's current GGL context. -Context* GetCurrentContext(); - // For a view context, display everything that has been rendered since the // last call. For an offscreen context, resolve everything that has been // rendered since the last call to a copy that can be accessed by the parent @@ -153,8 +155,12 @@ media::VideoDecodeContext* CreateVideoDecodeContext(Context* context, // TODO(gman): Remove this void DisableShaderTranslation(Context* context); +// Allows direct access to the GLES2 implementation so a context +// can be used without making it current. +gpu::gles2::GLES2Implementation* GetImplementation(Context* context); + // Return the current GGL error. -Error GetError(); +Error GetError(Context* context); } // namespace ggl |