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

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: 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..c99ece0a03db5bacc38d951904a3b948c79bd483
--- /dev/null
+++ b/content/renderer/android/synchronous_compositor_impl.cc
@@ -0,0 +1,109 @@
+// 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 "content/public/renderer/android/synchronous_compositor_client.h"
+#include "content/public/renderer/content_renderer_client.h"
+#include "content/renderer/android/synchronous_compositor_input_handler_client_wrapper.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>();
+}
+
+scoped_ptr<cc::InputHandlerClient>
+SynchronousCompositorImpl::CreateInputHandlerClientWrapper(
+ scoped_ptr<cc::InputHandlerClient> wrapped_client) {
+ return make_scoped_ptr(
+ new SynchronousCompositorInputHandlerClientWrapper(wrapped_client.Pass(),
+ this))
+ .PassAs<cc::InputHandlerClient>();
joth 2013/05/16 18:21:42 awkward to read. Maybe easier to just allocate a s
+}
+
+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