Advertisement
Guest User

vaapi_patch_r0.patch

a guest
May 2nd, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 22.70 KB | None | 0 0
  1. --- a/chrome/browser/about_flags.cc
  2. +++ b/chrome/browser/about_flags.cc
  3. @@ -1044,7 +1044,7 @@ const FeatureEntry kFeatureEntries[] = {
  4.          "disable-accelerated-video-decode",
  5.          flag_descriptions::kAcceleratedVideoDecodeName,
  6.          flag_descriptions::kAcceleratedVideoDecodeDescription,
  7. -        kOsMac | kOsWin | kOsCrOS | kOsAndroid,
  8. +        kOsAll,
  9.          SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
  10.      },
  11.  #if defined(OS_WIN)
  12. --- a/content/common/BUILD.gn
  13. +++ b/content/common/BUILD.gn
  14. @@ -13,6 +13,49 @@ if (is_mac) {
  15.    import("//build/config/mac/mac_sdk.gni")
  16.  }
  17.  
  18. +if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
  19. +  action("libva_generate_stubs") {
  20. +    extra_header = "../../media/gpu/va_stub_header.fragment"
  21. +
  22. +    script = "../../tools/generate_stubs/generate_stubs.py"
  23. +    sources = [
  24. +      "../../media/gpu/vaapi/va.sigs",
  25. +    ]
  26. +    inputs = [
  27. +      extra_header,
  28. +    ]
  29. +    sources += [ "../../media/gpu/vaapi/va_x11.sigs" ]
  30. +    if (use_ozone) {
  31. +      sources += [
  32. +        "../../media/gpu/vaapi/va_drm.sigs",
  33. +        "va_wayland.sigs",
  34. +      ]
  35. +    }
  36. +    stubs_filename_root = "va_stubs"
  37. +
  38. +    outputs = [
  39. +      "$target_gen_dir/$stubs_filename_root.cc",
  40. +      "$target_gen_dir/$stubs_filename_root.h",
  41. +    ]
  42. +    args = [
  43. +      "-i",
  44. +      rebase_path("$target_gen_dir", root_build_dir),
  45. +      "-o",
  46. +      rebase_path("$target_gen_dir", root_build_dir),
  47. +      "-t",
  48. +      "posix_stubs",
  49. +      "-e",
  50. +      rebase_path(extra_header, root_build_dir),
  51. +      "-s",
  52. +      stubs_filename_root,
  53. +      "-p",
  54. +      "content/common",
  55. +    ]
  56. +
  57. +    args += rebase_path(sources, root_build_dir)
  58. +  }
  59. +}
  60. +
  61.  source_set("common") {
  62.    # Targets external to content should always link to the public API.
  63.    # In addition, targets outside of the content component (shell and tests)
  64. @@ -525,6 +568,16 @@ source_set("common") {
  65.          "sandbox_linux/android/sandbox_bpf_base_policy_android.h",
  66.        ]
  67.      }
  68. +  } else {
  69. +    if (current_cpu != "arm" && is_desktop_linux) {
  70. +      sources += get_target_outputs(":libva_generate_stubs")
  71. +      deps += [ ":libva_generate_stubs" ]
  72. +      configs += [ "//third_party/libva:libva_config" ]
  73. +      if (use_ozone) {
  74. +        configs += [ "//build/config/linux:x11" ]
  75. +        deps += [ "//third_party/wayland:wayland_client" ]
  76. +      }
  77. +    }
  78.    }
  79.  
  80.    if (is_mac) {
  81. --- a/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
  82. +++ b/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
  83. @@ -25,6 +25,12 @@
  84.  #include "base/memory/ptr_util.h"
  85.  #include "base/strings/stringprintf.h"
  86.  #include "build/build_config.h"
  87. +
  88. +#if !defined(__arm__)
  89. +// Auto-generated for dlopen libva libraries
  90. +#include "content/common/va_stubs.h"
  91. +#endif
  92. +
  93.  #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
  94.  #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
  95.  #include "content/common/set_process_title.h"
  96. @@ -36,6 +42,28 @@
  97.  #include "sandbox/linux/syscall_broker/broker_process.h"
  98.  #include "sandbox/linux/system_headers/linux_syscalls.h"
  99.  
  100. +#if !defined(__arm__)
  101. +#include "third_party/libva/va/va.h"
  102. +#include "third_party/libva/va/va_backend.h"
  103. +#if defined(USE_X11)
  104. +#include "third_party/libva/va/va_x11.h"
  105. +#include "ui/gfx/x/x11_types.h"
  106. +#elif defined(USE_OZONE)
  107. +#include "base/files/file.h"
  108. +#include "third_party/libva/va/drm/va_drm.h"
  109. +#include "third_party/libva/va/va_drmcommon.h"
  110. +#endif
  111. +#endif
  112. +
  113. +#define DRIVER_EXTENSION        "_drv_video.so"
  114. +#if defined(__x86_64__)
  115. +#define VA_DRIVERS_PATH         "/usr/lib/x86_64-linux-gnu/dri"
  116. +#elif defined(__i386__)
  117. +#define VA_DRIVERS_PATH         "/usr/lib/i386-linux-gnu/dri"
  118. +#elif defined(__aarch64__)
  119. +#define VA_DRIVERS_PATH         "/usr/lib/aarch64-linux-gnu/dri"
  120. +#endif
  121. +
  122.  using sandbox::arch_seccomp_data;
  123.  using sandbox::bpf_dsl::Allow;
  124.  using sandbox::bpf_dsl::ResultExpr;
  125. @@ -44,6 +72,17 @@ using sandbox::syscall_broker::BrokerFilePermission;
  126.  using sandbox::syscall_broker::BrokerProcess;
  127.  using sandbox::SyscallSets;
  128.  
  129. +#if !defined(__arm__)
  130. +using content_common::kModuleVa;
  131. +#if defined(USE_X11)
  132. +using content_common::kModuleVa_x11;
  133. +#elif defined(USE_OZONE)
  134. +using content_common::kModuleVa_drm;
  135. +#endif
  136. +using content_common::InitializeStubs;
  137. +using content_common::StubPathMap;
  138. +#endif
  139. +
  140.  namespace content {
  141.  
  142.  namespace {
  143. @@ -98,7 +137,7 @@ inline bool UseLibV4L2() {
  144.  
  145.  bool IsAcceleratedVaapiVideoEncodeEnabled() {
  146.    bool accelerated_encode_enabled = false;
  147. -#if defined(OS_CHROMEOS)
  148. +#if defined(OS_CHROMEOS) || defined(OS_LINUX)
  149.    const base::CommandLine& command_line =
  150.        *base::CommandLine::ForCurrentProcess();
  151.    accelerated_encode_enabled =
  152. @@ -290,6 +329,36 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
  153.    }
  154.  }
  155.  
  156. +#if !defined(__arm__)
  157. +static VADisplay VaapiGetVADisplay() {
  158. +  StubPathMap paths;
  159. +  VADisplay va_display;
  160. +  paths[kModuleVa].push_back("libva.so.1");
  161. +#if defined(USE_OZONE)
  162. +  paths[kModuleVa_drm].push_back("libva-drm.so.1");
  163. +#elif defined (USE_X11)
  164. +  paths[kModuleVa_x11].push_back("libva-x11.so.1");
  165. +#endif
  166. +  if (!InitializeStubs(paths)) {
  167. +    return NULL;
  168. +  }
  169. +#if defined(USE_OZONE)
  170. +  const char kDriRenderNode0Path[] = "/dev/dri/renderD128";
  171. +  base::File drm_file = base::File(
  172. +      base::FilePath::FromUTF8Unsafe(kDriRenderNode0Path),
  173. +      base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_WRITE);
  174. +  va_display = vaGetDisplayDRM(drm_file.GetPlatformFile());
  175. +#elif defined(USE_X11)
  176. +  va_display = vaGetDisplay(gfx::GetXDisplay());
  177. +#endif
  178. +  if (!vaDisplayIsValid(va_display)) {
  179. +    LOG(WARNING) << "Unable to get display.";
  180. +    return NULL;
  181. +  }
  182. +  return va_display;
  183. +}
  184. +#endif
  185. +
  186.  bool GpuProcessPolicy::PreSandboxHook() {
  187.    // Warm up resources needed by the policy we're about to enable and
  188.   // eventually start a broker process.
  189. @@ -303,32 +372,75 @@ bool GpuProcessPolicy::PreSandboxHook() {
  190.       GpuBrokerProcessPolicy::Create,
  191.       std::vector<BrokerFilePermission>());  // No extra files in whitelist.
  192.  
  193. +#if !defined(__arm__)
  194.   if (IsArchitectureX86_64() || IsArchitectureI386()) {
  195.     // Accelerated video dlopen()'s some shared objects
  196.      // inside the sandbox, so preload them now.
  197.      if (IsAcceleratedVaapiVideoEncodeEnabled() ||
  198.          IsAcceleratedVideoDecodeEnabled()) {
  199. -      const char* I965DrvVideoPath = NULL;
  200. -      const char* I965HybridDrvVideoPath = NULL;
  201. -
  202. -      if (IsArchitectureX86_64()) {
  203. -        I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
  204. -        I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so";
  205. -      } else if (IsArchitectureI386()) {
  206. -        I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
  207. -      }
  208. -
  209. -      dlopen(I965DrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  210. -      if (I965HybridDrvVideoPath)
  211. -        dlopen(I965HybridDrvVideoPath, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  212. -      dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  213. +      // Init a VA Context, get driver name (and path), close context and preload
  214. +#if defined(USE_OZONE) || defined(USE_X11)
  215. +      VADisplay va_display = VaapiGetVADisplay();
  216. +      if (va_display) {
  217. +        char *va_search_path = getenv("LIBVA_DRIVERS_PATH");
  218. +        char *va_driver_name = getenv("LIBVA_DRIVER_NAME");
  219. +        char *saveptr, *driver_dir;
  220. +        if (!va_driver_name) {
  221. +          VADisplayContextP pDisplayContext =
  222. +            static_cast<VADisplayContextP>(va_display);
  223. +          pDisplayContext->vaGetDriverName(pDisplayContext, &va_driver_name);
  224. +        }
  225. +
  226. +        if (!va_driver_name) {
  227. +          return true;
  228. +        }
  229. +
  230. +        if (!va_search_path) {
  231. +          va_search_path = strdup(VA_DRIVERS_PATH);
  232. +        }
  233. +
  234. +        driver_dir = strtok_r(va_search_path, ":", &saveptr);
  235. +        while (driver_dir) {
  236. +          std::string driver_path = base::StringPrintf("%s/%s%s", driver_dir,
  237. +              va_driver_name, DRIVER_EXTENSION);
  238. +
  239. +          // attempt to dlopen() the va driver
  240. +          LOG(INFO) << "Looking for " << driver_path << "...";
  241. +          if (access(driver_path.c_str(), R_OK) != -1) {
  242. +            LOG(WARNING) << "Attempting to pre-load " << va_driver_name << " VA driver...";
  243. +            if (dlopen(driver_path.c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
  244. +              LOG(WARNING) << "VA driver \"" << driver_path << "\" opened!";
  245. +
  246. +              if (strcmp(va_driver_name, "nvidia") == 0) {
  247. +                LOG(WARNING) << "Pre-loading NVIDIA VDPAU driver libraries...";
  248. +                if (dlopen("libvdpau_nvidia.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
  249. +                  LOG(WARNING) << "Loaded libvdpau_nvidia.so";
  250. +                }
  251. +
  252. +                if (dlopen("libvdpau.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
  253. +                  LOG(WARNING) << "Loaded libvdpau.so";
  254. +                }
  255. +              }
  256. +              LOG(WARNING) << "Loading libva libraries...";
  257. +              dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  258.  #if defined(USE_OZONE)
  259. -      dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  260. +              dlopen("libva-drm.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  261.  #elif defined(USE_X11)
  262. -      dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  263. +              dlopen("libva-x11.so.1", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
  264. +#endif
  265. +              break;
  266. +            }
  267. +            LOG(ERROR) << "VA driver failed to open!";
  268. +          }
  269. +
  270. +          driver_dir = strtok_r(NULL, ":", &saveptr);
  271. +        }
  272. +        free(va_search_path);
  273. +      }
  274.  #endif
  275.      }
  276.    }
  277. +#endif
  278.  
  279.    return true;
  280.  }
  281. --- /dev/null
  282. +++ b/content/common/va_wayland.sigs
  283. @@ -0,0 +1,8 @@
  284. +// Copyright 2014 The Chromium Authors. All rights reserved.
  285. +// Use of this source code is governed by a BSD-style license that can be
  286. +// found in the LICENSE file.
  287. +
  288. +//------------------------------------------------
  289. +// Functions from libva-wayland used in chromium code.
  290. +//------------------------------------------------
  291. +VADisplay vaGetDisplayWl(struct wl_display *display);
  292. --- a/content/gpu/BUILD.gn
  293. +++ b/content/gpu/BUILD.gn
  294. @@ -92,7 +92,7 @@ target(link_target_type, "gpu_sources") {
  295.      ]
  296.    }
  297.  
  298. -  if (is_chromeos && current_cpu != "arm") {
  299. +  if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
  300.      configs += [ "//third_party/libva:libva_config" ]
  301.    }
  302.  
  303. --- a/content/gpu/gpu_main.cc
  304. +++ b/content/gpu/gpu_main.cc
  305. @@ -85,7 +85,7 @@
  306.  #include "ui/ozone/public/ozone_platform.h"
  307.  #endif
  308.  
  309. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
  310. +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
  311.  #include "media/gpu/vaapi_wrapper.h"
  312.  #endif
  313.  
  314. @@ -141,7 +141,7 @@ class ContentSandboxHelper : public gpu::GpuSandboxHelper {
  315.        (void)base::RandUint64();
  316.      }
  317.  
  318. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
  319. +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
  320.      media::VaapiWrapper::PreSandboxInitialization();
  321.  #endif
  322.  #if defined(OS_WIN)
  323. --- a/content/public/common/content_switches.cc
  324. +++ b/content/public/common/content_switches.cc
  325. @@ -1000,7 +1000,9 @@ const char kDisableAudioSupportForDesktopShare[] =
  326.  #if defined(OS_CHROMEOS)
  327.  // Disables panel fitting (used for mirror mode).
  328.  const char kDisablePanelFitting[]           = "disable-panel-fitting";
  329. +#endif
  330.  
  331. +#if defined(OS_CHROMEOS) || defined(OS_LINUX)
  332.  // Disables VA-API accelerated video encode.
  333.  const char kDisableVaapiAcceleratedVideoEncode[] =
  334.      "disable-vaapi-accelerated-video-encode";
  335. --- a/content/public/common/content_switches.h
  336. +++ b/content/public/common/content_switches.h
  337. @@ -291,6 +291,8 @@ CONTENT_EXPORT extern const char kEnableOSKOverscroll[];
  338.  
  339.  #if defined(OS_CHROMEOS)
  340.  CONTENT_EXPORT extern const char kDisablePanelFitting[];
  341. +#endif
  342. +#if defined(OS_CHROMEOS) || defined(OS_LINUX)
  343.  CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
  344.  #endif
  345.  
  346. --- a/gpu/config/software_rendering_list.json
  347. +++ b/gpu/config/software_rendering_list.json
  348. @@ -395,17 +395,6 @@ const char kSoftwareRenderingListJson[] = LONG_STRING_CONST(
  349.        ]
  350.      },
  351.      {
  352. -      "id": 48,
  353. -      "description": "Accelerated video decode is unavailable on Linux",
  354. -      "cr_bugs": [137247],
  355. -      "os": {
  356. -        "type": "linux"
  357. -      },
  358. -      "features": [
  359. -        "accelerated_video_decode"
  360. -      ]
  361. -    },
  362. -    {
  363.        "id": 50,
  364.        "description": "Disable VMware software renderer on older Mesa",
  365.        "cr_bugs": [145531, 332596, 571899, 629434],
  366. --- a/media/BUILD.gn
  367. +++ b/media/BUILD.gn
  368. @@ -396,7 +396,7 @@ component("media") {
  369.      allow_circular_includes_from = [ "//media/base/android" ]
  370.    }
  371.  
  372. -  if (current_cpu != "arm" && is_chromeos) {
  373. +  if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
  374.      sources += [
  375.        "filters/h264_bitstream_buffer.cc",
  376.        "filters/h264_bitstream_buffer.h",
  377. @@ -667,7 +667,7 @@ source_set("unit_tests") {
  378.      }
  379.    }
  380.  
  381. -  if (current_cpu != "arm" && is_chromeos) {
  382. +  if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
  383.      sources += [ "filters/h264_bitstream_buffer_unittest.cc" ]
  384.    }
  385.  
  386. --- a/media/gpu/BUILD.gn
  387. +++ b/media/gpu/BUILD.gn
  388. @@ -18,7 +18,7 @@ if (is_mac) {
  389.    import("//build/config/mac/mac_sdk.gni")
  390.  }
  391.  
  392. -if (is_chromeos && current_cpu != "arm") {
  393. +if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
  394.    action("libva_generate_stubs") {
  395.      extra_header = "va_stub_header.fragment"
  396.  
  397. @@ -212,7 +212,7 @@ component("gpu") {
  398.      }
  399.    }
  400.  
  401. -  if (is_chromeos || is_win) {
  402. +  if (is_linux || is_win) {
  403.      sources += [
  404.        "accelerated_video_decoder.h",
  405.        "h264_decoder.cc",
  406. @@ -221,7 +221,7 @@ component("gpu") {
  407.        "h264_dpb.h",
  408.      ]
  409.    }
  410. -  if (is_chromeos) {
  411. +  if (is_linux) {
  412.      sources += [
  413.        "vp8_decoder.cc",
  414.        "vp8_decoder.h",
  415. @@ -259,7 +259,7 @@ component("gpu") {
  416.          "EGL",
  417.          "GLESv2",
  418.        ]
  419. -      if (current_cpu == "arm") {
  420. +      if (current_cpu == "arm" && is_chromeos) {
  421.          sources += [
  422.            "tegra_v4l2_device.cc",
  423.            "tegra_v4l2_device.h",
  424. --- a/media/gpu/gpu_video_decode_accelerator_factory.cc
  425. +++ b/media/gpu/gpu_video_decode_accelerator_factory.cc
  426. @@ -16,7 +16,7 @@
  427.  #include "media/gpu/dxva_video_decode_accelerator_win.h"
  428.  #elif defined(OS_MACOSX)
  429.  #include "media/gpu/vt_video_decode_accelerator_mac.h"
  430. -#elif defined(OS_CHROMEOS)
  431. +#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
  432.  #if defined(USE_V4L2_CODEC)
  433.  #include "media/gpu/v4l2_device.h"
  434.  #include "media/gpu/v4l2_slice_video_decode_accelerator.h"
  435. @@ -82,7 +82,7 @@ GpuVideoDecodeAcceleratorFactory::GetDecoderCapabilities(
  436.  #if defined(OS_WIN)
  437.    capabilities.supported_profiles =
  438.        DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences);
  439. -#elif defined(OS_CHROMEOS)
  440. +#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
  441.    VideoDecodeAccelerator::SupportedProfiles vda_profiles;
  442.  #if defined(USE_V4L2_CODEC)
  443.    vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
  444. @@ -135,7 +135,7 @@ GpuVideoDecodeAcceleratorFactory::CreateVDA(
  445.      &GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA,
  446.      &GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA,
  447.  #endif
  448. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
  449. +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
  450.      &GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA,
  451.  #endif
  452.  #if defined(OS_MACOSX)
  453. @@ -218,11 +218,12 @@ GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA(
  454.  }
  455.  #endif
  456.  
  457. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
  458. +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
  459.  std::unique_ptr<VideoDecodeAccelerator>
  460.  GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA(
  461.      const gpu::GpuDriverBugWorkarounds& workarounds,
  462.      const gpu::GpuPreferences& gpu_preferences) const {
  463. +  VLOG(1) << "Creating new VAAPI video decode accelerator.";
  464.    std::unique_ptr<VideoDecodeAccelerator> decoder;
  465.    decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
  466.                                                  bind_image_cb_));
  467. --- a/media/gpu/gpu_video_decode_accelerator_factory.h
  468. +++ b/media/gpu/gpu_video_decode_accelerator_factory.h
  469. @@ -101,7 +101,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcceleratorFactory {
  470.        const gpu::GpuDriverBugWorkarounds& workarounds,
  471.        const gpu::GpuPreferences& gpu_preferences) const;
  472.  #endif
  473. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
  474. +#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
  475.    std::unique_ptr<VideoDecodeAccelerator> CreateVaapiVDA(
  476.        const gpu::GpuDriverBugWorkarounds& workarounds,
  477.        const gpu::GpuPreferences& gpu_preferences) const;
  478. --- a/media/gpu/ipc/service/BUILD.gn
  479. +++ b/media/gpu/ipc/service/BUILD.gn
  480. @@ -47,7 +47,7 @@ target(link_target_type, "service") {
  481.  
  482.    configs += [ "//media/gpu:gpu_config" ]
  483.  
  484. -  if (is_chromeos && current_cpu != "arm") {
  485. +  if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
  486.      configs += [ "//third_party/libva:libva_config" ]
  487.    }
  488.  
  489. --- a/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
  490. +++ b/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
  491. @@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent(
  492.    return true;
  493.  }
  494.  
  495. -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \
  496. +#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || \
  497.      defined(OS_MACOSX) || defined(OS_WIN)
  498.  static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub,
  499.                        uint32_t client_texture_id,
  500. @@ -172,7 +172,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
  501.    get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr());
  502.    make_context_current_cb_ =
  503.        base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr());
  504. -#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || \
  505. +#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || \
  506.      defined(OS_MACOSX) || defined(OS_WIN)
  507.    bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr());
  508.  #endif
  509. --- a/media/gpu/va_stub_header.fragment
  510. +++ b/media/gpu/va_stub_header.fragment
  511. @@ -5,8 +5,9 @@ extern "C" {
  512.  
  513.  #include "third_party/libva/va/drm/va_drm.h"
  514.  #include "third_party/libva/va/va.h"
  515. -#if defined(USE_X11)
  516.  #include "third_party/libva/va/va_x11.h"
  517. +#if defined(USE_OZONE)
  518. +#include "third_party/libva/va/wayland/va_wayland.h"
  519.  #endif
  520.  
  521.  }
  522. --- a/media/gpu/vaapi_video_decode_accelerator.cc
  523. +++ b/media/gpu/vaapi_video_decode_accelerator.cc
  524. @@ -358,17 +358,17 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config,
  525.  
  526.    base::AutoLock auto_lock(lock_);
  527.    DCHECK_EQ(state_, kUninitialized);
  528. -  DVLOG(2) << "Initializing VAVDA, profile: " << GetProfileName(profile);
  529. +  VLOG(1) << "Initializing VAVDA, profile: " << GetProfileName(profile);
  530.  
  531.  #if defined(USE_X11)
  532.    if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) {
  533. -    DVLOG(1) << "HW video decode acceleration not available without "
  534. +    VLOG(1) << "HW video decode acceleration not available without "
  535.                  "DesktopGL (GLX).";
  536.      return false;
  537.    }
  538.  #elif defined(USE_OZONE)
  539.    if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) {
  540. -    DVLOG(1) << "HW video decode acceleration not available without "
  541. +    VLOG(1) << "HW video decode acceleration not available without "
  542.               << "EGLGLES2.";
  543.      return false;
  544.    }
  545. @@ -378,7 +378,7 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config,
  546.        VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR));
  547.  
  548.    if (!vaapi_wrapper_.get()) {
  549. -    DVLOG(1) << "Failed initializing VAAPI for profile "
  550. +    VLOG(1) << "Failed initializing VAAPI for profile "
  551.               << GetProfileName(profile);
  552.      return false;
  553.    }
  554. @@ -394,7 +394,7 @@ bool VaapiVideoDecodeAccelerator::Initialize(const Config& config,
  555.      vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get()));
  556.      decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
  557.    } else {
  558. -    DLOG(ERROR) << "Unsupported profile " << GetProfileName(profile);
  559. +    VLOG(1) << "Unsupported profile " << GetProfileName(profile);
  560.      return false;
  561.    }
  562.  
  563. --- a/media/gpu/vaapi_wrapper.cc
  564. +++ b/media/gpu/vaapi_wrapper.cc
  565. @@ -188,7 +188,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper::Create(
  566.      VAProfile va_profile,
  567.      const base::Closure& report_error_to_uma_cb) {
  568.    if (!GetProfileInfos()->IsProfileSupported(mode, va_profile)) {
  569. -    DVLOG(1) << "Unsupported va_profile: " << va_profile;
  570. +    VLOG(1) << "Unsupported va_profile: " << va_profile;
  571.      return nullptr;
  572.    }
  573.  
  574. @@ -340,15 +340,17 @@ VaapiWrapper::GetSupportedProfileInfosForCodecModeInternal(CodecMode mode) {
  575.  bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) {
  576.    static bool vaapi_functions_initialized = PostSandboxInitialization();
  577.    if (!vaapi_functions_initialized) {
  578. -    bool running_on_chromeos = false;
  579. -#if defined(OS_CHROMEOS)
  580. +    bool error_level_logging = false;
  581. +#if defined(OS_LINUX)
  582. +    error_level_logging = true;
  583. +#elif defined(OS_CHROMEOS)
  584.      // When chrome runs on linux with chromeos=1, do not log error message
  585.      // without VAAPI libraries.
  586. -    running_on_chromeos = base::SysInfo::IsRunningOnChromeOS();
  587. +    error_level_logging = base::SysInfo::IsRunningOnChromeOS();
  588.  #endif
  589.      static const char kErrorMsg[] = "Failed to initialize VAAPI libs";
  590. -    if (running_on_chromeos)
  591. -      LOG(ERROR) << kErrorMsg;
  592. +    if (error_level_logging)
  593. +      VLOG(1) << kErrorMsg;
  594.      else
  595.        DVLOG(1) << kErrorMsg;
  596.      return false;
  597. @@ -407,7 +409,7 @@ bool VaapiWrapper::IsEntrypointSupported_Locked(VAProfile va_profile,
  598.  
  599.    if (std::find(supported_entrypoints.begin(), supported_entrypoints.end(),
  600.                  entrypoint) == supported_entrypoints.end()) {
  601. -    DVLOG(1) << "Unsupported entrypoint";
  602. +    VLOG(1) << "Unsupported entrypoint";
  603.      return false;
  604.    }
  605.    return true;
  606. @@ -431,8 +433,8 @@ bool VaapiWrapper::AreAttribsSupported_Locked(
  607.      if (attribs[i].type != required_attribs[i].type ||
  608.          (attribs[i].value & required_attribs[i].value) !=
  609.              required_attribs[i].value) {
  610. -      DVLOG(1) << "Unsupported value " << required_attribs[i].value
  611. -               << " for attribute type " << required_attribs[i].type;
  612. +      VLOG(1) << "Unsupported value " << required_attribs[i].value
  613. +              << " for attribute type " << required_attribs[i].type;
  614.        return false;
  615.      }
  616.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement