| Index: chrome/renderer/ggl/ggl.cc
|
| ===================================================================
|
| --- chrome/renderer/ggl/ggl.cc (revision 65093)
|
| +++ chrome/renderer/ggl/ggl.cc (working copy)
|
| @@ -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 @@
|
| // 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 @@
|
|
|
| // 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 @@
|
| // 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 @@
|
| 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 @@
|
| }
|
|
|
| bool Context::MakeCurrent(Context* context) {
|
| - g_current_context.Set(context);
|
| if (context) {
|
| gles2::SetGLContext(context->gles2_implementation_);
|
|
|
| @@ -405,7 +412,7 @@
|
|
|
| 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 SetSwapBuffersCallback(Context* context,
|
| - Callback1<Context*>::Type* callback) {
|
| + Callback0::Type* callback) {
|
| #if defined(ENABLE_GPU)
|
| context->SetSwapBuffersCallback(callback);
|
| #endif
|
| @@ -494,14 +501,6 @@
|
| #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 @@
|
| if (!context)
|
| return false;
|
|
|
| - if (context == GetCurrentContext())
|
| - MakeCurrent(NULL);
|
| -
|
| delete context;
|
| return true;
|
| #else
|
| @@ -537,12 +533,8 @@
|
| 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 @@
|
| }
|
| #endif
|
| }
|
| +
|
| +gpu::gles2::GLES2Implementation* GetImplementation(Context* context) {
|
| + if (!context)
|
| + return NULL;
|
| +
|
| + return context->gles2_implementation();
|
| +}
|
| +
|
| } // namespace ggl
|
|
|