Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(942)

Side by Side Diff: content/renderer/media/renderer_gpu_video_accelerator_factories.h

Issue 135393004: Revert of Revert of Remove threading from RendererGpuVideoAcceleratorFactories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dthread
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/media/renderer_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/child/thread_safe_sender.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "media/filters/gpu_video_accelerator_factories.h" 16 #include "media/filters/gpu_video_accelerator_factories.h"
17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
19 18
20 namespace base { 19 namespace base {
21 class WaitableEvent; 20 class WaitableEvent;
22 } 21 }
23 22
24 namespace content { 23 namespace content {
25 class ContextProviderCommandBuffer; 24 class ContextProviderCommandBuffer;
26 class GpuChannelHost; 25 class GpuChannelHost;
27 class WebGraphicsContext3DCommandBufferImpl; 26 class WebGraphicsContext3DCommandBufferImpl;
28 27
29 // Glue code to expose functionality needed by media::GpuVideoAccelerator to 28 // Glue code to expose functionality needed by media::GpuVideoAccelerator to
30 // RenderViewImpl. This class is entirely an implementation detail of 29 // RenderViewImpl. This class is entirely an implementation detail of
31 // 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
32 // 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.
33 // 32 //
34 // The RendererGpuVideoAcceleratorFactories can be constructed on any thread. 33 // The RendererGpuVideoAcceleratorFactories can be constructed on any thread,
35 // Most public methods of the class must be called from the media thread. The 34 // but subsequent calls to all public methods of the class must be called from
36 // exceptions (which can be called from any thread, as they are internally 35 // the |message_loop_proxy_|, as provided during construction.
37 // trampolined) are:
38 // * CreateVideoDecodeAccelerator()
39 // * ReadPixels()
40 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories 36 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories
41 : public media::GpuVideoAcceleratorFactories { 37 : public media::GpuVideoAcceleratorFactories {
42 public: 38 public:
43 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each 39 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each
44 // use. Safe to call from any thread. 40 // use. Safe to call from any thread.
45 RendererGpuVideoAcceleratorFactories( 41 RendererGpuVideoAcceleratorFactories(
46 GpuChannelHost* gpu_channel_host, 42 GpuChannelHost* gpu_channel_host,
43 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
47 const scoped_refptr<ContextProviderCommandBuffer>& context_provider); 44 const scoped_refptr<ContextProviderCommandBuffer>& context_provider);
48 45
49 // media::GpuVideoAcceleratorFactories implementation. 46 // media::GpuVideoAcceleratorFactories implementation.
50 // CreateVideoDecodeAccelerator() is safe to call from any thread.
51 virtual scoped_ptr<media::VideoDecodeAccelerator> 47 virtual scoped_ptr<media::VideoDecodeAccelerator>
52 CreateVideoDecodeAccelerator( 48 CreateVideoDecodeAccelerator(
53 media::VideoCodecProfile profile, 49 media::VideoCodecProfile profile,
54 media::VideoDecodeAccelerator::Client* client) OVERRIDE; 50 media::VideoDecodeAccelerator::Client* client) OVERRIDE;
55 virtual scoped_ptr<media::VideoEncodeAccelerator> 51 virtual scoped_ptr<media::VideoEncodeAccelerator>
56 CreateVideoEncodeAccelerator( 52 CreateVideoEncodeAccelerator(
57 media::VideoEncodeAccelerator::Client* client) OVERRIDE; 53 media::VideoEncodeAccelerator::Client* client) OVERRIDE;
58 // Creates textures and produces them into mailboxes. Returns a sync point to 54 // Creates textures and produces them into mailboxes. Returns a sync point to
59 // wait on before using the mailboxes, or 0 on failure. 55 // wait on before using the mailboxes, or 0 on failure.
60 virtual uint32 CreateTextures(int32 count, 56 virtual uint32 CreateTextures(int32 count,
61 const gfx::Size& size, 57 const gfx::Size& size,
62 std::vector<uint32>* texture_ids, 58 std::vector<uint32>* texture_ids,
63 std::vector<gpu::Mailbox>* texture_mailboxes, 59 std::vector<gpu::Mailbox>* texture_mailboxes,
64 uint32 texture_target) OVERRIDE; 60 uint32 texture_target) OVERRIDE;
65 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; 61 virtual void DeleteTexture(uint32 texture_id) OVERRIDE;
66 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; 62 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE;
67 // ReadPixels() is safe to call from any thread.
68 virtual void ReadPixels(uint32 texture_id, 63 virtual void ReadPixels(uint32 texture_id,
69 const gfx::Size& size, 64 const gfx::Rect& visible_rect,
70 const SkBitmap& pixels) OVERRIDE; 65 const SkBitmap& pixels) OVERRIDE;
71 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; 66 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE;
72 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE; 67 virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() OVERRIDE;
73 virtual void Abort() OVERRIDE;
74 virtual bool IsAborted() OVERRIDE;
75 scoped_refptr<RendererGpuVideoAcceleratorFactories> Clone();
76 68
77 protected: 69 protected:
78 friend class base::RefCountedThreadSafe<RendererGpuVideoAcceleratorFactories>; 70 friend class base::RefCountedThreadSafe<RendererGpuVideoAcceleratorFactories>;
79 virtual ~RendererGpuVideoAcceleratorFactories(); 71 virtual ~RendererGpuVideoAcceleratorFactories();
80 72
81 private: 73 private:
82 RendererGpuVideoAcceleratorFactories();
83
84 // Helper to get a pointer to the WebGraphicsContext3DCommandBufferImpl, 74 // Helper to get a pointer to the WebGraphicsContext3DCommandBufferImpl,
85 // if it has not been lost yet. 75 // if it has not been lost yet.
86 WebGraphicsContext3DCommandBufferImpl* GetContext3d(); 76 WebGraphicsContext3DCommandBufferImpl* GetContext3d();
87 77
88 // Helper for the constructor to acquire the ContentGLContext on
89 // |task_runner_|.
90 void AsyncBindContext();
91
92 // Async versions of the public methods, run on |task_runner_|.
93 // They use output parameters instead of return values and each takes
94 // a WaitableEvent* param to signal completion (except for DeleteTexture,
95 // which is fire-and-forget).
96 // AsyncCreateVideoDecodeAccelerator returns its output in the |vda_| member.
97 void AsyncCreateVideoDecodeAccelerator(
98 media::VideoCodecProfile profile,
99 media::VideoDecodeAccelerator::Client* client);
100 void AsyncReadPixels(uint32 texture_id, const gfx::Size& size);
101 void AsyncDestroyVideoDecodeAccelerator();
102
103 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 78 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
104 scoped_refptr<GpuChannelHost> gpu_channel_host_; 79 scoped_refptr<GpuChannelHost> gpu_channel_host_;
105 scoped_refptr<ContextProviderCommandBuffer> context_provider_; 80 scoped_refptr<ContextProviderCommandBuffer> context_provider_;
106 81
107 // For sending requests to allocate shared memory in the Browser process. 82 // For sending requests to allocate shared memory in the Browser process.
108 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 83 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
109 84
110 // This event is signaled if we have been asked to Abort().
111 base::WaitableEvent aborted_waiter_;
112
113 // This event is signaled by asynchronous tasks posted to |task_runner_| to
114 // indicate their completion.
115 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc.
116 base::WaitableEvent task_runner_async_waiter_;
117
118 // The vda returned by the CreateVideoDecodeAccelerator function.
119 scoped_ptr<media::VideoDecodeAccelerator> vda_;
120
121 // Bitmap returned by ReadPixels().
122 SkBitmap read_pixels_bitmap_;
123
124 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories); 85 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories);
125 }; 86 };
126 87
127 } // namespace content 88 } // namespace content
128 89
129 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_ 90 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/renderer_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698