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.
5 #ifndef CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_
6 #define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "gpu/config/gpu_info.h"
11 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
14 class SingleThreadTaskRunner
;
18 class BeginFrameSource
;
19 class ContextProvider
;
24 class ContextProviderWebContext
;
28 class WebGraphicsContext3DInProcessCommandBufferImpl
;
33 class InputHandlerManagerClient
;
34 class StreamTextureFactory
;
35 class FrameSwapMessageQueue
;
37 // Decouples creation from usage of the parts needed for the synchonous
38 // compositor rendering path. In practice this is only used in single
39 // process mode (namely, for Android WebView) hence the implementation of
40 // this will be injected from the logical 'browser' side code.
41 class SynchronousCompositorFactory
{
43 // Must only be called once, e.g. on startup. Ownership of |instance| remains
45 static void SetInstance(SynchronousCompositorFactory
* instance
);
46 static SynchronousCompositorFactory
* GetInstance();
48 virtual scoped_refptr
<base::SingleThreadTaskRunner
>
49 GetCompositorTaskRunner() = 0;
50 virtual bool RecordFullLayer() = 0;
51 virtual scoped_ptr
<cc::OutputSurface
> CreateOutputSurface(
53 scoped_refptr
<FrameSwapMessageQueue
> frame_swap_message_queue
) = 0;
55 // The factory maintains ownership of the returned interface.
56 virtual InputHandlerManagerClient
* GetInputHandlerManagerClient() = 0;
58 virtual scoped_ptr
<cc::BeginFrameSource
> CreateExternalBeginFrameSource(
60 virtual scoped_refptr
<StreamTextureFactory
> CreateStreamTextureFactory(
63 // Methods below should not be called if OverrideWithFactory is false.
64 // Instead, just fallback to default implementation, as if factory
66 virtual bool OverrideWithFactory();
67 virtual scoped_refptr
<cc_blink::ContextProviderWebContext
>
68 CreateOffscreenContextProvider(
69 const blink::WebGraphicsContext3D::Attributes
& attributes
,
70 const std::string
& debug_name
) = 0;
71 virtual gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl
*
72 CreateOffscreenGraphicsContext3D(
73 const blink::WebGraphicsContext3D::Attributes
& attributes
) = 0;
74 virtual gpu::GPUInfo
GetGPUInfo() const = 0;
77 SynchronousCompositorFactory() {}
78 virtual ~SynchronousCompositorFactory() {}
83 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_FACTORY_H_