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 GpuChannelHost; | 16 class GpuChannelHost; |
17 class ContentGLContext; | 17 class WebGraphicsContext3DCommandBufferImpl; |
18 namespace base { | 18 namespace base { |
19 class WaitableEvent; | 19 class WaitableEvent; |
20 } | 20 } |
21 | 21 |
22 // Glue code to expose functionality needed by media::GpuVideoDecoder to | 22 // Glue code to expose functionality needed by media::GpuVideoDecoder to |
23 // RenderViewImpl. This class is entirely an implementation detail of | 23 // RenderViewImpl. This class is entirely an implementation detail of |
24 // RenderViewImpl and only has its own header to allow extraction of its | 24 // 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. | 25 // implementation from render_view_impl.cc which is already far too large. |
26 // | 26 // |
27 // The public methods of the class can be called from any thread, and are | 27 // 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 | 28 // internally trampolined to the appropriate thread. GPU/GL-related calls go to |
29 // (de-facto, the renderer thread) if called from a different thread. | 29 // the constructor-argument loop (mostly that's the compositor thread, or the |
30 // renderer thread if threaded compositing is disabled), and shmem-related calls | |
31 // go to the render thread. | |
30 class CONTENT_EXPORT RendererGpuVideoDecoderFactories | 32 class CONTENT_EXPORT RendererGpuVideoDecoderFactories |
31 : public media::GpuVideoDecoder::Factories { | 33 : public media::GpuVideoDecoder::Factories { |
32 public: | 34 public: |
33 // Takes a ref on |gpu_channel_host| and tests |context| for NULL before each | 35 // Takes a ref on |gpu_channel_host| and tests |context| for NULL before each |
34 // use. | 36 // use. |
35 RendererGpuVideoDecoderFactories(GpuChannelHost* gpu_channel_host, | 37 RendererGpuVideoDecoderFactories( |
36 base::WeakPtr<ContentGLContext> context); | 38 GpuChannelHost* gpu_channel_host, |
39 MessageLoop* message_loop, | |
40 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); | |
37 | 41 |
38 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | 42 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( |
39 media::VideoDecodeAccelerator::Profile profile, | 43 media::VideoDecodeAccelerator::Profile profile, |
40 media::VideoDecodeAccelerator::Client* client) OVERRIDE; | 44 media::VideoDecodeAccelerator::Client* client) OVERRIDE; |
41 | 45 |
42 virtual bool CreateTextures(int32 count, const gfx::Size& size, | 46 virtual bool CreateTextures(int32 count, const gfx::Size& size, |
43 std::vector<uint32>* texture_ids, | 47 std::vector<uint32>* texture_ids, |
44 uint32* texture_target) OVERRIDE; | 48 uint32* texture_target) OVERRIDE; |
45 | 49 |
46 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; | 50 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; |
47 | 51 |
48 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 52 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
49 | 53 |
50 protected: | 54 protected: |
51 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; | 55 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; |
52 virtual ~RendererGpuVideoDecoderFactories(); | 56 virtual ~RendererGpuVideoDecoderFactories(); |
53 | 57 |
54 private: | 58 private: |
55 // Async versions of the public methods. These all run on |message_loop_| | 59 // Async versions of the public methods. They use output parameters instead |
56 // exclusively, and use output parameters instead of return values. Finally, | 60 // of return values and each takes a WaitableEvent* param to signal completion |
57 // each takes a WaitableEvent* param to signal completion (except for | 61 // (except for DeleteTexture, which is fire-and-forget). |
58 // DeleteTexture, which is fire-and-forget). | 62 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on |
63 // |message_loop_|. | |
59 void AsyncCreateVideoDecodeAccelerator( | 64 void AsyncCreateVideoDecodeAccelerator( |
60 media::VideoDecodeAccelerator::Profile profile, | 65 media::VideoDecodeAccelerator::Profile profile, |
61 media::VideoDecodeAccelerator::Client* client, | 66 media::VideoDecodeAccelerator::Client* client, |
62 media::VideoDecodeAccelerator** vda, | 67 media::VideoDecodeAccelerator** vda, |
63 base::WaitableEvent* waiter); | 68 base::WaitableEvent* waiter); |
64 void AsyncCreateTextures( | 69 void AsyncCreateTextures( |
65 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids, | 70 int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids, |
66 uint32* texture_target, bool* success, base::WaitableEvent* waiter); | 71 uint32* texture_target, bool* success, base::WaitableEvent* waiter); |
67 void AsyncDeleteTexture(uint32 texture_id); | 72 void AsyncDeleteTexture(uint32 texture_id); |
68 void AsyncCreateSharedMemory( | 73 void AsyncCreateSharedMemory( |
69 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter); | 74 size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter); |
70 | 75 |
71 MessageLoop* message_loop_; | 76 MessageLoop* message_loop_; |
72 scoped_refptr<GpuChannelHost> gpu_channel_host_; | 77 scoped_refptr<GpuChannelHost> gpu_channel_host_; |
73 base::WeakPtr<ContentGLContext> context_; | 78 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi_; |
no sievers
2012/03/08 20:09:27
What about the WGC3D going away?
Not only during c
Ami GONE FROM CHROMIUM
2012/03/08 20:19:51
Dunno. James?
(in practice these races will be ra
no sievers
2012/03/08 21:16:16
If you still use the WeakPtr to the ContentGLConte
Ami GONE FROM CHROMIUM
2012/03/08 21:22:27
Actually isn't it enough to know that this member
| |
74 DISALLOW_IMPLICIT_CONSTRUCTORS(RendererGpuVideoDecoderFactories); | 79 DISALLOW_IMPLICIT_CONSTRUCTORS(RendererGpuVideoDecoderFactories); |
75 }; | 80 }; |
76 | 81 |
77 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ | 82 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ |
OLD | NEW |