OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/gpu/compositor_output_surface.h" | 5 #include "content/renderer/gpu/compositor_output_surface.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
10 #include "ipc/ipc_forwarding_message_filter.h" | 10 #include "ipc/ipc_forwarding_message_filter.h" |
11 #include "ipc/ipc_sync_channel.h" | 11 #include "ipc/ipc_sync_channel.h" |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput SurfaceClient.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" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" |
14 | 14 |
15 using WebKit::WebGraphicsContext3D; | 15 using WebKit::WebGraphicsContext3D; |
16 using WebKit::WebCompositorOutputSurfaceSoftware; | |
16 | 17 |
17 //------------------------------------------------------------------------------ | 18 //------------------------------------------------------------------------------ |
18 | 19 |
19 // static | 20 // static |
20 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( | 21 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( |
21 base::TaskRunner* target_task_runner) | 22 base::TaskRunner* target_task_runner) |
22 { | 23 { |
23 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 24 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
24 return new IPC::ForwardingMessageFilter( | 25 return new IPC::ForwardingMessageFilter( |
25 messages_to_filter, arraysize(messages_to_filter), | 26 messages_to_filter, arraysize(messages_to_filter), |
26 target_task_runner); | 27 target_task_runner); |
27 } | 28 } |
28 | 29 |
29 CompositorOutputSurface::CompositorOutputSurface( | 30 CompositorOutputSurface::CompositorOutputSurface( |
30 int32 routing_id, | 31 int32 routing_id, |
31 WebGraphicsContext3D* context3D) | 32 WebGraphicsContext3D* context3D, |
33 WebCompositorOutputSurfaceSoftware* surfaceSoftware) | |
piman
2012/08/29 00:21:51
still nit: surface_software
| |
32 : output_surface_filter_( | 34 : output_surface_filter_( |
33 RenderThreadImpl::current()->compositor_output_surface_filter()) | 35 RenderThreadImpl::current()->compositor_output_surface_filter()), |
34 , client_(NULL) | 36 client_(NULL), |
35 , routing_id_(routing_id) | 37 routing_id_(routing_id), |
36 , context3D_(context3D) { | 38 context3D_(context3D), |
39 surface_software_(surfaceSoftware) { | |
37 DCHECK(output_surface_filter_); | 40 DCHECK(output_surface_filter_); |
38 capabilities_.hasParentCompositor = false; | 41 capabilities_.hasParentCompositor = false; |
39 DetachFromThread(); | 42 DetachFromThread(); |
40 } | 43 } |
41 | 44 |
42 CompositorOutputSurface::~CompositorOutputSurface() { | 45 CompositorOutputSurface::~CompositorOutputSurface() { |
43 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
44 if (!client_) | 47 if (!client_) |
45 return; | 48 return; |
46 output_surface_filter_->RemoveRoute(routing_id_); | 49 output_surface_filter_->RemoveRoute(routing_id_); |
47 } | 50 } |
48 | 51 |
49 const WebKit::WebCompositorOutputSurface::Capabilities& | 52 const WebKit::WebCompositorOutputSurface::Capabilities& |
50 CompositorOutputSurface::capabilities() const { | 53 CompositorOutputSurface::capabilities() const { |
51 DCHECK(CalledOnValidThread()); | 54 DCHECK(CalledOnValidThread()); |
52 return capabilities_; | 55 return capabilities_; |
53 } | 56 } |
54 | 57 |
55 bool CompositorOutputSurface::bindToClient( | 58 bool CompositorOutputSurface::bindToClient( |
56 WebKit::WebCompositorOutputSurfaceClient* client) { | 59 WebKit::WebCompositorOutputSurfaceClient* client) { |
57 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
58 DCHECK(!client_); | 61 DCHECK(!client_); |
59 if (!context3D_->makeContextCurrent()) | 62 if (context3D_.get()) { |
60 return false; | 63 if (!context3D_->makeContextCurrent()) |
64 return false; | |
65 } | |
61 | 66 |
62 client_ = client; | 67 client_ = client; |
63 | 68 |
64 output_surface_filter_->AddRoute( | 69 output_surface_filter_->AddRoute( |
65 routing_id_, | 70 routing_id_, |
66 base::Bind(&CompositorOutputSurface::OnMessageReceived, | 71 base::Bind(&CompositorOutputSurface::OnMessageReceived, |
67 base::Unretained(this))); | 72 base::Unretained(this))); |
68 | 73 |
69 return true; | 74 return true; |
70 } | 75 } |
71 | 76 |
72 WebGraphicsContext3D* CompositorOutputSurface::context3D() const { | 77 WebGraphicsContext3D* CompositorOutputSurface::context3D() const { |
73 DCHECK(CalledOnValidThread()); | 78 DCHECK(CalledOnValidThread()); |
74 return context3D_.get(); | 79 return context3D_.get(); |
75 } | 80 } |
76 | 81 |
82 WebCompositorOutputSurfaceSoftware* CompositorOutputSurface::surfaceSoftware() | |
83 const { | |
84 return surface_software_.get(); | |
85 } | |
86 | |
77 void CompositorOutputSurface::sendFrameToParentCompositor( | 87 void CompositorOutputSurface::sendFrameToParentCompositor( |
78 const WebKit::WebCompositorFrame&) { | 88 const WebKit::WebCompositorFrame&) { |
79 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
80 NOTREACHED(); | 90 NOTREACHED(); |
81 } | 91 } |
82 | 92 |
83 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 93 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
84 DCHECK(CalledOnValidThread()); | 94 DCHECK(CalledOnValidThread()); |
85 if (!client_) | 95 if (!client_) |
86 return; | 96 return; |
87 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) | 97 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) |
88 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); | 98 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); |
89 IPC_END_MESSAGE_MAP() | 99 IPC_END_MESSAGE_MAP() |
90 } | 100 } |
91 | 101 |
92 void CompositorOutputSurface::OnUpdateVSyncParameters( | 102 void CompositorOutputSurface::OnUpdateVSyncParameters( |
93 base::TimeTicks timebase, | 103 base::TimeTicks timebase, |
94 base::TimeDelta interval) { | 104 base::TimeDelta interval) { |
95 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
96 DCHECK(client_); | 106 DCHECK(client_); |
97 double monotonicTimebase = timebase.ToInternalValue() / | 107 double monotonicTimebase = timebase.ToInternalValue() / |
98 static_cast<double>(base::Time::kMicrosecondsPerSecond); | 108 static_cast<double>(base::Time::kMicrosecondsPerSecond); |
99 double intervalInSeconds = interval.ToInternalValue() / | 109 double intervalInSeconds = interval.ToInternalValue() / |
100 static_cast<double>(base::Time::kMicrosecondsPerSecond); | 110 static_cast<double>(base::Time::kMicrosecondsPerSecond); |
101 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); | 111 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds); |
102 } | 112 } |
OLD | NEW |