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

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

Issue 1133563010: Add a GpuMemoryBuffer pool that creates hardware backed VideoFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reveman@'s nits. Created 5 years, 7 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 | « content/renderer/media/renderer_gpu_video_accelerator_factories.h ('k') | media/BUILD.gn » ('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 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" 5 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "content/child/child_gpu_memory_buffer_manager.h"
11 #include "content/child/child_thread_impl.h" 12 #include "content/child/child_thread_impl.h"
12 #include "content/common/gpu/client/context_provider_command_buffer.h" 13 #include "content/common/gpu/client/context_provider_command_buffer.h"
13 #include "content/common/gpu/client/gl_helper.h" 14 #include "content/common/gpu/client/gl_helper.h"
14 #include "content/common/gpu/client/gpu_channel_host.h" 15 #include "content/common/gpu/client/gpu_channel_host.h"
15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
16 #include "content/common/gpu/media/gpu_video_accelerator_util.h" 17 #include "content/common/gpu/media/gpu_video_accelerator_util.h"
17 #include "content/renderer/render_thread_impl.h" 18 #include "content/renderer/render_thread_impl.h"
18 #include "gpu/command_buffer/client/gles2_implementation.h" 19 #include "gpu/command_buffer/client/gles2_implementation.h"
20 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
19 #include "media/video/video_decode_accelerator.h" 21 #include "media/video/video_decode_accelerator.h"
20 #include "media/video/video_encode_accelerator.h" 22 #include "media/video/video_encode_accelerator.h"
21 23
22 namespace content { 24 namespace content {
23 25
24 // static 26 // static
25 scoped_refptr<RendererGpuVideoAcceleratorFactories> 27 scoped_refptr<RendererGpuVideoAcceleratorFactories>
26 RendererGpuVideoAcceleratorFactories::Create( 28 RendererGpuVideoAcceleratorFactories::Create(
27 GpuChannelHost* gpu_channel_host, 29 GpuChannelHost* gpu_channel_host,
28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
(...skipping 10 matching lines...) Expand all
39 return factories; 41 return factories;
40 } 42 }
41 43
42 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories( 44 RendererGpuVideoAcceleratorFactories::RendererGpuVideoAcceleratorFactories(
43 GpuChannelHost* gpu_channel_host, 45 GpuChannelHost* gpu_channel_host,
44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 46 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
45 const scoped_refptr<ContextProviderCommandBuffer>& context_provider) 47 const scoped_refptr<ContextProviderCommandBuffer>& context_provider)
46 : task_runner_(task_runner), 48 : task_runner_(task_runner),
47 gpu_channel_host_(gpu_channel_host), 49 gpu_channel_host_(gpu_channel_host),
48 context_provider_(context_provider), 50 context_provider_(context_provider),
49 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) {} 51 gpu_memory_buffer_manager_(
52 ChildThreadImpl::current()->gpu_memory_buffer_manager()),
53 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) {
54 }
50 55
51 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {} 56 RendererGpuVideoAcceleratorFactories::~RendererGpuVideoAcceleratorFactories() {}
52 57
53 void RendererGpuVideoAcceleratorFactories::BindContext() { 58 void RendererGpuVideoAcceleratorFactories::BindContext() {
54 DCHECK(task_runner_->BelongsToCurrentThread()); 59 DCHECK(task_runner_->BelongsToCurrentThread());
55 if (!context_provider_->BindToCurrentThread()) 60 if (!context_provider_->BindToCurrentThread())
56 context_provider_ = NULL; 61 context_provider_ = NULL;
57 } 62 }
58 63
59 WebGraphicsContext3DCommandBufferImpl* 64 WebGraphicsContext3DCommandBufferImpl*
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return; 183 return;
179 184
180 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation(); 185 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation();
181 gles2->WaitSyncPointCHROMIUM(sync_point); 186 gles2->WaitSyncPointCHROMIUM(sync_point);
182 187
183 // Callers expect the WaitSyncPoint to affect the next IPCs. Make sure to 188 // Callers expect the WaitSyncPoint to affect the next IPCs. Make sure to
184 // flush the command buffers to ensure that. 189 // flush the command buffers to ensure that.
185 gles2->ShallowFlushCHROMIUM(); 190 gles2->ShallowFlushCHROMIUM();
186 } 191 }
187 192
193 scoped_ptr<gfx::GpuMemoryBuffer>
194 RendererGpuVideoAcceleratorFactories::AllocateGpuMemoryBuffer(
195 const gfx::Size& size,
196 gfx::GpuMemoryBuffer::Format format,
197 gfx::GpuMemoryBuffer::Usage usage) {
198 DCHECK(task_runner_->BelongsToCurrentThread());
199 scoped_ptr<gfx::GpuMemoryBuffer> buffer =
200 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(size, format, usage);
201 return buffer.Pass();
202 }
203
204 bool RendererGpuVideoAcceleratorFactories::IsTextureRGSupported() {
205 DCHECK(task_runner_->BelongsToCurrentThread());
206
207 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d();
208 if (!context)
209 return false;
210 return context->GetImplementation()->capabilities().texture_rg;
211 }
212
213 gpu::gles2::GLES2Interface*
214 RendererGpuVideoAcceleratorFactories::GetGLES2Interface() {
215 DCHECK(task_runner_->BelongsToCurrentThread());
216
217 WebGraphicsContext3DCommandBufferImpl* context = GetContext3d();
218 if (!context)
219 return nullptr;
220 gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation();
221 return gles2;
222 }
223
188 scoped_ptr<base::SharedMemory> 224 scoped_ptr<base::SharedMemory>
189 RendererGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size) { 225 RendererGpuVideoAcceleratorFactories::CreateSharedMemory(size_t size) {
190 DCHECK(task_runner_->BelongsToCurrentThread()); 226 DCHECK(task_runner_->BelongsToCurrentThread());
191 scoped_ptr<base::SharedMemory> mem( 227 scoped_ptr<base::SharedMemory> mem(
192 ChildThreadImpl::AllocateSharedMemory(size, thread_safe_sender_.get())); 228 ChildThreadImpl::AllocateSharedMemory(size, thread_safe_sender_.get()));
193 if (mem && !mem->Map(size)) 229 if (mem && !mem->Map(size))
194 return nullptr; 230 return nullptr;
195 return mem; 231 return mem;
196 } 232 }
197 233
(...skipping 12 matching lines...) Expand all
210 246
211 media::VideoEncodeAccelerator::SupportedProfiles 247 media::VideoEncodeAccelerator::SupportedProfiles
212 RendererGpuVideoAcceleratorFactories:: 248 RendererGpuVideoAcceleratorFactories::
213 GetVideoEncodeAcceleratorSupportedProfiles() { 249 GetVideoEncodeAcceleratorSupportedProfiles() {
214 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( 250 return GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(
215 gpu_channel_host_->gpu_info() 251 gpu_channel_host_->gpu_info()
216 .video_encode_accelerator_supported_profiles); 252 .video_encode_accelerator_supported_profiles);
217 } 253 }
218 254
219 } // namespace content 255 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_gpu_video_accelerator_factories.h ('k') | media/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698