1 // Copyright (c) 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.
5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
6 #define CONTENT_RENDERER_ANDOIRD_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/output/output_surface.h"
12 #include "content/public/renderer/android/synchronous_compositor.h"
16 class SynchronousCompositorClient
;
17 class WebGraphicsContext3DCommandBufferImpl
;
19 // Specialization of the output surface that adapts it to implement the
20 // content::SynchronousCompositor public API. This class effects an "inversion
21 // of control" - enabling drawing to be orchestrated by the embedding
22 // layer, instead of driven by the compositor internals - hence it holds two
23 // 'client' pointers (including |client_| in the OutputSurface baseclass) which
24 // represent the consumers of the two roles in plays.
25 // This class can be created only on the main thread, but then becomes pinned
26 // to a fixed thread when BindToClient is called.
27 class SynchronousCompositorOutputSurface
28 : NON_EXPORTED_BASE(public cc::OutputSurface
),
29 NON_EXPORTED_BASE(public SynchronousCompositor
) {
31 SynchronousCompositorOutputSurface(
33 WebGraphicsContext3DCommandBufferImpl
* context
);
34 virtual ~SynchronousCompositorOutputSurface();
37 virtual bool BindToClient(cc::OutputSurfaceClient
* surface_client
) OVERRIDE
;
38 virtual void SendFrameToParentCompositor(cc::CompositorFrame
* frame
) OVERRIDE
;
40 // SynchronousCompositor.
41 virtual void SetClient(SynchronousCompositorClient
* compositor_client
)
43 virtual bool DemandDrawSw(SkCanvas
* canvas
) OVERRIDE
;
46 bool CalledOnValidThread() const;
48 SynchronousCompositorClient
* compositor_client_
;
51 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface
);
54 } // namespace content
56 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_