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

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

Issue 15836005: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@nofrc
Patch Set: Ignore last patch set: bad upload. Created 7 years, 6 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
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 10 #include "cc/output/compositor_frame_ack.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 CommandLine* command_line = CommandLine::ForCurrentProcess(); 62 CommandLine* command_line = CommandLine::ForCurrentProcess();
63 capabilities_.has_parent_compositor = command_line->HasSwitch( 63 capabilities_.has_parent_compositor = command_line->HasSwitch(
64 switches::kEnableDelegatedRenderer); 64 switches::kEnableDelegatedRenderer);
65 DetachFromThread(); 65 DetachFromThread();
66 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); 66 message_sender_ = RenderThreadImpl::current()->sync_message_filter();
67 DCHECK(message_sender_.get()); 67 DCHECK(message_sender_.get());
68 } 68 }
69 69
70 CompositorOutputSurface::~CompositorOutputSurface() { 70 CompositorOutputSurface::~CompositorOutputSurface() {
71 DCHECK(CalledOnValidThread()); 71 DCHECK(CalledOnValidThread());
72 if (!client_) 72 if (!hasClient())
73 return; 73 return;
74 UpdateSmoothnessTakesPriority(false); 74 UpdateSmoothnessTakesPriority(false);
75 if (output_surface_proxy_.get()) 75 if (output_surface_proxy_.get())
76 output_surface_proxy_->ClearOutputSurface(); 76 output_surface_proxy_->ClearOutputSurface();
77 output_surface_filter_->RemoveRoute(routing_id_); 77 output_surface_filter_->RemoveRoute(routing_id_);
78 } 78 }
79 79
80 bool CompositorOutputSurface::BindToClient( 80 bool CompositorOutputSurface::BindToClient(
81 cc::OutputSurfaceClient* client) { 81 cc::OutputSurfaceClient* client) {
82 DCHECK(CalledOnValidThread()); 82 DCHECK(CalledOnValidThread());
83 83
84 if (!cc::OutputSurface::BindToClient(client)) 84 if (!cc::OutputSurface::BindToClient(client))
85 return false; 85 return false;
86 86
87 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); 87 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this);
88 output_surface_filter_->AddRoute( 88 output_surface_filter_->AddRoute(
89 routing_id_, 89 routing_id_,
90 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, 90 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived,
91 output_surface_proxy_)); 91 output_surface_proxy_));
92 92
93 return true; 93 return true;
94 } 94 }
95 95
96 void CompositorOutputSurface::SendFrameToParentCompositor( 96 void CompositorOutputSurface::SendFrameToParentCompositor(
97 cc::CompositorFrame* frame) { 97 cc::CompositorFrame* frame) {
98 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
99 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); 99 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame));
100 DidSwapBuffers();
100 } 101 }
101 102
102 void CompositorOutputSurface::SwapBuffers( 103 void CompositorOutputSurface::SwapBuffers(
103 const ui::LatencyInfo& latency_info) { 104 const ui::LatencyInfo& latency_info) {
104 WebGraphicsContext3DCommandBufferImpl* command_buffer = 105 WebGraphicsContext3DCommandBufferImpl* command_buffer =
105 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); 106 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
106 CommandBufferProxyImpl* command_buffer_proxy = 107 CommandBufferProxyImpl* command_buffer_proxy =
107 command_buffer->GetCommandBufferProxy(); 108 command_buffer->GetCommandBufferProxy();
108 DCHECK(command_buffer_proxy); 109 DCHECK(command_buffer_proxy);
109 context3d()->shallowFlushCHROMIUM(); 110 context3d()->shallowFlushCHROMIUM();
110 command_buffer_proxy->SetLatencyInfo(latency_info); 111 command_buffer_proxy->SetLatencyInfo(latency_info);
111 OutputSurface::SwapBuffers(latency_info); 112 OutputSurface::SwapBuffers(latency_info);
112 } 113 }
113 114
114 void CompositorOutputSurface::PostSubBuffer( 115 void CompositorOutputSurface::PostSubBuffer(
115 gfx::Rect rect, const ui::LatencyInfo& latency_info) { 116 gfx::Rect rect, const ui::LatencyInfo& latency_info) {
116 WebGraphicsContext3DCommandBufferImpl* command_buffer = 117 WebGraphicsContext3DCommandBufferImpl* command_buffer =
117 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); 118 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
118 CommandBufferProxyImpl* command_buffer_proxy = 119 CommandBufferProxyImpl* command_buffer_proxy =
119 command_buffer->GetCommandBufferProxy(); 120 command_buffer->GetCommandBufferProxy();
120 DCHECK(command_buffer_proxy); 121 DCHECK(command_buffer_proxy);
121 context3d()->shallowFlushCHROMIUM(); 122 context3d()->shallowFlushCHROMIUM();
122 command_buffer_proxy->SetLatencyInfo(latency_info); 123 command_buffer_proxy->SetLatencyInfo(latency_info);
123 OutputSurface::PostSubBuffer(rect, latency_info); 124 OutputSurface::PostSubBuffer(rect, latency_info);
124 } 125 }
125 126
126 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 127 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
127 DCHECK(CalledOnValidThread()); 128 DCHECK(CalledOnValidThread());
128 if (!client_) 129 if (!hasClient())
129 return; 130 return;
130 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 131 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
131 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 132 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
132 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 133 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
133 #if defined(OS_ANDROID) 134 #if defined(OS_ANDROID)
134 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame); 135 IPC_MESSAGE_HANDLER(ViewMsg_BeginFrame, OnBeginFrame);
135 #endif 136 #endif
136 IPC_END_MESSAGE_MAP() 137 IPC_END_MESSAGE_MAP()
137 } 138 }
138 139
139 void CompositorOutputSurface::OnUpdateVSyncParameters( 140 void CompositorOutputSurface::OnUpdateVSyncParameters(
140 base::TimeTicks timebase, base::TimeDelta interval) { 141 base::TimeTicks timebase, base::TimeDelta interval) {
141 DCHECK(CalledOnValidThread()); 142 DCHECK(CalledOnValidThread());
142 client_->OnVSyncParametersChanged(timebase, interval); 143 OnVSyncParametersChanged(timebase, interval);
143 } 144 }
144 145
145 #if defined(OS_ANDROID) 146 #if defined(OS_ANDROID)
146 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) { 147 void CompositorOutputSurface::SetNeedsBeginFrame(bool enable) {
147 DCHECK(CalledOnValidThread()); 148 DCHECK(CalledOnValidThread());
148 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); 149 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable));
150 OutputSurface::SetNeedsBeginFrame(enable);
149 } 151 }
150 152
151 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) { 153 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) {
152 DCHECK(CalledOnValidThread()); 154 DCHECK(CalledOnValidThread());
153 client_->BeginFrame(frame_time); 155 BeginFrame(frame_time);
154 } 156 }
155 #endif // defined(OS_ANDROID) 157 #endif // defined(OS_ANDROID)
156 158
157 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { 159 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) {
158 client_->OnSendFrameToParentCompositorAck(ack); 160 OnSendFrameToParentCompositorAck(ack);
159 } 161 }
160 162
161 bool CompositorOutputSurface::Send(IPC::Message* message) { 163 bool CompositorOutputSurface::Send(IPC::Message* message) {
162 return message_sender_->Send(message); 164 return message_sender_->Send(message);
163 } 165 }
164 166
165 namespace { 167 namespace {
166 #if defined(OS_ANDROID) 168 #if defined(OS_ANDROID)
167 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) { 169 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) {
168 base::PlatformThread::SetThreadPriority( 170 base::PlatformThread::SetThreadPriority(
(...skipping 28 matching lines...) Expand all
197 // If this is the last surface to stop preferring smoothness, 199 // If this is the last surface to stop preferring smoothness,
198 // Reset the main thread's priority to the default. 200 // Reset the main thread's priority to the default.
199 if (prefers_smoothness_ == true && 201 if (prefers_smoothness_ == true &&
200 --g_prefer_smoothness_count == 0) { 202 --g_prefer_smoothness_count == 0) {
201 SetThreadPriorityToDefault(main_thread_handle_); 203 SetThreadPriorityToDefault(main_thread_handle_);
202 } 204 }
203 prefers_smoothness_ = prefers_smoothness; 205 prefers_smoothness_ = prefers_smoothness;
204 } 206 }
205 207
206 } // namespace content 208 } // namespace content
OLDNEW
« cc/scheduler/scheduler.cc ('K') | « content/browser/renderer_host/image_transport_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698