diff options
Diffstat (limited to 'content/renderer/gpu')
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.cc | 30 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.h | 15 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 13 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.h | 10 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc | 12 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h | 5 |
6 files changed, 43 insertions, 42 deletions
diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc index 907eb072..e1f9a66 100644 --- a/content/renderer/gpu/command_buffer_proxy.cc +++ b/content/renderer/gpu/command_buffer_proxy.cc @@ -73,22 +73,23 @@ void CommandBufferProxy::OnDestroyed(gpu::error::ContextLostReason reason) { last_state_.error = gpu::error::kLostContext; last_state_.context_lost_reason = reason; - if (channel_error_callback_.get()) { - channel_error_callback_->Run(); + if (!channel_error_callback_.is_null()) { + channel_error_callback_.Run(); // Avoid calling the error callback more than once. - channel_error_callback_.reset(); + channel_error_callback_.Reset(); } } void CommandBufferProxy::OnEchoAck() { DCHECK(!echo_tasks_.empty()); - Task* task = echo_tasks_.front().release(); + base::Closure callback = echo_tasks_.front(); echo_tasks_.pop(); - task->Run(); + callback.Run(); } -void CommandBufferProxy::SetChannelErrorCallback(Callback0::Type* callback) { - channel_error_callback_.reset(callback); +void CommandBufferProxy::SetChannelErrorCallback( + const base::Closure& callback) { + channel_error_callback_ = callback; } bool CommandBufferProxy::Initialize(int32 size) { @@ -335,9 +336,10 @@ void CommandBufferProxy::SetToken(int32 token) { } void CommandBufferProxy::OnNotifyRepaint() { - if (notify_repaint_task_.get()) + if (!notify_repaint_task_.is_null()) MessageLoop::current()->PostNonNestableTask( - FROM_HERE, notify_repaint_task_.release()); + FROM_HERE, notify_repaint_task_); + notify_repaint_task_.Reset(); } void CommandBufferProxy::SetParseError( @@ -352,18 +354,16 @@ void CommandBufferProxy::SetContextLostReason( NOTREACHED(); } -bool CommandBufferProxy::Echo(Task* task) { +bool CommandBufferProxy::Echo(const base::Closure& callback) { if (last_state_.error != gpu::error::kNoError) { - delete task; return false; } if (!Send(new GpuChannelMsg_Echo(GpuCommandBufferMsg_EchoAck(route_id_)))) { - delete task; return false; } - echo_tasks_.push(linked_ptr<Task>(task)); + echo_tasks_.push(callback); return true; } @@ -395,8 +395,8 @@ bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, return result; } -void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { - notify_repaint_task_.reset(task); +void CommandBufferProxy::SetNotifyRepaintTask(const base::Closure& task) { + notify_repaint_task_ = task; } scoped_refptr<GpuVideoDecodeAcceleratorHost> diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h index 52cc471..efb89fe 100644 --- a/content/renderer/gpu/command_buffer_proxy.h +++ b/content/renderer/gpu/command_buffer_proxy.h @@ -11,7 +11,7 @@ #include <map> #include <queue> -#include "base/callback_old.h" +#include "base/callback.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -31,7 +31,6 @@ class Size; class GpuChannelHost; class PluginChannelHost; -class Task; // Client side proxy that forwards messages synchronously to a // CommandBufferStub. @@ -69,7 +68,7 @@ class CommandBufferProxy : public gpu::CommandBuffer, // Invoke the task when the channel has been flushed. Takes care of deleting // the task whether the echo succeeds or not. - bool Echo(Task* task); + bool Echo(const base::Closure& callback); // Reparent a command buffer. TODO(apatrick): going forward, the notion of // the parent / child relationship between command buffers is going away in @@ -78,11 +77,11 @@ class CommandBufferProxy : public gpu::CommandBuffer, virtual bool SetParent(CommandBufferProxy* parent_command_buffer, uint32 parent_texture_id); - void SetChannelErrorCallback(Callback0::Type* callback); + void SetChannelErrorCallback(const base::Closure& callback); // Set a task that will be invoked the next time the window becomes invalid // and needs to be repainted. Takes ownership of task. - void SetNotifyRepaintTask(Task* task); + void SetNotifyRepaintTask(const base::Closure& callback); // Sends an IPC message to create a GpuVideoDecodeAccelerator. Creates and // returns a pointer to a GpuVideoDecodeAcceleratorHost. @@ -130,11 +129,11 @@ class CommandBufferProxy : public gpu::CommandBuffer, unsigned int flush_count_; // Tasks to be invoked in echo responses. - std::queue<linked_ptr<Task> > echo_tasks_; + std::queue<base::Closure> echo_tasks_; - scoped_ptr<Task> notify_repaint_task_; + base::Closure notify_repaint_task_; - scoped_ptr<Callback0::Type> channel_error_callback_; + base::Closure channel_error_callback_; DISALLOW_COPY_AND_ASSIGN(CommandBufferProxy); }; diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index af93c92..2611ec9 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -4,6 +4,7 @@ #include "content/renderer/gpu/renderer_gl_context.h" +#include "base/bind.h" #include "base/debug/trace_event.h" #include "base/lazy_instance.h" #include "base/memory/ref_counted.h" @@ -192,8 +193,8 @@ void RendererGLContext::DeleteParentTexture(uint32 texture) { } void RendererGLContext::SetContextLostCallback( - Callback1<ContextLostReason>::Type* callback) { - context_lost_callback_.reset(callback); + const base::Callback<void (ContextLostReason)>& callback) { + context_lost_callback_ = callback; } bool RendererGLContext::MakeCurrent(RendererGLContext* context) { @@ -229,7 +230,7 @@ bool RendererGLContext::SwapBuffers() { return true; } -bool RendererGLContext::Echo(Task* task) { +bool RendererGLContext::Echo(const base::Closure& task) { return command_buffer_->Echo(task); } @@ -371,7 +372,7 @@ bool RendererGLContext::Initialize(bool onscreen, } command_buffer_->SetChannelErrorCallback( - NewCallback(this, &RendererGLContext::OnContextLost)); + base::Bind(&RendererGLContext::OnContextLost, base::Unretained(this))); // Create the GLES2 helper, which writes the command buffer protocol. gles2_helper_ = new gpu::gles2::GLES2CmdHelper(command_buffer_); @@ -446,12 +447,12 @@ void RendererGLContext::Destroy() { } void RendererGLContext::OnContextLost() { - if (context_lost_callback_.get()) { + if (!context_lost_callback_.is_null()) { RendererGLContext::ContextLostReason reason = kUnknown; if (command_buffer_) { reason = ConvertReason( command_buffer_->GetLastState().context_lost_reason); } - context_lost_callback_->Run(reason); + context_lost_callback_.Run(reason); } } diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index 8b04fd2..37da68d 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -10,7 +10,7 @@ #define CONTENT_RENDERER_GPU_RENDERER_GL_CONTEXT_H_ #pragma once -#include "base/callback_old.h" +#include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -22,7 +22,6 @@ class GpuChannelHost; class CommandBufferProxy; class GURL; -class Task; class TransportTextureHost; namespace gpu { @@ -142,7 +141,8 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, // Deletes a texture in the parent's RendererGLContext. void DeleteParentTexture(uint32 texture); - void SetContextLostCallback(Callback1<ContextLostReason>::Type* callback); + void SetContextLostCallback( + const base::Callback<void(ContextLostReason)>& callback); // Set the current RendererGLContext for the calling thread. static bool MakeCurrent(RendererGLContext* context); @@ -155,7 +155,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, // Run the task once the channel has been flushed. Takes care of deleting the // task whether the echo succeeds or not. - bool Echo(Task* task); + bool Echo(const base::Closure& task); // Create a TransportTextureHost object associated with the context. scoped_refptr<TransportTextureHost> CreateTransportTextureHost(); @@ -192,7 +192,7 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext>, scoped_refptr<GpuChannelHost> channel_; base::WeakPtr<RendererGLContext> parent_; - scoped_ptr<Callback1<ContextLostReason>::Type> context_lost_callback_; + base::Callback<void(ContextLostReason)> context_lost_callback_; uint32 parent_texture_id_; CommandBufferProxy* command_buffer_; gpu::gles2::GLES2CmdHelper* gles2_helper_; diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index da50f0c..29a368a 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -15,6 +15,7 @@ #include <algorithm> #include <set> +#include "base/bind.h" #include "base/lazy_instance.h" #include "base/string_tokenizer.h" #include "base/command_line.h" @@ -52,7 +53,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() cached_width_(0), cached_height_(0), bound_fbo_(0), - method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { + weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } WebGraphicsContext3DCommandBufferImpl:: @@ -174,8 +175,8 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); context_->SetContextLostCallback( - NewCallback(this, - &WebGraphicsContext3DCommandBufferImpl::OnContextLost)); + base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, + weak_ptr_factory_.GetWeakPtr())); // TODO(gman): Remove this. const CommandLine& command_line = *CommandLine::ForCurrentProcess(); @@ -245,8 +246,9 @@ void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { if (renderview) renderview->OnViewContextSwapBuffersPosted(); context_->SwapBuffers(); - context_->Echo(method_factory_.NewRunnableMethod( - &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete)); + context_->Echo(base::Bind( + &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, + weak_ptr_factory_.GetWeakPtr())); #if defined(OS_MACOSX) // It appears that making the compositor's on-screen context current on // other platforms implies this flush. TODO(kbr): this means that the diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h index 48e7d9a..c1265f1 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h @@ -11,7 +11,7 @@ #include <vector> #include "base/memory/scoped_ptr.h" -#include "base/task.h" +#include "base/memory/weak_ptr.h" #include "content/renderer/gpu/renderer_gl_context.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.h" @@ -487,8 +487,7 @@ class WebGraphicsContext3DCommandBufferImpl // Errors raised by synthesizeGLError(). std::vector<WGC3Denum> synthetic_errors_; - ScopedRunnableMethodFactory<WebGraphicsContext3DCommandBufferImpl> - method_factory_; + base::WeakPtrFactory<WebGraphicsContext3DCommandBufferImpl> weak_ptr_factory_; #ifdef FLIP_FRAMEBUFFER_VERTICALLY scoped_array<uint8> scanline_; |