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

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

Issue 16304003: Unified OutputSurface::SwapBuffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up 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 | Annotate | Revision Log
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 }; 43 };
44 44
45 return new IPC::ForwardingMessageFilter( 45 return new IPC::ForwardingMessageFilter(
46 messages_to_filter, arraysize(messages_to_filter), 46 messages_to_filter, arraysize(messages_to_filter),
47 target_task_runner); 47 target_task_runner);
48 } 48 }
49 49
50 CompositorOutputSurface::CompositorOutputSurface( 50 CompositorOutputSurface::CompositorOutputSurface(
51 int32 routing_id, 51 int32 routing_id,
52 WebGraphicsContext3DCommandBufferImpl* context3D, 52 WebGraphicsContext3DCommandBufferImpl* context3D,
53 cc::SoftwareOutputDevice* software_device) 53 cc::SoftwareOutputDevice* software_device,
54 bool swap_with_ipc)
54 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D), 55 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context3D),
55 make_scoped_ptr(software_device)), 56 make_scoped_ptr(software_device)),
57 swap_with_ipc_(swap_with_ipc),
56 output_surface_filter_( 58 output_surface_filter_(
57 RenderThreadImpl::current()->compositor_output_surface_filter()), 59 RenderThreadImpl::current()->compositor_output_surface_filter()),
58 routing_id_(routing_id), 60 routing_id_(routing_id),
59 prefers_smoothness_(false), 61 prefers_smoothness_(false),
60 main_thread_handle_(base::PlatformThread::CurrentHandle()) { 62 main_thread_handle_(base::PlatformThread::CurrentHandle()) {
61 DCHECK(output_surface_filter_.get()); 63 DCHECK(output_surface_filter_.get());
62 CommandLine* command_line = CommandLine::ForCurrentProcess();
63 capabilities_.has_parent_compositor = command_line->HasSwitch(
64 switches::kEnableDelegatedRenderer);
65 DetachFromThread(); 64 DetachFromThread();
66 message_sender_ = RenderThreadImpl::current()->sync_message_filter(); 65 message_sender_ = RenderThreadImpl::current()->sync_message_filter();
67 DCHECK(message_sender_.get()); 66 DCHECK(message_sender_.get());
68 } 67 }
69 68
70 CompositorOutputSurface::~CompositorOutputSurface() { 69 CompositorOutputSurface::~CompositorOutputSurface() {
71 DCHECK(CalledOnValidThread()); 70 DCHECK(CalledOnValidThread());
72 if (!client_) 71 if (!client_)
73 return; 72 return;
74 UpdateSmoothnessTakesPriority(false); 73 UpdateSmoothnessTakesPriority(false);
(...skipping 11 matching lines...) Expand all
86 85
87 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); 86 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this);
88 output_surface_filter_->AddRoute( 87 output_surface_filter_->AddRoute(
89 routing_id_, 88 routing_id_,
90 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, 89 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived,
91 output_surface_proxy_)); 90 output_surface_proxy_));
92 91
93 return true; 92 return true;
94 } 93 }
95 94
96 void CompositorOutputSurface::SendFrameToParentCompositor( 95 void CompositorOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
97 cc::CompositorFrame* frame) { 96 if (swap_with_ipc_) {
joth 2013/06/10 18:43:32 nit: swap_buffers_via_ipc_ maybe clearer?
aelias_OOO_until_Jul13 2013/06/10 18:57:57 Done.
98 DCHECK(CalledOnValidThread()); 97 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame));
99 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); 98 return;
100 } 99 }
101 100
102 void CompositorOutputSurface::SwapBuffers( 101 if (frame->software_frame_data)
joth 2013/06/10 18:43:32 do you need include the base-call here, to get the
aelias_OOO_until_Jul13 2013/06/10 18:57:57 Good catch, changed to call directly from here.
103 const ui::LatencyInfo& latency_info) { 102 return;
103
104 DCHECK(frame->gl_frame_data);
105
104 WebGraphicsContext3DCommandBufferImpl* command_buffer = 106 WebGraphicsContext3DCommandBufferImpl* command_buffer =
105 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); 107 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
106 CommandBufferProxyImpl* command_buffer_proxy = 108 CommandBufferProxyImpl* command_buffer_proxy =
107 command_buffer->GetCommandBufferProxy(); 109 command_buffer->GetCommandBufferProxy();
108 DCHECK(command_buffer_proxy); 110 DCHECK(command_buffer_proxy);
109 context3d()->shallowFlushCHROMIUM(); 111 context3d()->shallowFlushCHROMIUM();
110 command_buffer_proxy->SetLatencyInfo(latency_info); 112 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
111 OutputSurface::SwapBuffers(latency_info);
112 }
113 113
114 void CompositorOutputSurface::PostSubBuffer( 114 OutputSurface::SwapBuffers(frame);
115 gfx::Rect rect, const ui::LatencyInfo& latency_info) {
116 WebGraphicsContext3DCommandBufferImpl* command_buffer =
117 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d());
118 CommandBufferProxyImpl* command_buffer_proxy =
119 command_buffer->GetCommandBufferProxy();
120 DCHECK(command_buffer_proxy);
121 context3d()->shallowFlushCHROMIUM();
122 command_buffer_proxy->SetLatencyInfo(latency_info);
123 OutputSurface::PostSubBuffer(rect, latency_info);
124 } 115 }
125 116
126 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 117 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
127 DCHECK(CalledOnValidThread()); 118 DCHECK(CalledOnValidThread());
128 if (!client_) 119 if (!client_)
129 return; 120 return;
130 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 121 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
131 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 122 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
132 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 123 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
133 #if defined(OS_ANDROID) 124 #if defined(OS_ANDROID)
(...skipping 14 matching lines...) Expand all
148 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable)); 139 Send(new ViewHostMsg_SetNeedsBeginFrame(routing_id_, enable));
149 } 140 }
150 141
151 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) { 142 void CompositorOutputSurface::OnBeginFrame(base::TimeTicks frame_time) {
152 DCHECK(CalledOnValidThread()); 143 DCHECK(CalledOnValidThread());
153 client_->BeginFrame(frame_time); 144 client_->BeginFrame(frame_time);
154 } 145 }
155 #endif // defined(OS_ANDROID) 146 #endif // defined(OS_ANDROID)
156 147
157 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { 148 void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) {
158 client_->OnSendFrameToParentCompositorAck(ack); 149 client_->OnSwapBuffersComplete(&ack);
159 } 150 }
160 151
161 bool CompositorOutputSurface::Send(IPC::Message* message) { 152 bool CompositorOutputSurface::Send(IPC::Message* message) {
162 return message_sender_->Send(message); 153 return message_sender_->Send(message);
163 } 154 }
164 155
165 namespace { 156 namespace {
166 #if defined(OS_ANDROID) 157 #if defined(OS_ANDROID)
167 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) { 158 void SetThreadPriorityToIdle(base::PlatformThreadHandle handle) {
168 base::PlatformThread::SetThreadPriority( 159 base::PlatformThread::SetThreadPriority(
(...skipping 28 matching lines...) Expand all
197 // If this is the last surface to stop preferring smoothness, 188 // If this is the last surface to stop preferring smoothness,
198 // Reset the main thread's priority to the default. 189 // Reset the main thread's priority to the default.
199 if (prefers_smoothness_ == true && 190 if (prefers_smoothness_ == true &&
200 --g_prefer_smoothness_count == 0) { 191 --g_prefer_smoothness_count == 0) {
201 SetThreadPriorityToDefault(main_thread_handle_); 192 SetThreadPriorityToDefault(main_thread_handle_);
202 } 193 }
203 prefers_smoothness_ = prefers_smoothness; 194 prefers_smoothness_ = prefers_smoothness;
204 } 195 }
205 196
206 } // namespace content 197 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698