OLD | NEW |
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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 UpdateNeedsBeginFrames(); | 267 UpdateNeedsBeginFrames(); |
268 } | 268 } |
269 | 269 |
270 void SynchronousCompositorImpl::OnNeedsBeginFramesChange( | 270 void SynchronousCompositorImpl::OnNeedsBeginFramesChange( |
271 bool needs_begin_frames) { | 271 bool needs_begin_frames) { |
272 renderer_needs_begin_frames_ = needs_begin_frames; | 272 renderer_needs_begin_frames_ = needs_begin_frames; |
273 UpdateNeedsBeginFrames(); | 273 UpdateNeedsBeginFrames(); |
274 } | 274 } |
275 | 275 |
276 void SynchronousCompositorImpl::BeginFrame(const cc::BeginFrameArgs& args) { | 276 void SynchronousCompositorImpl::BeginFrame(const cc::BeginFrameArgs& args) { |
277 if (!registered_with_client_) { | 277 if (!registered_with_client_ && is_active_ && renderer_needs_begin_frames_) { |
| 278 // Make sure this is a BeginFrame that renderer side explicitly requested. |
| 279 // Otherwise it is possible renderer objects not initialized. |
278 RegisterWithClient(); | 280 RegisterWithClient(); |
279 DCHECK(registered_with_client_); | 281 DCHECK(registered_with_client_); |
280 } | 282 } |
281 if (begin_frame_source_) | 283 if (begin_frame_source_) |
282 begin_frame_source_->BeginFrame(args); | 284 begin_frame_source_->BeginFrame(args); |
283 } | 285 } |
284 | 286 |
285 void SynchronousCompositorImpl::UpdateNeedsBeginFrames() { | 287 void SynchronousCompositorImpl::UpdateNeedsBeginFrames() { |
286 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( | 288 RenderWidgetHostViewAndroid* rwhv = static_cast<RenderWidgetHostViewAndroid*>( |
287 contents_->GetRenderWidgetHostView()); | 289 contents_->GetRenderWidgetHostView()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 g_factory.Get(); // Ensure it's initialized. | 390 g_factory.Get(); // Ensure it's initialized. |
389 SynchronousCompositorImpl::CreateForWebContents(contents); | 391 SynchronousCompositorImpl::CreateForWebContents(contents); |
390 } | 392 } |
391 SynchronousCompositorImpl* instance = | 393 SynchronousCompositorImpl* instance = |
392 SynchronousCompositorImpl::FromWebContents(contents); | 394 SynchronousCompositorImpl::FromWebContents(contents); |
393 DCHECK(instance); | 395 DCHECK(instance); |
394 instance->SetClient(client); | 396 instance->SetClient(client); |
395 } | 397 } |
396 | 398 |
397 } // namespace content | 399 } // namespace content |
OLD | NEW |