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 "cc/compositor_frame.h" | 8 #include "cc/compositor_frame.h" |
9 #include "cc/output_surface_client.h" | 9 #include "cc/output_surface_client.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 29 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
30 return new IPC::ForwardingMessageFilter( | 30 return new IPC::ForwardingMessageFilter( |
31 messages_to_filter, arraysize(messages_to_filter), | 31 messages_to_filter, arraysize(messages_to_filter), |
32 target_task_runner); | 32 target_task_runner); |
33 } | 33 } |
34 | 34 |
35 CompositorOutputSurface::CompositorOutputSurface( | 35 CompositorOutputSurface::CompositorOutputSurface( |
36 int32 routing_id, | 36 int32 routing_id, |
37 WebGraphicsContext3D* context3D, | 37 WebGraphicsContext3D* context3D, |
38 cc::SoftwareOutputDevice* software_device) | 38 cc::SoftwareOutputDevice* software_device) |
39 : output_surface_filter_( | 39 : OutputSurfaceImpl(make_scoped_ptr(context3D), |
| 40 make_scoped_ptr(software_device)), |
| 41 output_surface_filter_( |
40 RenderThreadImpl::current()->compositor_output_surface_filter()), | 42 RenderThreadImpl::current()->compositor_output_surface_filter()), |
41 client_(NULL), | 43 routing_id_(routing_id) { |
42 routing_id_(routing_id), | |
43 context3D_(context3D), | |
44 software_device_(software_device) { | |
45 DCHECK(output_surface_filter_); | 44 DCHECK(output_surface_filter_); |
46 capabilities_.has_parent_compositor = false; | 45 capabilities_.has_parent_compositor = false; |
47 DetachFromThread(); | 46 DetachFromThread(); |
48 } | 47 } |
49 | 48 |
50 CompositorOutputSurface::~CompositorOutputSurface() { | 49 CompositorOutputSurface::~CompositorOutputSurface() { |
51 DCHECK(CalledOnValidThread()); | 50 DCHECK(CalledOnValidThread()); |
52 if (!client_) | 51 if (!client_) |
53 return; | 52 return; |
54 output_surface_proxy_->ClearOutputSurface(); | 53 output_surface_proxy_->ClearOutputSurface(); |
55 output_surface_filter_->RemoveRoute(routing_id_); | 54 output_surface_filter_->RemoveRoute(routing_id_); |
56 } | 55 } |
57 | 56 |
58 const struct cc::OutputSurface::Capabilities& | 57 const struct cc::OutputSurface::Capabilities& |
59 CompositorOutputSurface::Capabilities() const { | 58 CompositorOutputSurface::Capabilities() const { |
60 DCHECK(CalledOnValidThread()); | 59 DCHECK(CalledOnValidThread()); |
61 return capabilities_; | 60 return capabilities_; |
62 } | 61 } |
63 | 62 |
64 bool CompositorOutputSurface::BindToClient( | 63 bool CompositorOutputSurface::BindToClient( |
65 cc::OutputSurfaceClient* client) { | 64 cc::OutputSurfaceClient* client) { |
66 DCHECK(CalledOnValidThread()); | 65 DCHECK(CalledOnValidThread()); |
67 DCHECK(!client_); | |
68 if (context3D_.get()) { | |
69 if (!context3D_->makeContextCurrent()) | |
70 return false; | |
71 } | |
72 | 66 |
73 client_ = client; | 67 if (!cc::OutputSurfaceImpl::BindToClient(client)) |
| 68 return false; |
74 | 69 |
75 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); | 70 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); |
76 output_surface_filter_->AddRoute( | 71 output_surface_filter_->AddRoute( |
77 routing_id_, | 72 routing_id_, |
78 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, | 73 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, |
79 output_surface_proxy_)); | 74 output_surface_proxy_)); |
80 | 75 |
81 return true; | 76 return true; |
82 } | 77 } |
83 | 78 |
84 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { | 79 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { |
85 DCHECK(CalledOnValidThread()); | 80 DCHECK(CalledOnValidThread()); |
86 return context3D_.get(); | 81 return context3d_.get(); |
87 } | 82 } |
88 | 83 |
89 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { | 84 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { |
| 85 DCHECK(CalledOnValidThread()); |
90 return software_device_.get(); | 86 return software_device_.get(); |
91 } | 87 } |
92 | 88 |
93 void CompositorOutputSurface::SendFrameToParentCompositor( | 89 void CompositorOutputSurface::SendFrameToParentCompositor( |
94 cc::CompositorFrame* frame) { | 90 cc::CompositorFrame* frame) { |
95 DCHECK(CalledOnValidThread()); | 91 DCHECK(CalledOnValidThread()); |
96 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); | 92 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); |
97 } | 93 } |
98 | 94 |
99 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 95 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
(...skipping 10 matching lines...) Expand all Loading... |
110 DCHECK(CalledOnValidThread()); | 106 DCHECK(CalledOnValidThread()); |
111 DCHECK(client_); | 107 DCHECK(client_); |
112 client_->OnVSyncParametersChanged(timebase, interval); | 108 client_->OnVSyncParametersChanged(timebase, interval); |
113 } | 109 } |
114 | 110 |
115 bool CompositorOutputSurface::Send(IPC::Message* message) { | 111 bool CompositorOutputSurface::Send(IPC::Message* message) { |
116 return ChildThread::current()->sync_message_filter()->Send(message); | 112 return ChildThread::current()->sync_message_filter()->Send(message); |
117 } | 113 } |
118 | 114 |
119 } // namespace content | 115 } // namespace content |
OLD | NEW |