| 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 "cc/input/input_handler.h" | |
| 9 #include "content/public/renderer/android/synchronous_compositor_client.h" | |
| 10 #include "content/public/renderer/content_renderer_client.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 bool SynchronousCompositorImpl::IsHwReady() { | |
| 29 DCHECK(CalledOnValidThread()); | |
| 30 DCHECK(output_surface_); | |
| 31 | |
| 32 return output_surface_->IsHwReady(); | |
| 33 } | |
| 34 | |
| 35 void SynchronousCompositorImpl::SetClient( | |
| 36 SynchronousCompositorClient* compositor_client) { | |
| 37 DCHECK(CalledOnValidThread()); | |
| 38 compositor_client_ = compositor_client; | |
| 39 } | |
| 40 | |
| 41 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | |
| 42 DCHECK(CalledOnValidThread()); | |
| 43 DCHECK(output_surface_); | |
| 44 | |
| 45 return output_surface_->DemandDrawSw(canvas); | |
| 46 } | |
| 47 | |
| 48 bool SynchronousCompositorImpl::DemandDrawHw( | |
| 49 gfx::Size view_size, | |
| 50 const gfx::Transform& transform, | |
| 51 gfx::Rect damage_area) { | |
| 52 DCHECK(CalledOnValidThread()); | |
| 53 DCHECK(output_surface_); | |
| 54 | |
| 55 return output_surface_->DemandDrawHw(view_size, transform, damage_area); | |
| 56 } | |
| 57 | |
| 58 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { | |
| 59 DCHECK(CalledOnValidThread()); | |
| 60 compositor_client_->SetContinuousInvalidate(enable); | |
| 61 } | |
| 62 | |
| 63 void SynchronousCompositorImpl::DidCreateSynchronousOutputSurface() { | |
| 64 DCHECK(CalledOnValidThread()); | |
| 65 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, | |
| 66 this); | |
| 67 } | |
| 68 | |
| 69 void SynchronousCompositorImpl::DidDestroySynchronousOutputSurface() { | |
| 70 DCHECK(CalledOnValidThread()); | |
| 71 output_surface_ = NULL; | |
| 72 compositor_client_->DidDestroyCompositor(this); | |
| 73 } | |
| 74 | |
| 75 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | |
| 76 // requirement: SynchronousCompositorImpl() must only be used by | |
| 77 // embedders that supply their own compositor loop via | |
| 78 // OverrideCompositorMessageLoop(). | |
| 79 bool SynchronousCompositorImpl::CalledOnValidThread() const { | |
| 80 return base::MessageLoop::current() && (base::MessageLoop::current() == | |
| 81 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); | |
| 82 } | |
| 83 | |
| 84 } // namespace content | |
| OLD | NEW |