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 "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 if (!output_surface_) | |
| 33 return false; | |
|
joth
2013/05/23 19:20:57
gracefully handling something you DCHECKed for is
mkosiba (inactive)
2013/05/24 14:42:41
Ah, yes, the DCHECK should be sufficient. The a_w
| |
| 34 return output_surface_->IsHwReady(); | |
| 35 } | |
| 36 | |
| 37 void SynchronousCompositorImpl::SetClient( | |
| 38 SynchronousCompositorClient* compositor_client) { | |
| 39 DCHECK(CalledOnValidThread()); | |
| 40 compositor_client_ = compositor_client; | |
| 41 } | |
| 42 | |
| 43 bool SynchronousCompositorImpl::DemandDrawSw(SkCanvas* canvas) { | |
| 44 DCHECK(CalledOnValidThread()); | |
| 45 DCHECK(output_surface_); | |
| 46 | |
| 47 if (!output_surface_) | |
| 48 return false; | |
| 49 | |
| 50 return output_surface_->DemandDrawSw(canvas); | |
| 51 } | |
| 52 | |
| 53 bool SynchronousCompositorImpl::DemandDrawHw( | |
| 54 gfx::Size view_size, | |
| 55 const gfx::Transform& transform, | |
| 56 gfx::Rect damage_area) { | |
| 57 DCHECK(CalledOnValidThread()); | |
| 58 DCHECK(output_surface_); | |
| 59 | |
| 60 if (!output_surface_) | |
| 61 return false; | |
| 62 return output_surface_->DemandDrawHw(view_size, transform, damage_area); | |
| 63 } | |
| 64 | |
| 65 void SynchronousCompositorImpl::SetContinuousInvalidate(bool enable) { | |
| 66 DCHECK(CalledOnValidThread()); | |
| 67 compositor_client_->SetContinuousInvalidate(enable); | |
| 68 } | |
| 69 | |
| 70 void SynchronousCompositorImpl::DidCreateSynchronousCompositor() { | |
| 71 DCHECK(CalledOnValidThread()); | |
| 72 GetContentClient()->renderer()->DidCreateSynchronousCompositor(routing_id_, | |
| 73 this); | |
| 74 } | |
| 75 | |
| 76 void SynchronousCompositorImpl::DidDestroyCompositor() { | |
| 77 DCHECK(CalledOnValidThread()); | |
| 78 output_surface_ = NULL; | |
|
joth
2013/05/23 19:20:57
you're not calling compositor_client_->DidDestroyC
mkosiba (inactive)
2013/05/24 14:42:41
simple oversight on my end. Added the call.
| |
| 79 } | |
| 80 | |
| 81 // Not using base::NonThreadSafe as we want to enforce a more exacting threading | |
| 82 // requirement: SynchronousCompositorImpl() must only be used by | |
| 83 // embedders that supply their own compositor loop via | |
| 84 // OverrideCompositorMessageLoop(). | |
| 85 bool SynchronousCompositorImpl::CalledOnValidThread() const { | |
| 86 return base::MessageLoop::current() && (base::MessageLoop::current() == | |
| 87 GetContentClient()->renderer()->OverrideCompositorMessageLoop()); | |
| 88 } | |
| 89 | |
| 90 } // namespace content | |
| OLD | NEW |