1 // Copyright 2014 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_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_
8 #include "base/synchronization/lock.h"
9 #include "cc/blink/context_provider_web_context.h"
10 #include "content/browser/android/in_process/synchronous_input_event_filter.h"
11 #include "content/common/gpu/client/command_buffer_metrics.h"
12 #include "content/renderer/android/synchronous_compositor_factory.h"
13 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl.h"
14 #include "gpu/command_buffer/service/in_process_command_buffer.h"
21 class GLInProcessContext
;
25 class WebGraphicsContext3DInProcessCommandBufferImpl
;
30 class InProcessChildThreadParams
;
32 class SynchronousCompositorFactoryImpl
: public SynchronousCompositorFactory
{
34 SynchronousCompositorFactoryImpl();
35 ~SynchronousCompositorFactoryImpl() override
;
37 // SynchronousCompositorFactory
38 scoped_refptr
<base::SingleThreadTaskRunner
> GetCompositorTaskRunner()
40 scoped_ptr
<cc::OutputSurface
> CreateOutputSurface(
43 scoped_refptr
<content::FrameSwapMessageQueue
> frame_swap_message_queue
)
45 InputHandlerManagerClient
* GetInputHandlerManagerClient() override
;
46 scoped_ptr
<cc::BeginFrameSource
> CreateExternalBeginFrameSource(
47 int routing_id
) override
;
48 scoped_refptr
<StreamTextureFactory
> CreateStreamTextureFactory(
49 int view_id
) override
;
50 bool OverrideWithFactory() override
;
51 scoped_refptr
<cc_blink::ContextProviderWebContext
>
52 CreateOffscreenContextProvider(
53 const blink::WebGraphicsContext3D::Attributes
& attributes
,
54 const std::string
& debug_name
) override
;
55 gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl
*
56 CreateOffscreenGraphicsContext3D(
57 const blink::WebGraphicsContext3D::Attributes
& attributes
) override
;
58 gpu::GPUInfo
GetGPUInfo() const override
;
60 SynchronousInputEventFilter
* synchronous_input_event_filter() {
61 return &synchronous_input_event_filter_
;
64 void SetDeferredGpuService(
65 scoped_refptr
<gpu::InProcessCommandBuffer::Service
> service
);
66 base::Thread
* CreateInProcessGpuThread(
67 const InProcessChildThreadParams
& params
);
68 void SetUseIpcCommandBuffer();
69 void CompositorInitializedHardwareDraw();
70 void CompositorReleasedHardwareDraw();
74 scoped_refptr
<cc::ContextProvider
> CreateContextProviderForCompositor(
76 CommandBufferContextType type
);
77 bool CanCreateMainThreadContext();
78 scoped_refptr
<StreamTextureFactorySynchronousImpl::ContextProvider
>
79 TryCreateStreamTextureFactory();
80 void RestoreContextOnMainThread();
81 scoped_refptr
<gpu::InProcessCommandBuffer::Service
> GpuThreadService();
83 SynchronousInputEventFilter synchronous_input_event_filter_
;
85 scoped_refptr
<gpu::InProcessCommandBuffer::Service
> android_view_service_
;
86 scoped_refptr
<gpu::InProcessCommandBuffer::Service
> gpu_thread_service_
;
88 class VideoContextProvider
;
89 scoped_refptr
<VideoContextProvider
> video_context_provider_
;
91 bool use_ipc_command_buffer_
;
93 // |num_hardware_compositor_lock_| is updated on UI thread only but can be
94 // read on renderer main thread.
95 base::Lock num_hardware_compositor_lock_
;
96 unsigned int num_hardware_compositors_
;
97 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner_
;
100 } // namespace content
102 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_