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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "media/filters/gpu_video_decoder.h" | 13 #include "media/filters/gpu_video_decoder.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
| 16 class ContentGLContext; |
16 class GpuChannelHost; | 17 class GpuChannelHost; |
17 class ContentGLContext; | 18 class WebGraphicsContext3DCommandBufferImpl; |
18 namespace base { | 19 namespace base { |
19 class WaitableEvent; | 20 class WaitableEvent; |
20 } | 21 } |
21 | 22 |
22 // Glue code to expose functionality needed by media::GpuVideoDecoder to | 23 // Glue code to expose functionality needed by media::GpuVideoDecoder to |
23 // RenderViewImpl. This class is entirely an implementation detail of | 24 // RenderViewImpl. This class is entirely an implementation detail of |
24 // RenderViewImpl and only has its own header to allow extraction of its | 25 // RenderViewImpl and only has its own header to allow extraction of its |
25 // implementation from render_view_impl.cc which is already far too large. | 26 // implementation from render_view_impl.cc which is already far too large. |
26 // | 27 // |
27 // The public methods of the class can be called from any thread, and are | 28 // The public methods of the class can be called from any thread, and are |
28 // internally trampolined to the thread on which the class was constructed | 29 // internally trampolined to the appropriate thread. GPU/GL-related calls go to |
29 // (de-facto, the renderer thread) if called from a different thread. | 30 // the constructor-argument loop (mostly that's the compositor thread, or the |
| 31 // renderer thread if threaded compositing is disabled), and shmem-related calls |
| 32 // go to the render thread. |
30 class CONTENT_EXPORT RendererGpuVideoDecoderFactories | 33 class CONTENT_EXPORT RendererGpuVideoDecoderFactories |
31 : public media::GpuVideoDecoder::Factories { | 34 : public media::GpuVideoDecoder::Factories { |
32 public: | 35 public: |
33 // Takes a ref on |gpu_channel_host| and tests |context| for NULL before each | 36 // Takes a ref on |gpu_channel_host| and tests |context| for NULL before each |
34 // use. | 37 // use. |
35 RendererGpuVideoDecoderFactories(GpuChannelHost* gpu_channel_host, | 38 RendererGpuVideoDecoderFactories( |
36 base::WeakPtr<ContentGLContext> context); | 39 GpuChannelHost* gpu_channel_host, |
| 40 MessageLoop* message_loop, |
| 41 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); |
37 | 42 |
38 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | 43 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( |
39 media::VideoDecodeAccelerator::Profile profile, | 44 media::VideoDecodeAccelerator::Profile profile, |
40 media::VideoDecodeAccelerator::Client* client) OVERRIDE; | 45 media::VideoDecodeAccelerator::Client* client) OVERRIDE; |
41 | 46 |
42 virtual bool CreateTextures(int32 count, const gfx::Size& size, | 47 virtual bool CreateTextures(int32 count, const gfx::Size& size, |
43 std::vector<uint32>* texture_ids, | 48 std::vector<uint32>* texture_ids, |
44 uint32* texture_target) OVERRIDE; | 49 uint32* texture_target) OVERRIDE; |
45 | 50 |
46 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; | 51 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; |
47 | 52 |
48 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 53 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
49 | 54 |
50 protected: | 55 protected: |
51 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; | 56 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; |
52 virtual ~RendererGpuVideoDecoderFactories(); | 57 virtual ~RendererGpuVideoDecoderFactories(); |
53 | 58 |
54 private: | 59 private: |
55 // Async versions of the public methods. These all run on |message_loop_| | 60 // Helper for the constructor to acquire the ContentGLContext on the |
56 // exclusively, and use output parameters instead of return values. Finally, | 61 // compositor thread (when it is enabled). |
57 // each takes a WaitableEvent* param to signal completion (except for | 62 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* wgc3dcbi, |
58 // DeleteTexture, which is fire-and-forget). | 63 base::WaitableEvent* waiter); |
| 64 |
| 65 // Async versions of the public methods. They use output parameters instead |
| 66 // of return values and each takes a WaitableEvent* param to signal completion |
| 67 // (except for DeleteTexture, which is fire-and-forget). |
| 68 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on |
| 69 // |message_loop_|. |
59 void AsyncCreateVideoDecodeAccelerator( | 70 void AsyncCreateVideoDecodeAccelerator( |
60 media::VideoDecodeAccelerator::Profile profile, | 71 media::VideoDecodeAccelerator::Profile profile, |
61 media::VideoDecodeAccelerator::Client* client, | 72 media::VideoDecodeAccelerator::Client* client, |
62 media::VideoDecodeAccelerator** vda, | 73 media::VideoDecodeAccelerator** vda, |
63 base::WaitableEvent* waiter); | 74 base::WaitableEvent* waiter); |
64 void AsyncCreateTextures( | 75 void AsyncCreateTextures( |
65 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids, | 76 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids, |
66 uint32* texture_target, bool* success, base::WaitableEvent* waiter); | 77 uint32* texture_target, bool* success, base::WaitableEvent* waiter); |
67 void AsyncDeleteTexture(uint32 texture_id); | 78 void AsyncDeleteTexture(uint32 texture_id); |
68 void AsyncCreateSharedMemory( | 79 void AsyncCreateSharedMemory( |
69 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter); | 80 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter); |
70 | 81 |
71 MessageLoop* message_loop_; | 82 MessageLoop* message_loop_; |
72 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 83 scoped_refptr<GpuChannelHost> gpu_channel_host_; |
73 base::WeakPtr<ContentGLContext> context_; | 84 base::WeakPtr<ContentGLContext> context_; |
74 DISALLOW_IMPLICIT_CONSTRUCTORS(RendererGpuVideoDecoderFactories); | 85 DISALLOW_IMPLICIT_CONSTRUCTORS(RendererGpuVideoDecoderFactories); |
75 }; | 86 }; |
76 | 87 |
77 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ | 88 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ |
OLD | NEW |