Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: content/renderer/gpu/compositor_output_surface.cc

Issue 10798006: Implement WebCompositorOutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/gpu/compositor_output_surface.h"
6
7 #include "base/message_loop_proxy.h"
8 #include "content/common/view_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "ipc/ipc_forwarding_message_filter.h"
11 #include "ipc/ipc_sync_channel.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput SurfaceClient.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
14
15 using WebKit::WebGraphicsContext3D;
16
17 //------------------------------------------------------------------------------
18
19 // static
20 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter(
21 base::TaskRunner* target_task_runner)
22 {
23 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID};
24 return new IPC::ForwardingMessageFilter(
25 messages_to_filter, arraysize(messages_to_filter),
26 target_task_runner);
27 }
28
29 CompositorOutputSurface::CompositorOutputSurface(
30 int32 routing_id,
31 WebGraphicsContext3D* context3D)
32 : output_surface_filter_(
33 RenderThreadImpl::current()->compositor_output_surface_filter())
34 , client_(NULL)
35 , routing_id_(routing_id)
36 , context3D_(context3D) {
37 DCHECK(output_surface_filter_);
38 capabilities_.hasParentCompositor = false;
39 DetachFromThread();
40 }
41
42 CompositorOutputSurface::~CompositorOutputSurface() {
43 DCHECK(CalledOnValidThread());
44 if (!client_)
45 return;
46 output_surface_filter_->RemoveRoute(routing_id_);
47 }
48
49 const WebKit::WebCompositorOutputSurface::Capabilities&
50 CompositorOutputSurface::capabilities() const {
51 DCHECK(CalledOnValidThread());
52 return capabilities_;
53 }
54
55 bool CompositorOutputSurface::bindToClient(
56 WebKit::WebCompositorOutputSurfaceClient* client) {
57 DCHECK(CalledOnValidThread());
58 DCHECK(!client_);
59 if (!context3D_->makeContextCurrent())
60 return false;
61
62 client_ = client;
63
64 output_surface_filter_->AddRoute(
65 routing_id_,
66 base::Bind(&CompositorOutputSurface::OnMessageReceived,
67 base::Unretained(this)));
68
69 return true;
70 }
71
72 WebGraphicsContext3D* CompositorOutputSurface::context3D() const {
73 DCHECK(CalledOnValidThread());
74 return context3D_.get();
75 }
76
77 void CompositorOutputSurface::sendFrameToParentCompositor(
78 const WebKit::WebCompositorFrame&) {
79 DCHECK(CalledOnValidThread());
80 NOTREACHED();
81 }
82
83 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
84 DCHECK(CalledOnValidThread());
85 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
86 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
87 IPC_END_MESSAGE_MAP()
88 }
89
90 void CompositorOutputSurface::OnUpdateVSyncParameters(
91 base::TimeTicks timebase,
92 base::TimeDelta interval) {
93 DCHECK(CalledOnValidThread());
94 DCHECK(client_);
95 double monotonicTimebase = timebase.ToInternalValue() /
96 static_cast<double>(base::Time::kMicrosecondsPerSecond);
97 double intervalInSeconds = interval.ToInternalValue() /
98 static_cast<double>(base::Time::kMicrosecondsPerSecond);
99 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);
100 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_output_surface.h ('k') | content/renderer/gpu/compositor_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698