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

Unified Diff: content/renderer/android/synchronous_compositor_impl.cc

Issue 15002007: Delegate root layer scroll offset to android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
Index: content/renderer/android/synchronous_compositor_impl.cc
diff --git a/content/renderer/android/synchronous_compositor_impl.cc b/content/renderer/android/synchronous_compositor_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b13a58b3dbb80da787b6bc54fade1679e032a61d
--- /dev/null
+++ b/content/renderer/android/synchronous_compositor_impl.cc
@@ -0,0 +1,121 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/android/synchronous_compositor_impl.h"
+
+#include "base/message_loop.h"
+#include "cc/input/input_handler.h"
+#include "content/public/renderer/android/synchronous_compositor_client.h"
+#include "content/public/renderer/content_renderer_client.h"
+
+namespace content {
+
+SynchronousCompositorImpl::SynchronousCompositorImpl(int32 routing_id)
+ : routing_id_(routing_id), compositor_client_(NULL) {}
+
+SynchronousCompositorImpl::~SynchronousCompositorImpl() {
+}
+
+scoped_ptr<cc::OutputSurface>
+SynchronousCompositorImpl::CreateOutputSurface() {
+ scoped_ptr<SynchronousCompositorOutputSurface> output_surface(
+ new SynchronousCompositorOutputSurface(this));
+ output_surface_ = output_surface.get();
+ return output_surface.PassAs<cc::OutputSurface>();
+}
+
+void SynchronousCompositorImpl::didCreateInputHandler(
+ base::WeakPtr<cc::InputHandler> input_handler) {
+ // TODO(mkosiba): Seems contrived (also, current version has race,
+ // would need to ref-count SynchronousCompositorImpl).
+ // Need to find a better way for the SynchronousCompositorImpl to 'get' an
+ // input handler and to be notified of when the InputHandler is destroyed.
+ GetContentClient()->renderer()->OverrideCompositorMessageLoop()->PostTask(
jamesr 2013/05/22 01:28:13 this looks needlessly indirect. you're in the con
mkosiba (inactive) 2013/05/22 17:26:17 Done.
+ FROM_HERE,
+ base::Bind(&SynchronousCompositorImpl::didCreateInputHandlerOnImplThread,
+ base::Unretained(this)
+ input_handler));
+}
+
+void SynchronousCompositorImpl::didCreateInputHandlerOnImplThread(
+ base::WeakPtr<cc::InputHandler> input_handler) {
+ if (input_handler.get()) {
+ input_handler->SetRootLayerScrollOffsetDelegate(
+ GetSynchronousCompositor());
+ }
+}
+
+bool SynchronousCompositorImpl::IsHwReady() {
+ DCHECK(CalledOnValidThread());
+ DCHECK(output_surface_);
+
+ if (!output_surface_)
+ return false;
+ return output_surface_->IsHwReady();
+}
+
+void SynchronousCompositorImpl::SetClient(
+ SynchronousCompositorClient* compositor_client) {
+ DCHECK(CalledOnValidThread());
+ compositor_client_ = compositor_client;
+}
+
+bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(output_surface_);
+
+ if (!output_surface_)
+ return false;
+
+ return output_surface_->DemandDrawSw(canvas);
+}
+
+bool SynchronousCompositorImpl::DemandDrawHw(
+ gfx::Size view_size,
+ const gfx::Transform& transform,
+ gfx::Rect damage_area) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(output_surface_);
+
+ if (!output_surface_)
+ return false;
+ return output_surface_->DemandDrawHw(view_size, transform, damage_area);
+}
+
+void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) {
+ DCHECK(CalledOnValidThread());
+ compositor_client_->SetContinuousInvalidate(enable);
+}
+
+void SynchronousCompositorImpl::DidCreateSynchronousCompositor() {
+ DCHECK(CalledOnValidThread());
+ GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_,
+ this);
+}
+
+void SynchronousCompositorImpl::DidDestroyCompositor() {
+ DCHECK(CalledOnValidThread());
+ output_surface_ = NULL;
+}
+
+void SynchronousCompositorImpl::SetTotalScrollOffset(gfx::Vector2dF new_value) {
+ DCHECK(CalledOnValidThread());
+ compositor_client_->SetTotalRootLayerScrollOffset(new_value);
+}
+
+gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() {
+ DCHECK(CalledOnValidThread());
+ return compositor_client_->GetTotalRootLayerScrollOffset();
+}
+
+// Not using base::NonThreadSafe as we want to enforce a more exacting threading
+// requirement: SynchronousCompositorImpl() must only be used by
+// embedders that supply their own compositor loop via
+// OverrideCompositorMessageLoop().
+bool SynchronousCompositorImpl::CalledOnValidThread() const {
+ return base::MessageLoop::current() && (base::MessageLoop::current() ==
+ GetContentClient()->renderer()->OverrideCompositorMessageLoop());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698