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

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

Issue 12614013: Plumb cc::LatencyInfo through command buffer and output surface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/compositor_frame.h" 9 #include "cc/compositor_frame.h"
10 #include "cc/compositor_frame_ack.h" 10 #include "cc/compositor_frame_ack.h"
11 #include "cc/output_surface_client.h" 11 #include "cc/output_surface_client.h"
12 #include "content/common/gpu/client/command_buffer_proxy_impl.h"
12 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
13 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
14 #include "content/renderer/render_thread_impl.h" 15 #include "content/renderer/render_thread_impl.h"
15 #include "ipc/ipc_forwarding_message_filter.h" 16 #include "ipc/ipc_forwarding_message_filter.h"
16 #include "ipc/ipc_sync_channel.h" 17 #include "ipc/ipc_sync_channel.h"
17 #include "ipc/ipc_sync_message_filter.h" 18 #include "ipc/ipc_sync_message_filter.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
19 20
20 #if defined(OS_ANDROID) 21 #if defined(OS_ANDROID)
21 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) 22 // TODO(epenner): Move thread priorities to base. (crbug.com/170549)
(...skipping 24 matching lines...) Expand all
46 }; 47 };
47 48
48 return new IPC::ForwardingMessageFilter( 49 return new IPC::ForwardingMessageFilter(
49 messages_to_filter, arraysize(messages_to_filter), 50 messages_to_filter, arraysize(messages_to_filter),
50 target_task_runner); 51 target_task_runner);
51 } 52 }
52 53
53 CompositorOutputSurface::CompositorOutputSurface( 54 CompositorOutputSurface::CompositorOutputSurface(
54 int32 routing_id, 55 int32 routing_id,
55 WebGraphicsContext3D* context3D, 56 WebGraphicsContext3D* context3D,
57 CommandBufferProxyImpl* command_buffer_proxy,
56 cc::SoftwareOutputDevice* software_device) 58 cc::SoftwareOutputDevice* software_device)
57 : OutputSurface(make_scoped_ptr(context3D), 59 : OutputSurface(make_scoped_ptr(context3D),
58 make_scoped_ptr(software_device)), 60 make_scoped_ptr(software_device)),
59 output_surface_filter_( 61 output_surface_filter_(
60 RenderThreadImpl::current()->compositor_output_surface_filter()), 62 RenderThreadImpl::current()->compositor_output_surface_filter()),
61 routing_id_(routing_id), 63 routing_id_(routing_id),
62 prefers_smoothness_(false), 64 prefers_smoothness_(false),
63 main_thread_id_(base::PlatformThread::CurrentId()) { 65 main_thread_id_(base::PlatformThread::CurrentId()),
66 command_buffer_proxy_(command_buffer_proxy) {
64 DCHECK(output_surface_filter_); 67 DCHECK(output_surface_filter_);
65 CommandLine* command_line = CommandLine::ForCurrentProcess(); 68 CommandLine* command_line = CommandLine::ForCurrentProcess();
66 capabilities_.has_parent_compositor = command_line->HasSwitch( 69 capabilities_.has_parent_compositor = command_line->HasSwitch(
67 switches::kEnableDelegatedRenderer); 70 switches::kEnableDelegatedRenderer);
68 DetachFromThread(); 71 DetachFromThread();
69 } 72 }
70 73
71 CompositorOutputSurface::~CompositorOutputSurface() { 74 CompositorOutputSurface::~CompositorOutputSurface() {
72 DCHECK(CalledOnValidThread()); 75 DCHECK(CalledOnValidThread());
73 if (!client_) 76 if (!client_)
(...skipping 10 matching lines...) Expand all
84 87
85 if (!cc::OutputSurface::BindToClient(client)) 88 if (!cc::OutputSurface::BindToClient(client))
86 return false; 89 return false;
87 90
88 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this); 91 output_surface_proxy_ = new CompositorOutputSurfaceProxy(this);
89 output_surface_filter_->AddRoute( 92 output_surface_filter_->AddRoute(
90 routing_id_, 93 routing_id_,
91 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived, 94 base::Bind(&CompositorOutputSurfaceProxy::OnMessageReceived,
92 output_surface_proxy_)); 95 output_surface_proxy_));
93 96
97 if (command_buffer_proxy_)
apatrick_chromium 2013/03/15 19:09:35 nit: braces
98 command_buffer_proxy_->SetLatencyInfoCallback(
99 base::Bind(&CompositorOutputSurface::OnReceivedLatencyInfo,
100 base::Unretained(this)));
101
94 return true; 102 return true;
95 } 103 }
96 104
97 void CompositorOutputSurface::SendFrameToParentCompositor( 105 void CompositorOutputSurface::SendFrameToParentCompositor(
98 cc::CompositorFrame* frame) { 106 cc::CompositorFrame* frame) {
99 DCHECK(CalledOnValidThread()); 107 DCHECK(CalledOnValidThread());
100 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame)); 108 Send(new ViewHostMsg_SwapCompositorFrame(routing_id_, *frame));
101 } 109 }
102 110
111 void CompositorOutputSurface::SetLatencyInfo(
112 const cc::LatencyInfo& latency_info) {
113 if (command_buffer_proxy_)
114 command_buffer_proxy_->SetLatencyInfo(latency_info);
115 }
116
117 void CompositorOutputSurface::OnReceivedLatencyInfo(
118 const cc::LatencyInfo& latency_info) {
119 DCHECK(CalledOnValidThread());
120 DCHECK(client_);
121 client_->OnReceivedLatencyInfo(latency_info);
122 }
123
103 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { 124 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
104 DCHECK(CalledOnValidThread()); 125 DCHECK(CalledOnValidThread());
105 if (!client_) 126 if (!client_)
106 return; 127 return;
107 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) 128 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
108 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); 129 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
109 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); 130 IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
110 IPC_END_MESSAGE_MAP() 131 IPC_END_MESSAGE_MAP()
111 } 132 }
112 133
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // If this is the last surface to stop preferring smoothness, 182 // If this is the last surface to stop preferring smoothness,
162 // Reset the main thread's priority to the default. 183 // Reset the main thread's priority to the default.
163 if (prefers_smoothness_ == true && 184 if (prefers_smoothness_ == true &&
164 --g_prefer_smoothness_count == 0) { 185 --g_prefer_smoothness_count == 0) {
165 SetThreadsPriorityToDefault(main_thread_id_); 186 SetThreadsPriorityToDefault(main_thread_id_);
166 } 187 }
167 prefers_smoothness_ = prefers_smoothness; 188 prefers_smoothness_ = prefers_smoothness;
168 } 189 }
169 190
170 } // namespace content 191 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698