Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / android / in_process / synchronous_compositor_factory_impl.h
blob81a49301d21577f025a6ab90560f341adde98643
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/renderer/android/synchronous_compositor_factory.h"
12 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl.h"
13 #include "gpu/command_buffer/service/in_process_command_buffer.h"
15 namespace gpu {
16 class GLInProcessContext;
19 namespace gpu_blink {
20 class WebGraphicsContext3DInProcessCommandBufferImpl;
23 namespace content {
25 class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
26 public:
27 SynchronousCompositorFactoryImpl();
28 ~SynchronousCompositorFactoryImpl() override;
30 // SynchronousCompositorFactory
31 scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop() override;
32 bool RecordFullLayer() override;
33 scoped_ptr<cc::OutputSurface> CreateOutputSurface(
34 int routing_id,
35 scoped_refptr<content::FrameSwapMessageQueue> frame_swap_message_queue)
36 override;
37 InputHandlerManagerClient* GetInputHandlerManagerClient() override;
38 scoped_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource(
39 int routing_id) override;
40 scoped_refptr<cc_blink::ContextProviderWebContext>
41 CreateOffscreenContextProvider(
42 const blink::WebGraphicsContext3D::Attributes& attributes,
43 const std::string& debug_name) override;
44 scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
45 int view_id) override;
46 gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl*
47 CreateOffscreenGraphicsContext3D(
48 const blink::WebGraphicsContext3D::Attributes& attributes) override;
50 SynchronousInputEventFilter* synchronous_input_event_filter() {
51 return &synchronous_input_event_filter_;
54 void SetDeferredGpuService(
55 scoped_refptr<gpu::InProcessCommandBuffer::Service> service);
56 void SetRecordFullDocument(bool record_full_document);
57 void CompositorInitializedHardwareDraw();
58 void CompositorReleasedHardwareDraw();
60 scoped_refptr<cc::ContextProvider> CreateContextProviderForCompositor();
62 private:
63 bool CanCreateMainThreadContext();
64 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
65 TryCreateStreamTextureFactory();
66 void RestoreContextOnMainThread();
68 SynchronousInputEventFilter synchronous_input_event_filter_;
70 scoped_refptr<gpu::InProcessCommandBuffer::Service> service_;
72 class VideoContextProvider;
73 scoped_refptr<VideoContextProvider> video_context_provider_;
75 bool record_full_layer_;
77 // |num_hardware_compositor_lock_| is updated on UI thread only but can be
78 // read on renderer main thread.
79 base::Lock num_hardware_compositor_lock_;
80 unsigned int num_hardware_compositors_;
81 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_;
84 } // namespace content
86 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H_