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

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

Issue 1150423003: webview: Initialize synchronous compositor after first activation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return FromID(GetInProcessRendererId(), routing_id); 67 return FromID(GetInProcessRendererId(), routing_id);
68 } 68 }
69 69
70 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents) 70 SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents)
71 : compositor_client_(NULL), 71 : compositor_client_(NULL),
72 output_surface_(NULL), 72 output_surface_(NULL),
73 begin_frame_source_(nullptr), 73 begin_frame_source_(nullptr),
74 contents_(contents), 74 contents_(contents),
75 routing_id_(contents->GetRoutingID()), 75 routing_id_(contents->GetRoutingID()),
76 input_handler_(NULL), 76 input_handler_(NULL),
77 has_initialized_(false),
77 is_active_(false), 78 is_active_(false),
78 renderer_needs_begin_frames_(false), 79 renderer_needs_begin_frames_(false),
79 weak_ptr_factory_(this) { 80 weak_ptr_factory_(this) {
80 DCHECK(contents); 81 DCHECK(contents);
81 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); 82 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
82 } 83 }
83 84
84 SynchronousCompositorImpl::~SynchronousCompositorImpl() { 85 SynchronousCompositorImpl::~SynchronousCompositorImpl() {
85 DCHECK(!output_surface_); 86 DCHECK(!output_surface_);
86 DCHECK(!begin_frame_source_); 87 DCHECK(!begin_frame_source_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 output_surface_ = output_surface; 134 output_surface_ = output_surface;
134 begin_frame_source_ = begin_frame_source; 135 begin_frame_source_ = begin_frame_source;
135 136
136 begin_frame_source_->SetCompositor(this); 137 begin_frame_source_->SetCompositor(this);
137 output_surface_->SetCompositor(this); 138 output_surface_->SetCompositor(this);
138 139
139 output_surface_->SetTreeActivationCallback( 140 output_surface_->SetTreeActivationCallback(
140 base::Bind(&SynchronousCompositorImpl::DidActivatePendingTree, 141 base::Bind(&SynchronousCompositorImpl::DidActivatePendingTree,
141 weak_ptr_factory_.GetWeakPtr())); 142 weak_ptr_factory_.GetWeakPtr()));
142 143
144 SetInputHandler(input_handler);
145
143 OnNeedsBeginFramesChange(begin_frame_source_->NeedsBeginFrames()); 146 OnNeedsBeginFramesChange(begin_frame_source_->NeedsBeginFrames());
144
145 compositor_client_->DidInitializeCompositor(this);
146
147 SetInputHandler(input_handler);
148 } 147 }
149 148
150 void SynchronousCompositorImpl::DidDestroyRendererObjects() { 149 void SynchronousCompositorImpl::DidDestroyRendererObjects() {
151 DCHECK(output_surface_); 150 DCHECK(output_surface_);
152 DCHECK(begin_frame_source_); 151 DCHECK(begin_frame_source_);
153 DCHECK(compositor_client_); 152 DCHECK(compositor_client_);
154 153
154 OnNeedsBeginFramesChange(false);
155
155 begin_frame_source_->SetCompositor(nullptr); 156 begin_frame_source_->SetCompositor(nullptr);
156 output_surface_->SetCompositor(nullptr); 157 output_surface_->SetCompositor(nullptr);
157 SetInputHandler(nullptr); 158 SetInputHandler(nullptr);
158 compositor_client_->DidDestroyCompositor(this); 159 compositor_client_->DidDestroyCompositor(this);
boliu 2015/05/29 23:21:12 Every single compositor_client_ call needs to be g
159 output_surface_ = nullptr; 160 output_surface_ = nullptr;
160 begin_frame_source_ = nullptr; 161 begin_frame_source_ = nullptr;
161 } 162 }
162 163
163 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw( 164 scoped_ptr<cc::CompositorFrame> SynchronousCompositorImpl::DemandDrawHw(
164 gfx::Size surface_size, 165 gfx::Size surface_size,
165 const gfx::Transform& transform, 166 const gfx::Transform& transform,
166 gfx::Rect viewport, 167 gfx::Rect viewport,
167 gfx::Rect clip, 168 gfx::Rect clip,
168 gfx::Rect viewport_rect_for_tile_priority, 169 gfx::Rect viewport_rect_for_tile_priority,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 void SynchronousCompositorImpl::BeginFrame(const cc::BeginFrameArgs& args) { 258 void SynchronousCompositorImpl::BeginFrame(const cc::BeginFrameArgs& args) {
258 if (begin_frame_source_) 259 if (begin_frame_source_)
259 begin_frame_source_->BeginFrame(args); 260 begin_frame_source_->BeginFrame(args);
260 } 261 }
261 262
262 void SynchronousCompositorImpl::UpdateNeedsBeginFrames() { 263 void SynchronousCompositorImpl::UpdateNeedsBeginFrames() {
263 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( 264 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>(
264 contents_->GetRenderWidgetHostView()); 265 contents_->GetRenderWidgetHostView());
265 if (rwhv) 266 if (rwhv)
266 rwhv->OnSetNeedsBeginFrames(is_active_ && renderer_needs_begin_frames_); 267 rwhv->OnSetNeedsBeginFrames((is_active_ || !has_initialized_) &&
268 renderer_needs_begin_frames_);
267 } 269 }
268 270
269 void SynchronousCompositorImpl::SetInputHandler( 271 void SynchronousCompositorImpl::SetInputHandler(
270 cc::InputHandler* input_handler) { 272 cc::InputHandler* input_handler) {
271 DCHECK(CalledOnValidThread()); 273 DCHECK(CalledOnValidThread());
272 274
273 if (input_handler_) 275 if (input_handler_)
274 input_handler_->SetRootLayerScrollOffsetDelegate(NULL); 276 input_handler_->SetRootLayerScrollOffsetDelegate(NULL);
275 277
276 input_handler_ = input_handler; 278 input_handler_ = input_handler;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 RenderProcessHost* rph = contents_->GetRenderProcessHost(); 310 RenderProcessHost* rph = contents_->GetRenderProcessHost();
309 for (ScopedVector<IPC::Message>::const_iterator i = messages.begin(); 311 for (ScopedVector<IPC::Message>::const_iterator i = messages.begin();
310 i != messages.end(); 312 i != messages.end();
311 ++i) { 313 ++i) {
312 rph->OnMessageReceived(**i); 314 rph->OnMessageReceived(**i);
313 } 315 }
314 } 316 }
315 317
316 void SynchronousCompositorImpl::DidActivatePendingTree() { 318 void SynchronousCompositorImpl::DidActivatePendingTree() {
317 DCHECK(compositor_client_); 319 DCHECK(compositor_client_);
320 if (!has_initialized_) {
321 has_initialized_ = true;
322 compositor_client_->DidInitializeCompositor(this);
323 }
318 compositor_client_->DidUpdateContent(); 324 compositor_client_->DidUpdateContent();
319 DeliverMessages(); 325 DeliverMessages();
320 } 326 }
321 327
322 gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() { 328 gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() {
323 DCHECK(CalledOnValidThread()); 329 DCHECK(CalledOnValidThread());
324 DCHECK(compositor_client_); 330 DCHECK(compositor_client_);
325 // TODO(miletus): Make GetTotalRootLayerScrollOffset return 331 // TODO(miletus): Make GetTotalRootLayerScrollOffset return
326 // ScrollOffset. crbug.com/414283. 332 // ScrollOffset. crbug.com/414283.
327 return gfx::ScrollOffset( 333 return gfx::ScrollOffset(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 g_factory.Get(); // Ensure it's initialized. 375 g_factory.Get(); // Ensure it's initialized.
370 SynchronousCompositorImpl::CreateForWebContents(contents); 376 SynchronousCompositorImpl::CreateForWebContents(contents);
371 } 377 }
372 SynchronousCompositorImpl* instance = 378 SynchronousCompositorImpl* instance =
373 SynchronousCompositorImpl::FromWebContents(contents); 379 SynchronousCompositorImpl::FromWebContents(contents);
374 DCHECK(instance); 380 DCHECK(instance);
375 instance->SetClient(client); 381 instance->SetClient(client);
376 } 382 }
377 383
378 } // namespace content 384 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698