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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "content/child/thread_safe_sender.h" |
14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
15 #include "media/filters/gpu_video_accelerator_factories.h" | 16 #include "media/filters/gpu_video_accelerator_factories.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class MessageLoopProxy; | 21 class MessageLoopProxy; |
21 class WaitableEvent; | 22 class WaitableEvent; |
22 } | 23 } |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class GpuChannelHost; | 26 class GpuChannelHost; |
26 class WebGraphicsContext3DCommandBufferImpl; | 27 class WebGraphicsContext3DCommandBufferImpl; |
27 | 28 |
28 // Glue code to expose functionality needed by media::GpuVideoAccelerator to | 29 // Glue code to expose functionality needed by media::GpuVideoAccelerator to |
29 // RenderViewImpl. This class is entirely an implementation detail of | 30 // RenderViewImpl. This class is entirely an implementation detail of |
30 // RenderViewImpl and only has its own header to allow extraction of its | 31 // RenderViewImpl and only has its own header to allow extraction of its |
31 // implementation from render_view_impl.cc which is already far too large. | 32 // implementation from render_view_impl.cc which is already far too large. |
32 // | 33 // |
33 // The public methods of the class can be called from any thread, and are | 34 // The public methods of the class can be called from any thread, and are |
34 // internally trampolined to the appropriate thread. GPU/GL-related calls go to | 35 // internally trampolined to the appropriate thread. GPU/GL-related calls go to |
35 // the constructor-argument loop (the media thread), and shmem-related calls go | 36 // the constructor-argument loop (the media thread). |
36 // to the render thread. | |
37 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories | 37 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories |
38 : public media::GpuVideoAcceleratorFactories { | 38 : public media::GpuVideoAcceleratorFactories { |
39 public: | 39 public: |
40 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each | 40 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each |
41 // use. | 41 // use. |
42 RendererGpuVideoAcceleratorFactories( | 42 RendererGpuVideoAcceleratorFactories( |
43 GpuChannelHost* gpu_channel_host, | 43 GpuChannelHost* gpu_channel_host, |
44 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 44 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
45 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); | 45 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); |
46 | 46 |
(...skipping 28 matching lines...) Expand all Loading... |
75 friend class base::RefCountedThreadSafe<RendererGpuVideoAcceleratorFactories>; | 75 friend class base::RefCountedThreadSafe<RendererGpuVideoAcceleratorFactories>; |
76 virtual ~RendererGpuVideoAcceleratorFactories(); | 76 virtual ~RendererGpuVideoAcceleratorFactories(); |
77 | 77 |
78 private: | 78 private: |
79 RendererGpuVideoAcceleratorFactories(); | 79 RendererGpuVideoAcceleratorFactories(); |
80 | 80 |
81 // Helper for the constructor to acquire the ContentGLContext on | 81 // Helper for the constructor to acquire the ContentGLContext on |
82 // |message_loop_|. | 82 // |message_loop_|. |
83 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context); | 83 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context); |
84 | 84 |
85 // Async versions of the public methods. They use output parameters instead | 85 // Async versions of the public methods, run on |message_loop_|. |
86 // of return values and each takes a WaitableEvent* param to signal completion | 86 // They use output parameters instead of return values and each takes |
87 // (except for DeleteTexture, which is fire-and-forget). | 87 // a WaitableEvent* param to signal completion (except for DeleteTexture, |
88 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on | 88 // which is fire-and-forget). |
89 // |message_loop_|. | |
90 // AsyncCreateVideoDecodeAccelerator returns its output in the |vda_| member. | 89 // AsyncCreateVideoDecodeAccelerator returns its output in the |vda_| member. |
91 // AsyncCreateVideoEncodeAccelerator returns its output in the |vea_| member. | 90 // AsyncCreateVideoEncodeAccelerator returns its output in the |vea_| member. |
92 void AsyncCreateVideoDecodeAccelerator( | 91 void AsyncCreateVideoDecodeAccelerator( |
93 media::VideoCodecProfile profile, | 92 media::VideoCodecProfile profile, |
94 media::VideoDecodeAccelerator::Client* client); | 93 media::VideoDecodeAccelerator::Client* client); |
95 void AsyncCreateVideoEncodeAccelerator( | 94 void AsyncCreateVideoEncodeAccelerator( |
96 media::VideoEncodeAccelerator::Client* client); | 95 media::VideoEncodeAccelerator::Client* client); |
97 void AsyncCreateTextures(int32 count, | 96 void AsyncCreateTextures(int32 count, |
98 const gfx::Size& size, | 97 const gfx::Size& size, |
99 uint32 texture_target, | 98 uint32 texture_target, |
100 uint32* sync_point); | 99 uint32* sync_point); |
101 void AsyncDeleteTexture(uint32 texture_id); | 100 void AsyncDeleteTexture(uint32 texture_id); |
102 void AsyncWaitSyncPoint(uint32 sync_point); | 101 void AsyncWaitSyncPoint(uint32 sync_point); |
103 void AsyncReadPixels(uint32 texture_id, | 102 void AsyncReadPixels(uint32 texture_id, |
104 uint32 texture_target, | 103 uint32 texture_target, |
105 const gfx::Size& size); | 104 const gfx::Size& size); |
106 void AsyncCreateSharedMemory(size_t size); | |
107 void AsyncDestroyVideoDecodeAccelerator(); | 105 void AsyncDestroyVideoDecodeAccelerator(); |
108 void AsyncDestroyVideoEncodeAccelerator(); | 106 void AsyncDestroyVideoEncodeAccelerator(); |
109 | 107 |
110 scoped_refptr<base::MessageLoopProxy> message_loop_; | 108 scoped_refptr<base::MessageLoopProxy> message_loop_; |
111 scoped_refptr<base::MessageLoopProxy> main_message_loop_; | |
112 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 109 scoped_refptr<GpuChannelHost> gpu_channel_host_; |
113 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_; | 110 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_; |
114 | 111 |
| 112 // For sending requests to allocate shared memory in the Browser process. |
| 113 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 114 |
115 // This event is signaled if we have been asked to Abort(). | 115 // This event is signaled if we have been asked to Abort(). |
116 base::WaitableEvent aborted_waiter_; | 116 base::WaitableEvent aborted_waiter_; |
117 | 117 |
118 // This event is signaled by asynchronous tasks posted to |message_loop_| to | 118 // This event is signaled by asynchronous tasks posted to |message_loop_| to |
119 // indicate their completion. | 119 // indicate their completion. |
120 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc. | 120 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc. |
121 base::WaitableEvent message_loop_async_waiter_; | 121 base::WaitableEvent message_loop_async_waiter_; |
122 | 122 |
123 // This event is signaled by asynchronous tasks posted to the renderer thread | |
124 // message loop to indicate their completion. e.g. AsyncCreateSharedMemory. | |
125 base::WaitableEvent render_thread_async_waiter_; | |
126 | |
127 // The vda returned by the CreateVideoDecodeAccelerator function. | 123 // The vda returned by the CreateVideoDecodeAccelerator function. |
128 scoped_ptr<media::VideoDecodeAccelerator> vda_; | 124 scoped_ptr<media::VideoDecodeAccelerator> vda_; |
129 | 125 |
130 // The vea returned by the CreateVideoEncodeAccelerator function. | 126 // The vea returned by the CreateVideoEncodeAccelerator function. |
131 scoped_ptr<media::VideoEncodeAccelerator> vea_; | 127 scoped_ptr<media::VideoEncodeAccelerator> vea_; |
132 | 128 |
133 // Shared memory segment which is returned by the CreateSharedMemory() | |
134 // function. | |
135 scoped_ptr<base::SharedMemory> shared_memory_segment_; | |
136 | |
137 // Bitmap returned by ReadPixels(). | 129 // Bitmap returned by ReadPixels(). |
138 SkBitmap read_pixels_bitmap_; | 130 SkBitmap read_pixels_bitmap_; |
139 | 131 |
140 // Textures returned by the CreateTexture() function. | 132 // Textures returned by the CreateTexture() function. |
141 std::vector<uint32> created_textures_; | 133 std::vector<uint32> created_textures_; |
142 std::vector<gpu::Mailbox> created_texture_mailboxes_; | 134 std::vector<gpu::Mailbox> created_texture_mailboxes_; |
143 | 135 |
144 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories); | 136 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories); |
145 }; | 137 }; |
146 | 138 |
147 } // namespace content | 139 } // namespace content |
148 | 140 |
149 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ | 141 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ |
OLD | NEW |