Chromium Code Reviews| 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..e0d5cdd148f3e1ebbc7ca546e8831d5b30b27f4a |
| --- /dev/null |
| +++ b/content/renderer/android/synchronous_compositor_impl.cc |
| @@ -0,0 +1,90 @@ |
| +// 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 "cc/input/input_handler.h" |
| +#include "content/public/renderer/android/synchronous_compositor_client.h" |
| +#include "content/public/renderer/content_renderer_client.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>(); |
| +} |
| + |
| +bool SynchronousCompositorImpl::IsHwReady() { |
| + DCHECK(CalledOnValidThread()); |
| + DCHECK(output_surface_); |
| + |
| + if (!output_surface_) |
| + 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
|
| + 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; |
|
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.
|
| +} |
| + |
| +// 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 |