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

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

Issue 43283002: Enable GLX/EGL backend switching while run HW video decode with libva. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 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/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 14
15 #include "content/common/gpu/gpu_channel.h" 15 #include "content/common/gpu/gpu_channel.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #include "gpu/command_buffer/common/command_buffer.h" 18 #include "gpu/command_buffer/common/command_buffer.h"
19 #include "ipc/ipc_message_macros.h" 19 #include "ipc/ipc_message_macros.h"
20 #include "ipc/ipc_message_utils.h" 20 #include "ipc/ipc_message_utils.h"
21 #include "media/base/limits.h" 21 #include "media/base/limits.h"
22 #include "ui/gl/gl_context.h" 22 #include "ui/gl/gl_context.h"
23 #include "ui/gl/gl_surface_egl.h" 23 #include "ui/gl/gl_surface_egl.h"
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
27 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 27 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
28 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 28 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
29 #include "content/common/gpu/media/exynos_video_decode_accelerator.h" 29 #include "content/common/gpu/media/exynos_video_decode_accelerator.h"
30 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) 30 #elif defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
31 #if defined(VIDEO_TEXTURE_GLX_BACKEND)
31 #include "ui/gl/gl_context_glx.h" 32 #include "ui/gl/gl_context_glx.h"
33 #endif
32 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 34 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
33 #elif defined(OS_ANDROID) 35 #elif defined(OS_ANDROID)
34 #include "content/common/gpu/media/android_video_decode_accelerator.h" 36 #include "content/common/gpu/media/android_video_decode_accelerator.h"
35 #endif 37 #endif
36 38
37 #include "ui/gfx/size.h" 39 #include "ui/gfx/size.h"
38 40
39 namespace content { 41 namespace content {
40 42
41 static bool MakeDecoderContextCurrent( 43 static bool MakeDecoderContextCurrent(
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 video_decode_accelerator_.reset(new DXVAVideoDecodeAccelerator( 272 video_decode_accelerator_.reset(new DXVAVideoDecodeAccelerator(
271 this, make_context_current_)); 273 this, make_context_current_));
272 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 274 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
273 video_decode_accelerator_.reset(new ExynosVideoDecodeAccelerator( 275 video_decode_accelerator_.reset(new ExynosVideoDecodeAccelerator(
274 gfx::GLSurfaceEGL::GetHardwareDisplay(), 276 gfx::GLSurfaceEGL::GetHardwareDisplay(),
275 stub_->decoder()->GetGLContext()->GetHandle(), 277 stub_->decoder()->GetGLContext()->GetHandle(),
276 this, 278 this,
277 weak_factory_for_io_.GetWeakPtr(), 279 weak_factory_for_io_.GetWeakPtr(),
278 make_context_current_, 280 make_context_current_,
279 io_message_loop_)); 281 io_message_loop_));
280 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) 282 #elif defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
283 DLOG(INFO) << "Initializing VAAPI HW decoder.";
284 #if defined(VIDEO_TEXTURE_GLX_BACKEND)
281 gfx::GLContextGLX* glx_context = 285 gfx::GLContextGLX* glx_context =
282 static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); 286 static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext());
283 GLXContext glx_context_handle = 287 GLXContext glx_context_handle =
284 static_cast<GLXContext>(glx_context->GetHandle()); 288 static_cast<GLXContext>(glx_context->GetHandle());
285 video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( 289 video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator(
286 glx_context->display(), glx_context_handle, this, 290 glx_context->display(), glx_context_handle, this,
287 make_context_current_)); 291 make_context_current_));
292 #elif defined(VIDEO_TEXTURE_EGL_BACKEND)
293 video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator(
294 gfx::GLSurfaceEGL::GetHardwareDisplay(),
295 stub_->decoder()->GetGLContext()->GetHandle(),
296 this,
297 make_context_current_));
298 #endif
288 #elif defined(OS_ANDROID) 299 #elif defined(OS_ANDROID)
289 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator( 300 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
290 this, 301 this,
291 stub_->decoder()->AsWeakPtr(), 302 stub_->decoder()->AsWeakPtr(),
292 make_context_current_)); 303 make_context_current_));
293 #else 304 #else
294 NOTIMPLEMENTED() << "HW video decode acceleration not available."; 305 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
295 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 306 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
296 return; 307 return;
297 #endif 308 #endif
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; 502 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second;
492 GLenum target = texture_ref->texture()->target(); 503 GLenum target = texture_ref->texture()->target();
493 gpu::gles2::TextureManager* texture_manager = 504 gpu::gles2::TextureManager* texture_manager =
494 stub_->decoder()->GetContextGroup()->texture_manager(); 505 stub_->decoder()->GetContextGroup()->texture_manager();
495 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); 506 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0));
496 texture_manager->SetLevelCleared(texture_ref, target, 0, true); 507 texture_manager->SetLevelCleared(texture_ref, target, 0, true);
497 uncleared_textures_.erase(it); 508 uncleared_textures_.erase(it);
498 } 509 }
499 510
500 } // namespace content 511 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698