Chromium Code Reviews| Index: content/renderer/gpu/compositor_output_surface.cc |
| diff --git a/content/renderer/gpu/compositor_output_surface.cc b/content/renderer/gpu/compositor_output_surface.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10e71ac6e3781e9f6ee2547c27db2ca645ab8302 |
| --- /dev/null |
| +++ b/content/renderer/gpu/compositor_output_surface.cc |
| @@ -0,0 +1,92 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/renderer/gpu/compositor_output_surface.h" |
| + |
| +#include "base/message_loop_proxy.h" |
| +#include "content/common/view_messages.h" |
| +#include "content/renderer/render_thread_impl.h" |
| +#include "ipc/ipc_forwarding_message_filter.h" |
| +#include "ipc/ipc_sync_channel.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurfaceClient.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h" |
| + |
| +using WebKit::WebGraphicsContext3D; |
| + |
| +//------------------------------------------------------------------------------ |
| + |
| +// static |
| +IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
| + base::TaskRunner* target_task_runner) |
| +{ |
| + uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
| + return new IPC::ForwardingMessageFilter( |
| + messages_to_filter, arraysize(messages_to_filter), |
| + target_task_runner); |
| +} |
| + |
| +CompositorOutputSurface::CompositorOutputSurface( |
| + int32 routing_id, |
| + WebGraphicsContext3D* context3D) |
| + : output_surface_filter_( |
| + RenderThreadImpl::current()->compositor_output_surface_filter()) |
| + , client_(NULL) |
|
piman
2012/08/08 16:47:43
nit: initializer style
Class::Class(...)
: ini
|
| + , routing_id_(routing_id) |
| + , context3D_(context3D) { |
| + capabilities_.hasParentCompositor = false; |
|
piman
2012/08/08 16:47:43
Could you add a DCHECK(output_surface_filter_) to
|
| +} |
| + |
| +CompositorOutputSurface::~CompositorOutputSurface() { |
| + if (!client_) |
| + return; |
| + output_surface_filter_-> |
|
jbates
2012/08/08 16:55:09
nit: no need for line wrap
|
| + RemoveRoute(routing_id_); |
|
piman
2012/08/08 16:47:43
nit: I think this line fits in 80 chars.
|
| +} |
| + |
| +const WebKit::WebCompositorOutputSurface::Capabilities& |
| + CompositorOutputSurface::capabilities() const { |
| + return capabilities_; |
| +} |
| + |
| +bool CompositorOutputSurface::bindToClient( |
| + WebKit::WebCompositorOutputSurfaceClient* client) { |
| + DCHECK(!client_); |
| + if (! context3D_->makeContextCurrent()) |
|
piman
2012/08/08 16:47:43
nit: no space after !
jbates
2012/08/08 16:55:09
nit: no space after !
|
| + return false; |
| + |
| + client_ = client; |
| + |
| + output_surface_filter_->AddRoute( |
| + routing_id_, |
| + base::Bind(&CompositorOutputSurface::OnMessageReceived, |
| + base::Unretained(this))); |
| + |
| + return true; |
| +} |
| + |
| +WebGraphicsContext3D* CompositorOutputSurface::context3D() const { |
| + return context3D_.get(); |
| +} |
| + |
| +void CompositorOutputSurface::sendFrameToParentCompositor( |
| + const WebKit::WebCompositorFrame&) { |
| + NOTREACHED(); |
| +} |
| + |
| +void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
| + IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
| + IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
|
jbates
2012/08/08 16:55:09
We're going to need the SwapAck here as well. Feel
|
| + IPC_END_MESSAGE_MAP() |
| +} |
| + |
| +void CompositorOutputSurface::OnUpdateVSyncParameters( |
| + base::TimeTicks timebase, |
| + base::TimeDelta interval) { |
| + DCHECK(client_); |
| + double monotonicTimebase = timebase.ToInternalValue() / |
| + static_cast<double>(base::Time::kMicrosecondsPerSecond); |
| + double intervalInSeconds = interval.ToInternalValue() / |
| + static_cast<double>(base::Time::kMicrosecondsPerSecond); |
| + client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); |
| +} |