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 29 matching lines...) Expand all Loading... |
40 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; | 40 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID}; |
41 return new IPC::ForwardingMessageFilter( | 41 return new IPC::ForwardingMessageFilter( |
42 messages_to_filter, arraysize(messages_to_filter), | 42 messages_to_filter, arraysize(messages_to_filter), |
43 target_task_runner); | 43 target_task_runner); |
44 } | 44 } |
45 | 45 |
46 CompositorOutputSurface::CompositorOutputSurface( | 46 CompositorOutputSurface::CompositorOutputSurface( |
47 int32 routing_id, | 47 int32 routing_id, |
48 WebGraphicsContext3D* context3D, | 48 WebGraphicsContext3D* context3D, |
49 cc::SoftwareOutputDevice* software_device) | 49 cc::SoftwareOutputDevice* software_device) |
50 : output_surface_filter_( | 50 : OutputSurface(make_scoped_ptr(context3D), |
| 51 make_scoped_ptr(software_device)), |
| 52 output_surface_filter_( |
51 RenderThreadImpl::current()->compositor_output_surface_filter()), | 53 RenderThreadImpl::current()->compositor_output_surface_filter()), |
52 client_(NULL), | |
53 routing_id_(routing_id), | 54 routing_id_(routing_id), |
54 context3D_(context3D), | |
55 software_device_(software_device), | |
56 prefers_smoothness_(false), | 55 prefers_smoothness_(false), |
57 main_thread_id_(base::PlatformThread::CurrentId()) { | 56 main_thread_id_(base::PlatformThread::CurrentId()) { |
58 DCHECK(output_surface_filter_); | 57 DCHECK(output_surface_filter_); |
59 capabilities_.has_parent_compositor = false; | 58 capabilities_.has_parent_compositor = false; |
60 DetachFromThread(); | 59 DetachFromThread(); |
61 } | 60 } |
62 | 61 |
63 CompositorOutputSurface::~CompositorOutputSurface() { | 62 CompositorOutputSurface::~CompositorOutputSurface() { |
64 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
65 if (!client_) | 64 if (!client_) |
66 return; | 65 return; |
67 UpdateSmoothnessTakesPriority(false); | 66 UpdateSmoothnessTakesPriority(false); |
68 output_surface_proxy_->ClearOutputSurface(); | 67 if (output_surface_proxy_) |
| 68 output_surface_proxy_->ClearOutputSurface(); |
69 output_surface_filter_->RemoveRoute(routing_id_); | 69 output_surface_filter_->RemoveRoute(routing_id_); |
70 } | 70 } |
71 | 71 |
72 const struct cc::OutputSurface::Capabilities& | |
73 CompositorOutputSurface::Capabilities() const { | |
74 DCHECK(CalledOnValidThread()); | |
75 return capabilities_; | |
76 } | |
77 | |
78 bool CompositorOutputSurface::BindToClient( | 72 bool CompositorOutputSurface::BindToClient( |
79 cc::OutputSurfaceClient* client) { | 73 cc::OutputSurfaceClient* client) { |
80 DCHECK(CalledOnValidThread()); | 74 DCHECK(CalledOnValidThread()); |
81 DCHECK(!client_); | |
82 if (context3D_.get()) { | |
83 if (!context3D_->makeContextCurrent()) | |
84 return false; | |
85 } | |
86 | 75 |
87 client_ = client; | 76 if (!cc::OutputSurface::BindToClient(client)) |
| 77 return false; |
88 | 78 |
89 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); | 79 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); |
90 output_surface_filter_->AddRoute( | 80 output_surface_filter_->AddRoute( |
91 routing_id_, | 81 routing_id_, |
92 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, | 82 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, |
93 output_surface_proxy_)); | 83 output_surface_proxy_)); |
94 | 84 |
95 return true; | 85 return true; |
96 } | 86 } |
97 | 87 |
98 WebGraphicsContext3D* CompositorOutputSurface::Context3D() const { | |
99 DCHECK(CalledOnValidThread()); | |
100 return context3D_.get(); | |
101 } | |
102 | |
103 cc::SoftwareOutputDevice* CompositorOutputSurface::SoftwareDevice() const { | |
104 return software_device_.get(); | |
105 } | |
106 | |
107 void CompositorOutputSurface::SendFrameToParentCompositor( | 88 void CompositorOutputSurface::SendFrameToParentCompositor( |
108 cc::CompositorFrame* frame) { | 89 cc::CompositorFrame* frame) { |
109 DCHECK(CalledOnValidThread()); | 90 DCHECK(CalledOnValidThread()); |
110 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); | 91 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); |
111 } | 92 } |
112 | 93 |
113 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { | 94 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { |
114 DCHECK(CalledOnValidThread()); | 95 DCHECK(CalledOnValidThread()); |
115 if (!client_) | 96 if (!client_) |
116 return; | 97 return; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // If this is the last surface to stop preferring smoothness, | 147 // If this is the last surface to stop preferring smoothness, |
167 // Reset the main thread's priority to the default. | 148 // Reset the main thread's priority to the default. |
168 if (prefers_smoothness_ == true && | 149 if (prefers_smoothness_ == true && |
169 --g_prefer_smoothness_count == 0) { | 150 --g_prefer_smoothness_count == 0) { |
170 SetThreadsPriorityToDefault(main_thread_id_); | 151 SetThreadsPriorityToDefault(main_thread_id_); |
171 } | 152 } |
172 prefers_smoothness_ = prefers_smoothness; | 153 prefers_smoothness_ = prefers_smoothness; |
173 } | 154 } |
174 | 155 |
175 } // namespace content | 156 } // namespace content |
OLD | NEW |