| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ | 6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "content/child/thread_safe_sender.h" | 17 #include "content/child/thread_safe_sender.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "media/renderers/gpu_video_accelerator_factories.h" | 19 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 20 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class WaitableEvent; | 23 class WaitableEvent; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace gpu { | 26 namespace gpu { |
| 27 class GpuChannelHost; |
| 27 class GpuMemoryBufferManager; | 28 class GpuMemoryBufferManager; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 class ContextProviderCommandBuffer; | 32 class ContextProviderCommandBuffer; |
| 32 class GpuChannelHost; | |
| 33 class WebGraphicsContext3DCommandBufferImpl; | 33 class WebGraphicsContext3DCommandBufferImpl; |
| 34 | 34 |
| 35 // Glue code to expose functionality needed by media::GpuVideoAccelerator to | 35 // Glue code to expose functionality needed by media::GpuVideoAccelerator to |
| 36 // RenderViewImpl. This class is entirely an implementation detail of | 36 // RenderViewImpl. This class is entirely an implementation detail of |
| 37 // RenderViewImpl and only has its own header to allow extraction of its | 37 // RenderViewImpl and only has its own header to allow extraction of its |
| 38 // implementation from render_view_impl.cc which is already far too large. | 38 // implementation from render_view_impl.cc which is already far too large. |
| 39 // | 39 // |
| 40 // The RendererGpuVideoAcceleratorFactories can be constructed on any thread, | 40 // The RendererGpuVideoAcceleratorFactories can be constructed on any thread, |
| 41 // but subsequent calls to all public methods of the class must be called from | 41 // but subsequent calls to all public methods of the class must be called from |
| 42 // the |task_runner_|, as provided during construction. | 42 // the |task_runner_|, as provided during construction. |
| 43 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories | 43 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories |
| 44 : public media::GpuVideoAcceleratorFactories { | 44 : public media::GpuVideoAcceleratorFactories { |
| 45 public: | 45 public: |
| 46 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each | 46 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each |
| 47 // use. Safe to call from any thread. | 47 // use. Safe to call from any thread. |
| 48 static scoped_ptr<RendererGpuVideoAcceleratorFactories> Create( | 48 static scoped_ptr<RendererGpuVideoAcceleratorFactories> Create( |
| 49 GpuChannelHost* gpu_channel_host, | 49 gpu::GpuChannelHost* gpu_channel_host, |
| 50 const scoped_refptr<base::SingleThreadTaskRunner>& | 50 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 51 main_thread_task_runner, | 51 main_thread_task_runner, |
| 52 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 52 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 53 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 53 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 54 bool enable_gpu_memory_buffer_video_frames, | 54 bool enable_gpu_memory_buffer_video_frames, |
| 55 std::vector<unsigned> image_texture_targets, | 55 std::vector<unsigned> image_texture_targets, |
| 56 bool enable_video_accelerator); | 56 bool enable_video_accelerator); |
| 57 | 57 |
| 58 // media::GpuVideoAcceleratorFactories implementation. | 58 // media::GpuVideoAcceleratorFactories implementation. |
| 59 bool IsGpuVideoAcceleratorEnabled() override; | 59 bool IsGpuVideoAcceleratorEnabled() override; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 90 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 91 GetVideoEncodeAcceleratorSupportedProfiles() override; | 91 GetVideoEncodeAcceleratorSupportedProfiles() override; |
| 92 | 92 |
| 93 void ReleaseContextProvider(); | 93 void ReleaseContextProvider(); |
| 94 scoped_refptr<ContextProviderCommandBuffer> ContextProviderMainThread(); | 94 scoped_refptr<ContextProviderCommandBuffer> ContextProviderMainThread(); |
| 95 | 95 |
| 96 ~RendererGpuVideoAcceleratorFactories() override; | 96 ~RendererGpuVideoAcceleratorFactories() override; |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 RendererGpuVideoAcceleratorFactories( | 99 RendererGpuVideoAcceleratorFactories( |
| 100 GpuChannelHost* gpu_channel_host, | 100 gpu::GpuChannelHost* gpu_channel_host, |
| 101 const scoped_refptr<base::SingleThreadTaskRunner>& | 101 const scoped_refptr<base::SingleThreadTaskRunner>& |
| 102 main_thread_task_runner, | 102 main_thread_task_runner, |
| 103 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 103 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 104 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, | 104 const scoped_refptr<ContextProviderCommandBuffer>& context_provider, |
| 105 bool enable_gpu_memory_buffer_video_frames, | 105 bool enable_gpu_memory_buffer_video_frames, |
| 106 std::vector<unsigned> image_texture_targets, | 106 std::vector<unsigned> image_texture_targets, |
| 107 bool enable_video_accelerator); | 107 bool enable_video_accelerator); |
| 108 | 108 |
| 109 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 109 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 111 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 111 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host_; |
| 112 | 112 |
| 113 // Shared pointer to a shared context provider that should be accessed | 113 // Shared pointer to a shared context provider that should be accessed |
| 114 // and set only on the main thread. | 114 // and set only on the main thread. |
| 115 scoped_refptr<ContextProviderCommandBuffer> context_provider_refptr_; | 115 scoped_refptr<ContextProviderCommandBuffer> context_provider_refptr_; |
| 116 | 116 |
| 117 // Raw pointer to a context provider accessed from the media thread. | 117 // Raw pointer to a context provider accessed from the media thread. |
| 118 ContextProviderCommandBuffer* context_provider_; | 118 ContextProviderCommandBuffer* context_provider_; |
| 119 | 119 |
| 120 // Whether gpu memory buffers should be used to hold video frames data. | 120 // Whether gpu memory buffers should be used to hold video frames data. |
| 121 bool enable_gpu_memory_buffer_video_frames_; | 121 bool enable_gpu_memory_buffer_video_frames_; |
| 122 const std::vector<unsigned> image_texture_targets_; | 122 const std::vector<unsigned> image_texture_targets_; |
| 123 // Whether video acceleration encoding/decoding should be enabled. | 123 // Whether video acceleration encoding/decoding should be enabled. |
| 124 const bool video_accelerator_enabled_; | 124 const bool video_accelerator_enabled_; |
| 125 | 125 |
| 126 gpu::GpuMemoryBufferManager* const gpu_memory_buffer_manager_; | 126 gpu::GpuMemoryBufferManager* const gpu_memory_buffer_manager_; |
| 127 | 127 |
| 128 // For sending requests to allocate shared memory in the Browser process. | 128 // For sending requests to allocate shared memory in the Browser process. |
| 129 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 129 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories); | 131 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 } // namespace content | 134 } // namespace content |
| 135 | 135 |
| 136 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ | 136 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ |
| OLD | NEW |