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

Side by Side 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, 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 | Annotate | Revision Log
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/renderer/android/synchronous_compositor_impl.h" 5 #include "content/renderer/android/synchronous_compositor_impl.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "cc/input/input_handler.h" 8 #include "cc/input/input_handler.h"
9 #include "content/public/renderer/android/synchronous_compositor_client.h" 9 #include "content/public/renderer/android/synchronous_compositor_client.h"
10 #include "content/public/renderer/content_renderer_client.h" 10 #include "content/public/renderer/content_renderer_client.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 SynchronousCompositorImpl::SynchronousCompositorImpl(int32 routing_id) 14 SynchronousCompositorImpl::SynchronousCompositorImpl(int32 routing_id)
15 : routing_id_(routing_id), compositor_client_(NULL) {} 15 : routing_id_(routing_id), compositor_client_(NULL) {
16 }
16 17
17 SynchronousCompositorImpl::~SynchronousCompositorImpl() { 18 SynchronousCompositorImpl::~SynchronousCompositorImpl() {
18 } 19 }
19 20
20 scoped_ptr<cc::OutputSurface> 21 scoped_ptr<cc::OutputSurface>
21 SynchronousCompositorImpl::CreateOutputSurface() { 22 SynchronousCompositorImpl::CreateOutputSurface() {
22 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( 23 scoped_ptr<SynchronousCompositorOutputSurface> output_surface(
23 new SynchronousCompositorOutputSurface(this)); 24 new SynchronousCompositorOutputSurface(this));
24 output_surface_ = output_surface.get(); 25 output_surface_ = output_surface.get();
25 return output_surface.PassAs<cc::OutputSurface>(); 26 return output_surface.PassAs<cc::OutputSurface>();
(...skipping 24 matching lines...) Expand all
50 const gfx::Transform& transform, 51 const gfx::Transform& transform,
51 gfx::Rect damage_area) { 52 gfx::Rect damage_area) {
52 DCHECK(CalledOnValidThread()); 53 DCHECK(CalledOnValidThread());
53 DCHECK(output_surface_); 54 DCHECK(output_surface_);
54 55
55 return output_surface_->DemandDrawHw(view_size, transform, damage_area); 56 return output_surface_->DemandDrawHw(view_size, transform, damage_area);
56 } 57 }
57 58
58 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { 59 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) {
59 DCHECK(CalledOnValidThread()); 60 DCHECK(CalledOnValidThread());
60 // compositor_client_ can be NULL during WebContents teardown.
61 if (compositor_client_) 61 if (compositor_client_)
62 compositor_client_->SetContinuousInvalidate(enable); 62 compositor_client_->SetContinuousInvalidate(enable);
63 } 63 }
64 64
65 void SynchronousCompositorImpl::DidCreateSynchronousOutputSurface() { 65 void SynchronousCompositorImpl::DidCreateSynchronousOutputSurface() {
66 DCHECK(CalledOnValidThread()); 66 DCHECK(CalledOnValidThread());
67 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, 67 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_,
68 this); 68 this);
69 } 69 }
70 70
71 void SynchronousCompositorImpl::DidDestroySynchronousOutputSurface() { 71 void SynchronousCompositorImpl::DidDestroySynchronousOutputSurface() {
72 DCHECK(CalledOnValidThread()); 72 DCHECK(CalledOnValidThread());
73 output_surface_ = NULL; 73 output_surface_ = NULL;
74 // compositor_client_ can be NULL during WebContents teardown.
75 if (compositor_client_) 74 if (compositor_client_)
76 compositor_client_->DidDestroyCompositor(this); 75 compositor_client_->DidDestroyCompositor(this);
77 } 76 }
78 77
78 void SynchronousCompositorImpl::SetTotalScrollOffset(gfx::Vector2dF new_value) {
79 DCHECK(CalledOnValidThread());
80 if (compositor_client_)
81 compositor_client_->SetTotalRootLayerScrollOffset(new_value);
82 }
83
84 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() {
85 DCHECK(CalledOnValidThread());
86 if (compositor_client_)
87 return compositor_client_->GetTotalRootLayerScrollOffset();
88 else
89 return gfx::Vector2dF();
mkosiba (inactive) 2013/05/29 13:18:24 this is the only downside of checking for composit
90 }
91
79 // Not using base::NonThreadSafe as we want to enforce a more exacting threading 92 // Not using base::NonThreadSafe as we want to enforce a more exacting threading
80 // requirement: SynchronousCompositorImpl() must only be used by 93 // requirement: SynchronousCompositorImpl() must only be used by
81 // embedders that supply their own compositor loop via 94 // embedders that supply their own compositor loop via
82 // OverrideCompositorMessageLoop(). 95 // OverrideCompositorMessageLoop().
83 bool SynchronousCompositorImpl::CalledOnValidThread() const { 96 bool SynchronousCompositorImpl::CalledOnValidThread() const {
84 return base::MessageLoop::current() && (base::MessageLoop::current() == 97 return base::MessageLoop::current() && (base::MessageLoop::current() ==
85 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); 98 GetContentClient()->renderer()->OverrideCompositorMessageLoop());
86 } 99 }
87 100
88 } // namespace content 101 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_impl.h ('k') | content/renderer/gpu/input_handler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698