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

Unified 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: Back to first approach Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/in_process/synchronous_compositor_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/in_process/synchronous_compositor_impl.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_impl.cc b/content/browser/android/in_process/synchronous_compositor_impl.cc
index d3c6b830b7082bf6e2dec32f803b6751d249aa47..a44ccfe2b03925a14a1b45c5e10218fd7c9b17e0 100644
--- a/content/browser/android/in_process/synchronous_compositor_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_impl.cc
@@ -74,6 +74,7 @@ SynchronousCompositorImpl::SynchronousCompositorImpl(WebContents* contents)
contents_(contents),
routing_id_(contents->GetRoutingID()),
input_handler_(NULL),
+ registered_with_client_(false),
is_active_(false),
renderer_needs_begin_frames_(false),
weak_ptr_factory_(this) {
@@ -108,6 +109,17 @@ void SynchronousCompositorImpl::SetClient(
}
}
+void SynchronousCompositorImpl::RegisterWithClient() {
+ DCHECK(CalledOnValidThread());
+
+ if (registered_with_client_)
+ return;
+
+ SetIsActive(false);
+ compositor_client_->DidInitializeCompositor(this);
+ registered_with_client_ = true;
+}
+
// static
void SynchronousCompositor::SetGpuService(
scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
@@ -140,11 +152,10 @@ void SynchronousCompositorImpl::DidInitializeRendererObjects(
base::Bind(&SynchronousCompositorImpl::DidActivatePendingTree,
weak_ptr_factory_.GetWeakPtr()));
- OnNeedsBeginFramesChange(begin_frame_source_->NeedsBeginFrames());
-
- compositor_client_->DidInitializeCompositor(this);
-
SetInputHandler(input_handler);
+
+ OnNeedsBeginFramesChange(begin_frame_source_->NeedsBeginFrames());
+ SetIsActive(true);
}
void SynchronousCompositorImpl::DidDestroyRendererObjects() {
@@ -152,10 +163,17 @@ void SynchronousCompositorImpl::DidDestroyRendererObjects() {
DCHECK(begin_frame_source_);
DCHECK(compositor_client_);
+ if (registered_with_client_) {
+ compositor_client_->DidDestroyCompositor(this);
+ registered_with_client_ = false;
+ }
+
+ SetIsActive(false);
+ OnNeedsBeginFramesChange(false);
+
+ SetInputHandler(nullptr);
begin_frame_source_->SetCompositor(nullptr);
output_surface_->SetCompositor(nullptr);
- SetInputHandler(nullptr);
- compositor_client_->DidDestroyCompositor(this);
output_surface_ = nullptr;
begin_frame_source_ = nullptr;
}
@@ -233,7 +251,8 @@ void SynchronousCompositorImpl::SetMemoryPolicy(size_t bytes_limit) {
void SynchronousCompositorImpl::PostInvalidate() {
DCHECK(CalledOnValidThread());
DCHECK(compositor_client_);
- compositor_client_->PostInvalidate();
+ if (registered_with_client_)
+ compositor_client_->PostInvalidate();
}
void SynchronousCompositorImpl::DidChangeRootLayerScrollOffset() {
@@ -282,9 +301,10 @@ void SynchronousCompositorImpl::SetInputHandler(
void SynchronousCompositorImpl::DidOverscroll(
const DidOverscrollParams& params) {
DCHECK(compositor_client_);
- compositor_client_->DidOverscroll(params.accumulated_overscroll,
- params.latest_overscroll_delta,
- params.current_fling_velocity);
+ if (registered_with_client_)
+ compositor_client_->DidOverscroll(params.accumulated_overscroll,
+ params.latest_overscroll_delta,
+ params.current_fling_velocity);
}
void SynchronousCompositorImpl::DidStopFlinging() {
@@ -315,6 +335,9 @@ void SynchronousCompositorImpl::DeliverMessages() {
void SynchronousCompositorImpl::DidActivatePendingTree() {
DCHECK(compositor_client_);
+ if (!registered_with_client_)
+ RegisterWithClient();
+ DCHECK(registered_with_client_);
compositor_client_->DidUpdateContent();
DeliverMessages();
}
@@ -322,6 +345,8 @@ void SynchronousCompositorImpl::DidActivatePendingTree() {
gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() {
DCHECK(CalledOnValidThread());
DCHECK(compositor_client_);
+ if (!registered_with_client_)
+ return gfx::ScrollOffset();
// TODO(miletus): Make GetTotalRootLayerScrollOffset return
// ScrollOffset. crbug.com/414283.
return gfx::ScrollOffset(
@@ -331,6 +356,8 @@ gfx::ScrollOffset SynchronousCompositorImpl::GetTotalScrollOffset() {
bool SynchronousCompositorImpl::IsExternalFlingActive() const {
DCHECK(CalledOnValidThread());
DCHECK(compositor_client_);
+ if (!registered_with_client_)
+ return false;
return compositor_client_->IsExternalFlingActive();
}
@@ -344,14 +371,15 @@ void SynchronousCompositorImpl::UpdateRootLayerState(
DCHECK(CalledOnValidThread());
DCHECK(compositor_client_);
- // TODO(miletus): Pass in ScrollOffset. crbug.com/414283.
- compositor_client_->UpdateRootLayerState(
- gfx::ScrollOffsetToVector2dF(total_scroll_offset),
- gfx::ScrollOffsetToVector2dF(max_scroll_offset),
- scrollable_size,
- page_scale_factor,
- min_page_scale_factor,
- max_page_scale_factor);
+ if (registered_with_client_)
boliu 2015/05/30 01:06:29 style: Need braces for if statements with multi-li
+ // TODO(miletus): Pass in ScrollOffset. crbug.com/414283.
+ compositor_client_->UpdateRootLayerState(
+ gfx::ScrollOffsetToVector2dF(total_scroll_offset),
+ gfx::ScrollOffsetToVector2dF(max_scroll_offset),
+ scrollable_size,
+ page_scale_factor,
+ min_page_scale_factor,
+ max_page_scale_factor);
}
// Not using base::NonThreadSafe as we want to enforce a more exacting threading
« no previous file with comments | « content/browser/android/in_process/synchronous_compositor_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698