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

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator.cc

Issue 858653002: vaapi plumbing to allow hardware video overlays (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittests build Created 5 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
OLDNEW
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 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 15
16 #include "content/common/gpu/gpu_channel.h" 16 #include "content/common/gpu/gpu_channel.h"
17 #include "content/common/gpu/gpu_messages.h" 17 #include "content/common/gpu/gpu_messages.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "gpu/command_buffer/common/command_buffer.h" 19 #include "gpu/command_buffer/common/command_buffer.h"
20 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_macros.h"
21 #include "ipc/ipc_message_utils.h" 21 #include "ipc/ipc_message_utils.h"
22 #include "ipc/message_filter.h" 22 #include "ipc/message_filter.h"
23 #include "media/base/limits.h" 23 #include "media/base/limits.h"
24 #include "ui/gl/gl_context.h" 24 #include "ui/gl/gl_context.h"
25 #include "ui/gl/gl_image.h"
25 #include "ui/gl/gl_surface_egl.h" 26 #include "ui/gl/gl_surface_egl.h"
26 27
27 #if defined(OS_WIN) 28 #if defined(OS_WIN)
28 #include "base/win/windows_version.h" 29 #include "base/win/windows_version.h"
29 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 30 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
30 #elif defined(OS_MACOSX) 31 #elif defined(OS_MACOSX)
31 #include "content/common/gpu/media/vt_video_decode_accelerator.h" 32 #include "content/common/gpu/media/vt_video_decode_accelerator.h"
32 #elif defined(OS_CHROMEOS) 33 #elif defined(OS_CHROMEOS)
33 #if defined(ARCH_CPU_ARMEL) && defined(USE_LIBV4L2) 34 #if defined(ARCH_CPU_ARMEL) && defined(USE_LIBV4L2)
34 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" 35 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 gfx::GLSurfaceEGL::GetHardwareDisplay(), 330 gfx::GLSurfaceEGL::GetHardwareDisplay(),
330 stub_->decoder()->GetGLContext()->GetHandle(), 331 stub_->decoder()->GetGLContext()->GetHandle(),
331 weak_factory_for_io_.GetWeakPtr(), 332 weak_factory_for_io_.GetWeakPtr(),
332 make_context_current_, 333 make_context_current_,
333 io_message_loop_)); 334 io_message_loop_));
334 } 335 }
335 #endif 336 #endif
336 return decoder.Pass(); 337 return decoder.Pass();
337 } 338 }
338 339
340 void GpuVideoDecodeAccelerator::BindImage(uint32 client_texture_id,
341 uint32 texture_target,
342 scoped_refptr<gfx::GLImage> image) {
343 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder();
344 gpu::gles2::TextureManager* texture_manager =
345 command_decoder->GetContextGroup()->texture_manager();
346 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id);
347 if (ref)
348 texture_manager->SetLevelImage(ref, texture_target, 0, image.get());
349 }
350
339 scoped_ptr<media::VideoDecodeAccelerator> 351 scoped_ptr<media::VideoDecodeAccelerator>
340 GpuVideoDecodeAccelerator::CreateVaapiVDA() { 352 GpuVideoDecodeAccelerator::CreateVaapiVDA() {
341 scoped_ptr<media::VideoDecodeAccelerator> decoder; 353 scoped_ptr<media::VideoDecodeAccelerator> decoder;
342 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 354 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
343 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_)); 355 decoder.reset(new VaapiVideoDecodeAccelerator(
356 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage,
357 base::Unretained(this))));
344 #endif 358 #endif
345 return decoder.Pass(); 359 return decoder.Pass();
346 } 360 }
347 361
348 scoped_ptr<media::VideoDecodeAccelerator> 362 scoped_ptr<media::VideoDecodeAccelerator>
349 GpuVideoDecodeAccelerator::CreateVTVDA() { 363 GpuVideoDecodeAccelerator::CreateVTVDA() {
350 scoped_ptr<media::VideoDecodeAccelerator> decoder; 364 scoped_ptr<media::VideoDecodeAccelerator> decoder;
351 #if defined(OS_MACOSX) 365 #if defined(OS_MACOSX)
352 decoder.reset(new VTVideoDecodeAccelerator( 366 decoder.reset(new VTVideoDecodeAccelerator(
353 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()), 367 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 474 }
461 475
462 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 476 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691
463 GLenum format = 477 GLenum format =
464 video_decode_accelerator_.get()->GetSurfaceInternalFormat(); 478 video_decode_accelerator_.get()->GetSurfaceInternalFormat();
465 if (format != GL_RGBA) { 479 if (format != GL_RGBA) {
466 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format, 480 texture_manager->SetLevelInfo(texture_ref, texture_target_, 0, format,
467 width, height, 1, 0, format, 0, false); 481 width, height, 1, 0, format, 0, false);
468 } 482 }
469 } 483 }
470 uint32 service_texture_id; 484 buffers.push_back(media::PictureBuffer(buffer_ids[i], texture_dimensions_,
471 if (!command_decoder->GetServiceTextureId( 485 texture_ref->service_id(),
472 texture_ids[i], &service_texture_id)) { 486 texture_ids[i]));
473 DLOG(ERROR) << "Failed to translate texture!";
474 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
475 return;
476 }
477 buffers.push_back(media::PictureBuffer(
478 buffer_ids[i], texture_dimensions_, service_texture_id));
479 textures.push_back(texture_ref); 487 textures.push_back(texture_ref);
480 } 488 }
481 video_decode_accelerator_->AssignPictureBuffers(buffers); 489 video_decode_accelerator_->AssignPictureBuffers(buffers);
482 DebugAutoLock auto_lock(debug_uncleared_textures_lock_); 490 DebugAutoLock auto_lock(debug_uncleared_textures_lock_);
483 for (uint32 i = 0; i < buffer_ids.size(); ++i) 491 for (uint32 i = 0; i < buffer_ids.size(); ++i)
484 uncleared_textures_[buffer_ids[i]] = textures[i]; 492 uncleared_textures_[buffer_ids[i]] = textures[i];
485 } 493 }
486 494
487 void GpuVideoDecodeAccelerator::OnReusePictureBuffer( 495 void GpuVideoDecodeAccelerator::OnReusePictureBuffer(
488 int32 picture_buffer_id) { 496 int32 picture_buffer_id) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 return stub_->channel()->Send(message); 585 return stub_->channel()->Send(message);
578 } 586 }
579 587
580 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, 588 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message,
581 bool succeeded) { 589 bool succeeded) {
582 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); 590 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded);
583 Send(message); 591 Send(message);
584 } 592 }
585 593
586 } // namespace content 594 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_decode_accelerator.h ('k') | content/common/gpu/media/vaapi_drm_picture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698