| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DECODER_FACTORIES_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ | 6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class GpuChannelHost; | 25 class GpuChannelHost; |
| 26 class WebGraphicsContext3DCommandBufferImpl; | 26 class WebGraphicsContext3DCommandBufferImpl; |
| 27 | 27 |
| 28 // Glue code to expose functionality needed by media::GpuVideoDecoder to | 28 // Glue code to expose functionality needed by media::GpuVideoDecoder to |
| 29 // RenderViewImpl. This class is entirely an implementation detail of | 29 // RenderViewImpl. This class is entirely an implementation detail of |
| 30 // RenderViewImpl and only has its own header to allow extraction of its | 30 // 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. | 31 // implementation from render_view_impl.cc which is already far too large. |
| 32 // | 32 // |
| 33 // The public methods of the class can be called from any thread, and are | 33 // 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 | 34 // internally trampolined to the appropriate thread. GPU/GL-related calls go to |
| 35 // the constructor-argument loop (mostly that's the compositor thread, or the | 35 // the constructor-argument loop, and shmem-related calls go to the render |
| 36 // renderer thread if threaded compositing is disabled), and shmem-related calls | 36 // thread. |
| 37 // go to the render thread. | |
| 38 class CONTENT_EXPORT RendererGpuVideoDecoderFactories | 37 class CONTENT_EXPORT RendererGpuVideoDecoderFactories |
| 39 : public media::GpuVideoDecoder::Factories { | 38 : public media::GpuVideoDecoder::Factories { |
| 40 public: | 39 public: |
| 41 // 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 |
| 42 // use. | 41 // use. |
| 43 RendererGpuVideoDecoderFactories( | 42 RendererGpuVideoDecoderFactories( |
| 44 GpuChannelHost* gpu_channel_host, | 43 GpuChannelHost* gpu_channel_host, |
| 45 const scoped_refptr<base::MessageLoopProxy>& compositor_message_loop, | 44 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 46 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); | 45 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); |
| 47 | 46 |
| 48 // media::GpuVideoDecoder::Factories implementation. | 47 // media::GpuVideoDecoder::Factories implementation. |
| 49 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | 48 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( |
| 50 media::VideoCodecProfile profile, | 49 media::VideoCodecProfile profile, |
| 51 media::VideoDecodeAccelerator::Client* client) OVERRIDE; | 50 media::VideoDecodeAccelerator::Client* client) OVERRIDE; |
| 52 // Creates textures and produces them into mailboxes. Returns a sync point to | 51 // Creates textures and produces them into mailboxes. Returns a sync point to |
| 53 // wait on before using the mailboxes, or 0 on failure. | 52 // wait on before using the mailboxes, or 0 on failure. |
| 54 virtual uint32 CreateTextures( | 53 virtual uint32 CreateTextures( |
| 55 int32 count, const gfx::Size& size, | 54 int32 count, const gfx::Size& size, |
| 56 std::vector<uint32>* texture_ids, | 55 std::vector<uint32>* texture_ids, |
| 57 std::vector<gpu::Mailbox>* texture_mailboxes, | 56 std::vector<gpu::Mailbox>* texture_mailboxes, |
| 58 uint32 texture_target) OVERRIDE; | 57 uint32 texture_target) OVERRIDE; |
| 59 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; | 58 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; |
| 60 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; | 59 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; |
| 61 virtual void ReadPixels(uint32 texture_id, | 60 virtual void ReadPixels(uint32 texture_id, |
| 62 uint32 texture_target, | 61 uint32 texture_target, |
| 63 const gfx::Size& size, | 62 const gfx::Size& size, |
| 64 const SkBitmap& pixels) OVERRIDE; | 63 const SkBitmap& pixels) OVERRIDE; |
| 65 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 64 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
| 66 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; | 65 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; |
| 67 virtual void Abort() OVERRIDE; | 66 virtual void Abort() OVERRIDE; |
| 68 virtual bool IsAborted() OVERRIDE; | 67 virtual bool IsAborted() OVERRIDE; |
| 69 | 68 |
| 69 // Makes a copy of |this|. |
| 70 scoped_refptr<RendererGpuVideoDecoderFactories> Clone(); |
| 71 |
| 70 protected: | 72 protected: |
| 71 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; | 73 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; |
| 72 virtual ~RendererGpuVideoDecoderFactories(); | 74 virtual ~RendererGpuVideoDecoderFactories(); |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 // Helper for the constructor to acquire the ContentGLContext on the | 77 RendererGpuVideoDecoderFactories(); |
| 76 // compositor thread (when it is enabled). | 78 |
| 79 // Helper for the constructor to acquire the ContentGLContext on |
| 80 // |message_loop_|. |
| 77 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context); | 81 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context); |
| 78 | 82 |
| 79 // Async versions of the public methods. They use output parameters instead | 83 // Async versions of the public methods. They use output parameters instead |
| 80 // of return values and each takes a WaitableEvent* param to signal completion | 84 // of return values and each takes a WaitableEvent* param to signal completion |
| 81 // (except for DeleteTexture, which is fire-and-forget). | 85 // (except for DeleteTexture, which is fire-and-forget). |
| 82 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on | 86 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on |
| 83 // |compositor_message_loop_|. | 87 // |message_loop_|. |
| 84 // The AsyncCreateVideoDecodeAccelerator returns its output in the vda_ | 88 // The AsyncCreateVideoDecodeAccelerator returns its output in the vda_ |
| 85 // member. | 89 // member. |
| 86 void AsyncCreateVideoDecodeAccelerator( | 90 void AsyncCreateVideoDecodeAccelerator( |
| 87 media::VideoCodecProfile profile, | 91 media::VideoCodecProfile profile, |
| 88 media::VideoDecodeAccelerator::Client* client); | 92 media::VideoDecodeAccelerator::Client* client); |
| 89 void AsyncCreateTextures(int32 count, const gfx::Size& size, | 93 void AsyncCreateTextures(int32 count, const gfx::Size& size, |
| 90 uint32 texture_target, uint32* sync_point); | 94 uint32 texture_target, uint32* sync_point); |
| 91 void AsyncDeleteTexture(uint32 texture_id); | 95 void AsyncDeleteTexture(uint32 texture_id); |
| 92 void AsyncWaitSyncPoint(uint32 sync_point); | 96 void AsyncWaitSyncPoint(uint32 sync_point); |
| 93 void AsyncReadPixels(uint32 texture_id, uint32 texture_target, | 97 void AsyncReadPixels(uint32 texture_id, uint32 texture_target, |
| 94 const gfx::Size& size); | 98 const gfx::Size& size); |
| 95 void AsyncCreateSharedMemory(size_t size); | 99 void AsyncCreateSharedMemory(size_t size); |
| 96 void AsyncDestroyVideoDecodeAccelerator(); | 100 void AsyncDestroyVideoDecodeAccelerator(); |
| 97 | 101 |
| 98 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_; | 102 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 99 scoped_refptr<base::MessageLoopProxy> main_message_loop_; | 103 scoped_refptr<base::MessageLoopProxy> main_message_loop_; |
| 100 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 104 scoped_refptr<GpuChannelHost> gpu_channel_host_; |
| 101 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_; | 105 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_; |
| 102 | 106 |
| 103 // This event is signaled if we have been asked to Abort(). | 107 // This event is signaled if we have been asked to Abort(). |
| 104 base::WaitableEvent aborted_waiter_; | 108 base::WaitableEvent aborted_waiter_; |
| 105 | 109 |
| 106 // This event is signaled by asynchronous tasks posted to the compositor | 110 // This event is signaled by asynchronous tasks posted to |message_loop_| to |
| 107 // message loop to indicate their completion. | 111 // indicate their completion. |
| 108 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc. | 112 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc. |
| 109 base::WaitableEvent compositor_loop_async_waiter_; | 113 base::WaitableEvent message_loop_async_waiter_; |
| 110 | 114 |
| 111 // This event is signaled by asynchronous tasks posted to the renderer thread | 115 // This event is signaled by asynchronous tasks posted to the renderer thread |
| 112 // message loop to indicate their completion. e.g. AsyncCreateSharedMemory. | 116 // message loop to indicate their completion. e.g. AsyncCreateSharedMemory. |
| 113 base::WaitableEvent render_thread_async_waiter_; | 117 base::WaitableEvent render_thread_async_waiter_; |
| 114 | 118 |
| 115 // The vda returned by the CreateVideoAcclelerator function. | 119 // The vda returned by the CreateVideoAcclelerator function. |
| 116 scoped_ptr<media::VideoDecodeAccelerator> vda_; | 120 scoped_ptr<media::VideoDecodeAccelerator> vda_; |
| 117 | 121 |
| 118 // Shared memory segment which is returned by the CreateSharedMemory() | 122 // Shared memory segment which is returned by the CreateSharedMemory() |
| 119 // function. | 123 // function. |
| 120 scoped_ptr<base::SharedMemory> shared_memory_segment_; | 124 scoped_ptr<base::SharedMemory> shared_memory_segment_; |
| 121 | 125 |
| 122 // Bitmap returned by ReadPixels(). | 126 // Bitmap returned by ReadPixels(). |
| 123 SkBitmap read_pixels_bitmap_; | 127 SkBitmap read_pixels_bitmap_; |
| 124 | 128 |
| 125 // Textures returned by the CreateTexture() function. | 129 // Textures returned by the CreateTexture() function. |
| 126 std::vector<uint32> created_textures_; | 130 std::vector<uint32> created_textures_; |
| 127 std::vector<gpu::Mailbox> created_texture_mailboxes_; | 131 std::vector<gpu::Mailbox> created_texture_mailboxes_; |
| 128 | 132 |
| 129 DISALLOW_IMPLICIT_CONSTRUCTORS(RendererGpuVideoDecoderFactories); | 133 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoDecoderFactories); |
| 130 }; | 134 }; |
| 131 | 135 |
| 132 } // namespace content | 136 } // namespace content |
| 133 | 137 |
| 134 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ | 138 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ |
| OLD | NEW |