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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_impl.cc

Issue 619843002: cc: Make separate interface for BeginFrame ipc from OutputSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/android/in_process/synchronous_compositor_impl.h" 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
6 6
7 #include "base/auto_reset.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "cc/input/input_handler.h" 10 #include "cc/input/input_handler.h"
11 #include "content/browser/android/in_process/synchronous_compositor_external_beg in_frame_source.h"
10 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h" 12 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h"
11 #include "content/browser/android/in_process/synchronous_input_event_filter.h" 13 #include "content/browser/android/in_process/synchronous_input_event_filter.h"
12 #include "content/browser/renderer_host/render_widget_host_view_android.h" 14 #include "content/browser/renderer_host/render_widget_host_view_android.h"
13 #include "content/common/input/did_overscroll_params.h" 15 #include "content/common/input/did_overscroll_params.h"
14 #include "content/public/browser/android/synchronous_compositor_client.h" 16 #include "content/public/browser/android/synchronous_compositor_client.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
17 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
18 #include "ui/gl/gl_surface.h" 20 #include "ui/gl/gl_surface.h"
19 21
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 60 }
59 61
60 SynchronousCompositorImpl* SynchronousCompositorImpl::FromRoutingID( 62 SynchronousCompositorImpl* SynchronousCompositorImpl::FromRoutingID(
61 int routing_id) { 63 int routing_id) {
62 return FromID(GetInProcessRendererId(), routing_id); 64 return FromID(GetInProcessRendererId(), routing_id);
63 } 65 }
64 66
65 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents) 67 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents)
66 : compositor_client_(NULL), 68 : compositor_client_(NULL),
67 output_surface_(NULL), 69 output_surface_(NULL),
70 begin_frame_source_(NULL),
68 contents_(contents), 71 contents_(contents),
69 input_handler_(NULL), 72 input_handler_(NULL),
73 invoking_composite_(false),
70 weak_ptr_factory_(this) { 74 weak_ptr_factory_(this) {
71 DCHECK(contents); 75 DCHECK(contents);
72 } 76 }
73 77
74 SynchronousCompositorImpl::~SynchronousCompositorImpl() { 78 SynchronousCompositorImpl::~SynchronousCompositorImpl() {
75 if (compositor_client_) 79 if (compositor_client_)
76 compositor_client_->DidDestroyCompositor(this); 80 compositor_client_->DidDestroyCompositor(this);
77 SetInputHandler(NULL); 81 SetInputHandler(NULL);
78 } 82 }
79 83
80 void SynchronousCompositorImpl::SetClient( 84 void SynchronousCompositorImpl::SetClient(
81 SynchronousCompositorClient* compositor_client) { 85 SynchronousCompositorClient* compositor_client) {
82 DCHECK(CalledOnValidThread()); 86 DCHECK(CalledOnValidThread());
83 compositor_client_ = compositor_client; 87 compositor_client_ = compositor_client;
84 } 88 }
85 89
86 // static 90 // static
87 void SynchronousCompositor::SetGpuService( 91 void SynchronousCompositor::SetGpuService(
88 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { 92 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
89 g_factory.Get().SetDeferredGpuService(service); 93 g_factory.Get().SetDeferredGpuService(service);
90 } 94 }
91 95
92 // static 96 // static
93 void SynchronousCompositor::SetRecordFullDocument(bool record_full_document) { 97 void SynchronousCompositor::SetRecordFullDocument(bool record_full_document) {
94 g_factory.Get().SetRecordFullDocument(record_full_document); 98 g_factory.Get().SetRecordFullDocument(record_full_document);
95 } 99 }
96 100
101 void SynchronousCompositorImpl::SetExternalBeginFrameSource(
102 SynchronousCompositorExternalBeginFrameSource* begin_frame_source) {
103 DCHECK(!begin_frame_source_);
104 begin_frame_source_ = begin_frame_source;
105 }
106
97 bool SynchronousCompositorImpl::InitializeHwDraw() { 107 bool SynchronousCompositorImpl::InitializeHwDraw() {
98 DCHECK(CalledOnValidThread()); 108 DCHECK(CalledOnValidThread());
99 DCHECK(output_surface_); 109 DCHECK(output_surface_);
100 110
101 scoped_refptr<cc::ContextProvider> onscreen_context = 111 scoped_refptr<cc::ContextProvider> onscreen_context =
102 g_factory.Get().CreateOnscreenContextProviderForCompositorThread(); 112 g_factory.Get().CreateOnscreenContextProviderForCompositorThread();
103 113
104 bool success = output_surface_->InitializeHwDraw(onscreen_context); 114 bool success = output_surface_->InitializeHwDraw(onscreen_context);
105 115
106 if (success) 116 if (success)
(...skipping 10 matching lines...) Expand all
117 127
118 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( 128 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw(
119 gfx::Size surface_size, 129 gfx::Size surface_size,
120 const gfx::Transform& transform, 130 const gfx::Transform& transform,
121 gfx::Rect viewport, 131 gfx::Rect viewport,
122 gfx::Rect clip, 132 gfx::Rect clip,
123 gfx::Rect viewport_rect_for_tile_priority, 133 gfx::Rect viewport_rect_for_tile_priority,
124 const gfx::Transform& transform_for_tile_priority) { 134 const gfx::Transform& transform_for_tile_priority) {
125 DCHECK(CalledOnValidThread()); 135 DCHECK(CalledOnValidThread());
126 DCHECK(output_surface_); 136 DCHECK(output_surface_);
137 DCHECK(!invoking_composite_);
138 DCHECK(begin_frame_source_);
139 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true);
127 140
128 scoped_ptr<cc::CompositorFrame> frame = 141 scoped_ptr<cc::CompositorFrame> frame =
129 output_surface_->DemandDrawHw(surface_size, 142 output_surface_->DemandDrawHw(surface_size,
130 transform, 143 transform,
131 viewport, 144 viewport,
132 clip, 145 clip,
133 viewport_rect_for_tile_priority, 146 viewport_rect_for_tile_priority,
134 transform_for_tile_priority); 147 transform_for_tile_priority);
135 if (frame.get()) 148 if (frame.get())
136 UpdateFrameMetaData(frame->metadata); 149 UpdateFrameMetaData(frame->metadata);
137 150
151 begin_frame_source_->BeginFrame();
152 SetContinuousInvalidate(begin_frame_source_->NeedsBeginFrames());
153
138 return frame.Pass(); 154 return frame.Pass();
139 } 155 }
140 156
141 void SynchronousCompositorImpl::ReturnResources( 157 void SynchronousCompositorImpl::ReturnResources(
142 const cc::CompositorFrameAck& frame_ack) { 158 const cc::CompositorFrameAck& frame_ack) {
143 DCHECK(CalledOnValidThread()); 159 DCHECK(CalledOnValidThread());
144 output_surface_->ReturnResources(frame_ack); 160 output_surface_->ReturnResources(frame_ack);
145 } 161 }
146 162
147 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { 163 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) {
148 DCHECK(CalledOnValidThread()); 164 DCHECK(CalledOnValidThread());
149 DCHECK(output_surface_); 165 DCHECK(output_surface_);
166 DCHECK(!invoking_composite_);
167 DCHECK(begin_frame_source_);
168 base::AutoReset<bool> invoking_composite_resetter(&invoking_composite_, true);
150 169
151 scoped_ptr<cc::CompositorFrame> frame = output_surface_->DemandDrawSw(canvas); 170 scoped_ptr<cc::CompositorFrame> frame = output_surface_->DemandDrawSw(canvas);
152 if (frame.get()) 171 if (frame.get())
153 UpdateFrameMetaData(frame->metadata); 172 UpdateFrameMetaData(frame->metadata);
173
174 begin_frame_source_->BeginFrame();
175 SetContinuousInvalidate(begin_frame_source_->NeedsBeginFrames());
176
154 return !!frame.get(); 177 return !!frame.get();
155 } 178 }
156 179
157 void SynchronousCompositorImpl::UpdateFrameMetaData( 180 void SynchronousCompositorImpl::UpdateFrameMetaData(
158 const cc::CompositorFrameMetadata& frame_metadata) { 181 const cc::CompositorFrameMetadata& frame_metadata) {
159 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( 182 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
160 contents_->GetRenderWidgetHostView()); 183 contents_->GetRenderWidgetHostView());
161 if (rwhv) 184 if (rwhv)
162 rwhv->SynchronousFrameMetadata(frame_metadata); 185 rwhv->SynchronousFrameMetadata(frame_metadata);
163 DeliverMessages(); 186 DeliverMessages();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 243 }
221 } 244 }
222 245
223 void SynchronousCompositorImpl::DidStopFlinging() { 246 void SynchronousCompositorImpl::DidStopFlinging() {
224 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( 247 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
225 contents_->GetRenderWidgetHostView()); 248 contents_->GetRenderWidgetHostView());
226 if (rwhv) 249 if (rwhv)
227 rwhv->DidStopFlinging(); 250 rwhv->DidStopFlinging();
228 } 251 }
229 252
230 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { 253 void SynchronousCompositorImpl::SetContinuousInvalidate(
254 bool needs_begin_frames) const {
231 DCHECK(CalledOnValidThread()); 255 DCHECK(CalledOnValidThread());
232 if (compositor_client_) 256 if (compositor_client_)
233 compositor_client_->SetContinuousInvalidate(enable); 257 compositor_client_->SetContinuousInvalidate(needs_begin_frames);
234 } 258 }
235 259
236 InputEventAckState SynchronousCompositorImpl::HandleInputEvent( 260 InputEventAckState SynchronousCompositorImpl::HandleInputEvent(
237 const blink::WebInputEvent& input_event) { 261 const blink::WebInputEvent& input_event) {
238 DCHECK(CalledOnValidThread()); 262 DCHECK(CalledOnValidThread());
239 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent( 263 return g_factory.Get().synchronous_input_event_filter()->HandleInputEvent(
240 contents_->GetRoutingID(), input_event); 264 contents_->GetRoutingID(), input_event);
241 } 265 }
242 266
243 void SynchronousCompositorImpl::DeliverMessages() { 267 void SynchronousCompositorImpl::DeliverMessages() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 g_factory.Get(); // Ensure it's initialized. 334 g_factory.Get(); // Ensure it's initialized.
311 SynchronousCompositorImpl::CreateForWebContents(contents); 335 SynchronousCompositorImpl::CreateForWebContents(contents);
312 } 336 }
313 if (SynchronousCompositorImpl* instance = 337 if (SynchronousCompositorImpl* instance =
314 SynchronousCompositorImpl::FromWebContents(contents)) { 338 SynchronousCompositorImpl::FromWebContents(contents)) {
315 instance->SetClient(client); 339 instance->SetClient(client);
316 } 340 }
317 } 341 }
318 342
319 } // namespace content 343 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698