| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ |
| 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMPL_H
_ |
| 7 | 7 |
| 8 #include "base/lazy_instance.h" | |
| 9 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
| 10 #include "cc/blink/context_provider_web_context.h" | 9 #include "cc/blink/context_provider_web_context.h" |
| 11 #include "content/browser/android/in_process/synchronous_input_event_filter.h" | 10 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
| 12 #include "content/common/gpu/client/command_buffer_metrics.h" | 11 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 13 #include "content/renderer/android/synchronous_compositor_factory.h" | 12 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 14 #include "content/renderer/media/android/stream_texture_factory_synchronous_impl
.h" | |
| 15 #include "gpu/command_buffer/service/in_process_command_buffer.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class Thread; | |
| 19 } | |
| 20 | |
| 21 namespace gpu { | |
| 22 class GLInProcessContext; | |
| 23 } | |
| 24 | |
| 25 namespace gpu_blink { | |
| 26 class WebGraphicsContext3DInProcessCommandBufferImpl; | |
| 27 } | |
| 28 | 13 |
| 29 namespace content { | 14 namespace content { |
| 30 | 15 |
| 31 class InProcessChildThreadParams; | |
| 32 class ContextProviderCommandBuffer; | |
| 33 | |
| 34 class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { | 16 class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { |
| 35 public: | 17 public: |
| 36 SynchronousCompositorFactoryImpl(); | 18 SynchronousCompositorFactoryImpl(); |
| 37 ~SynchronousCompositorFactoryImpl() override; | 19 ~SynchronousCompositorFactoryImpl() override; |
| 38 | 20 |
| 39 // SynchronousCompositorFactory | 21 // SynchronousCompositorFactory |
| 40 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() | 22 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() |
| 41 override; | 23 override; |
| 42 std::unique_ptr<cc::OutputSurface> CreateOutputSurface( | 24 std::unique_ptr<cc::OutputSurface> CreateOutputSurface( |
| 43 int routing_id, | 25 int routing_id, |
| 44 uint32_t output_surface_id, | 26 uint32_t output_surface_id, |
| 45 const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, | 27 const scoped_refptr<FrameSwapMessageQueue>& frame_swap_message_queue, |
| 46 const scoped_refptr<cc::ContextProvider>& onscreen_context, | 28 const scoped_refptr<cc::ContextProvider>& onscreen_context, |
| 47 const scoped_refptr<cc::ContextProvider>& worker_context) override; | 29 const scoped_refptr<cc::ContextProvider>& worker_context) override; |
| 48 InputHandlerManagerClient* GetInputHandlerManagerClient() override; | 30 InputHandlerManagerClient* GetInputHandlerManagerClient() override; |
| 49 SynchronousInputHandlerProxyClient* GetSynchronousInputHandlerProxyClient() | 31 SynchronousInputHandlerProxyClient* GetSynchronousInputHandlerProxyClient() |
| 50 override; | 32 override; |
| 51 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( | 33 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( |
| 52 int routing_id) override; | 34 int routing_id) override; |
| 53 | 35 |
| 54 SynchronousInputEventFilter* synchronous_input_event_filter() { | 36 SynchronousInputEventFilter* synchronous_input_event_filter() { |
| 55 return &synchronous_input_event_filter_; | 37 return &synchronous_input_event_filter_; |
| 56 } | 38 } |
| 57 | 39 |
| 58 private: | 40 private: |
| 59 SynchronousInputEventFilter synchronous_input_event_filter_; | 41 SynchronousInputEventFilter synchronous_input_event_filter_; |
| 60 }; | 42 }; |
| 61 | 43 |
| 62 class SynchronousCompositorStreamTextureFactoryImpl { | |
| 63 public: | |
| 64 static SynchronousCompositorStreamTextureFactoryImpl* GetInstance(); | |
| 65 | |
| 66 scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(); | |
| 67 void SetDeferredGpuService( | |
| 68 scoped_refptr<gpu::InProcessCommandBuffer::Service> service); | |
| 69 void CompositorInitializedHardwareDraw(); | |
| 70 void CompositorReleasedHardwareDraw(); | |
| 71 | |
| 72 private: | |
| 73 friend struct base::DefaultLazyInstanceTraits< | |
| 74 SynchronousCompositorStreamTextureFactoryImpl>; | |
| 75 | |
| 76 SynchronousCompositorStreamTextureFactoryImpl(); | |
| 77 ~SynchronousCompositorStreamTextureFactoryImpl(); | |
| 78 | |
| 79 bool CanCreateMainThreadContext(); | |
| 80 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> | |
| 81 TryCreateStreamTextureFactory(); | |
| 82 void RestoreContextOnMainThread(); | |
| 83 | |
| 84 scoped_refptr<gpu::InProcessCommandBuffer::Service> android_view_service_; | |
| 85 | |
| 86 class VideoContextProvider; | |
| 87 scoped_refptr<VideoContextProvider> video_context_provider_; | |
| 88 | |
| 89 // |num_hardware_compositor_lock_| is updated on UI thread only but can be | |
| 90 // read on renderer main thread. | |
| 91 base::Lock num_hardware_compositor_lock_; | |
| 92 unsigned int num_hardware_compositors_; | |
| 93 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | |
| 94 }; | |
| 95 | |
| 96 } // namespace content | 44 } // namespace content |
| 97 | 45 |
| 98 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMP
L_H_ | 46 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_FACTORY_IMP
L_H_ |
| OLD | NEW |