Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/android/synchronous_compositor_impl.h" | |
| 6 | |
| 7 #include "base/message_loop.h" | |
| 8 #include "content/public/renderer/android/synchronous_compositor_client.h" | |
| 9 #include "content/public/renderer/content_renderer_client.h" | |
| 10 #include "content/renderer/android/synchronous_compositor_input_handler_client_w rapper.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 SynchronousCompositorImpl::SynchronousCompositorImpl(int32 routing_id) | |
| 15 : routing_id_(routing_id), compositor_client_(NULL) {} | |
| 16 | |
| 17 SynchronousCompositorImpl::~SynchronousCompositorImpl() { | |
| 18 } | |
| 19 | |
| 20 scoped_ptr<cc::OutputSurface> | |
| 21 SynchronousCompositorImpl::CreateOutputSurface() { | |
| 22 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( | |
| 23 new SynchronousCompositorOutputSurface(this)); | |
| 24 output_surface_ = output_surface.get(); | |
| 25 return output_surface.PassAs<cc::OutputSurface>(); | |
| 26 } | |
| 27 | |
| 28 scoped_ptr<cc::InputHandlerClient> | |
| 29 SynchronousCompositorImpl::CreateInputHandlerClientWrapper( | |
| 30 scoped_ptr<cc::InputHandlerClient> wrapped_client) { | |
| 31 return make_scoped_ptr( | |
| 32 new SynchronousCompositorInputHandlerClientWrapper(wrapped_client.Pass(), | |
| 33 this)) | |
| 34 .PassAs<cc::InputHandlerClient>(); | |
|
joth
2013/05/16 18:21:42
awkward to read. Maybe easier to just allocate a s
| |
| 35 } | |
| 36 | |
| 37 bool SynchronousCompositorImpl::IsHwReady() { | |
| 38 DCHECK(CalledOnValidThread()); | |
| 39 DCHECK(output_surface_); | |
| 40 | |
| 41 if (!output_surface_) | |
| 42 return false; | |
| 43 return output_surface_->IsHwReady(); | |
| 44 } | |
| 45 | |
| 46 void SynchronousCompositorImpl::SetClient( | |
| 47 SynchronousCompositorClient* compositor_client) { | |
| 48 DCHECK(CalledOnValidThread()); | |
| 49 compositor_client_ = compositor_client; | |
| 50 } | |
| 51 | |
| 52 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | |
| 53 DCHECK(CalledOnValidThread()); | |
| 54 DCHECK(output_surface_); | |
| 55 | |
| 56 if (!output_surface_) | |
| 57 return false; | |
| 58 | |
| 59 return output_surface_->DemandDrawSw(canvas); | |
| 60 } | |
| 61 | |
| 62 bool SynchronousCompositorImpl::DemandDrawHw( | |
| 63 gfx::Size view_size, | |
| 64 const gfx::Transform& transform, | |
| 65 gfx::Rect damage_area) { | |
| 66 DCHECK(CalledOnValidThread()); | |
| 67 DCHECK(output_surface_); | |
| 68 | |
| 69 if (!output_surface_) | |
| 70 return false; | |
| 71 return output_surface_->DemandDrawHw(view_size, transform, damage_area); | |
| 72 } | |
| 73 | |
| 74 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { | |
| 75 DCHECK(CalledOnValidThread()); | |
| 76 compositor_client_->SetContinuousInvalidate(enable); | |
| 77 } | |
| 78 | |
| 79 void SynchronousCompositorImpl::DidCreateSynchronousCompositor() { | |
| 80 DCHECK(CalledOnValidThread()); | |
| 81 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, | |
| 82 this); | |
| 83 } | |
| 84 | |
| 85 void SynchronousCompositorImpl::DidDestroyCompositor() { | |
| 86 DCHECK(CalledOnValidThread()); | |
| 87 output_surface_ = NULL; | |
| 88 } | |
| 89 | |
| 90 void SynchronousCompositorImpl::SetTotalScrollOffset(gfx::Vector2dF new_value) { | |
| 91 DCHECK(CalledOnValidThread()); | |
| 92 compositor_client_->SetTotalRootLayerScrollOffset(new_value); | |
| 93 } | |
| 94 | |
| 95 gfx::Vector2dF SynchronousCompositorImpl::GetTotalScrollOffset() { | |
| 96 DCHECK(CalledOnValidThread()); | |
| 97 return compositor_client_->GetTotalRootLayerScrollOffset(); | |
| 98 } | |
| 99 | |
| 100 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | |
| 101 // requirement: SynchronousCompositorImpl() must only be used by | |
| 102 // embedders that supply their own compositor loop via | |
| 103 // OverrideCompositorMessageLoop(). | |
| 104 bool SynchronousCompositorImpl::CalledOnValidThread() const { | |
| 105 return base::MessageLoop::current() && (base::MessageLoop::current() == | |
| 106 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); | |
| 107 } | |
| 108 | |
| 109 } // namespace content | |
| OLD | NEW |