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

Side by Side Diff: gpu/ipc/host/gpu_memory_buffer_support.cc

Issue 2684993005: (NotForReview) Enable YUV video overlay on Skylake ChromeOS.
Patch Set: rebase to ToT (Mar/27) Created 3 years, 9 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 | « gpu/ipc/host/gpu_memory_buffer_support.h ('k') | gpu/ipc/host/gpu_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gpu/ipc/host/gpu_memory_buffer_support.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "build/build_config.h"
10 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
11 #include "gpu/ipc/host/gpu_switches.h"
12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_implementation.h"
14 #include "ui/gl/gl_switches.h"
15
16 namespace gpu {
17
18 bool AreNativeGpuMemoryBuffersEnabled() {
19 // Disable native buffers when using software GL.
20 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
21 switches::kUseGL) ==
22 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation())) {
23 return false;
24 }
25
26 #if defined(OS_MACOSX)
27 return !base::CommandLine::ForCurrentProcess()->HasSwitch(
28 switches::kDisableNativeGpuMemoryBuffers);
29 #else
30 return base::CommandLine::ForCurrentProcess()->HasSwitch(
31 switches::kEnableNativeGpuMemoryBuffers);
32 #endif
33 }
34
35 GpuMemoryBufferConfigurationSet GetNativeGpuMemoryBufferConfigurations() {
36 GpuMemoryBufferConfigurationSet configurations;
37
38 #if defined(USE_OZONE) || defined(OS_MACOSX)
39 if (AreNativeGpuMemoryBuffersEnabled()) {
40 const gfx::BufferFormat kNativeFormats[] = {
41 gfx::BufferFormat::R_8,
42 gfx::BufferFormat::RG_88,
43 gfx::BufferFormat::BGR_565,
44 gfx::BufferFormat::RGBA_4444,
45 gfx::BufferFormat::RGBA_8888,
46 gfx::BufferFormat::BGRA_8888,
47 gfx::BufferFormat::UYVY_422,
48 gfx::BufferFormat::YVU_420,
49 gfx::BufferFormat::YUV_420_BIPLANAR};
50 const gfx::BufferUsage kNativeUsages[] = {
51 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
52 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
53 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
54 for (auto format : kNativeFormats) {
55 for (auto usage : kNativeUsages) {
56 if (IsNativeGpuMemoryBufferConfigurationSupported(format, usage))
57 configurations.insert(std::make_pair(format, usage));
58 }
59 }
60 }
61
62 // Disable native buffers only when using software GL.
63 bool force_native_gpu_read_write_formats =
64 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
65 switches::kUseGL) !=
66 gl::GetGLImplementationName(gl::GetSoftwareGLImplementation());
67 if (force_native_gpu_read_write_formats) {
68 const gfx::BufferFormat kGPUReadWriteFormats[] = {
69 gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_8888,
70 gfx::BufferFormat::RGBX_8888, gfx::BufferFormat::BGRA_8888,
71 gfx::BufferFormat::BGRX_8888, gfx::BufferFormat::UYVY_422,
72 gfx::BufferFormat::YVU_420, gfx::BufferFormat::YUV_420_BIPLANAR};
73 const gfx::BufferUsage kGPUReadWriteUsages[] = {
74 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
75 gfx::BufferUsage::SCANOUT_CPU_READ_WRITE};
76 for (auto format : kGPUReadWriteFormats) {
77 for (auto usage : kGPUReadWriteUsages) {
78 if (IsNativeGpuMemoryBufferConfigurationSupported(format, usage))
79 configurations.insert(std::make_pair(format, usage));
80 }
81 }
82 }
83 #endif // defined(USE_OZONE) || defined(OS_MACOSX)
84
85 return configurations;
86 }
87
88 uint32_t GetImageTextureTarget(gfx::BufferFormat format,
89 gfx::BufferUsage usage) {
90 #if defined(USE_OZONE) || defined(OS_MACOSX)
91 GpuMemoryBufferConfigurationSet native_configurations =
92 GetNativeGpuMemoryBufferConfigurations();
93 if (native_configurations.find(std::make_pair(format, usage)) ==
94 native_configurations.end()) {
95 return GL_TEXTURE_2D;
96 }
97
98 switch (GetNativeGpuMemoryBufferType()) {
99 case gfx::NATIVE_PIXMAP:
100 // GPU memory buffers that are shared with the GL using EGLImages
101 // require TEXTURE_EXTERNAL_OES.
102 return GL_TEXTURE_EXTERNAL_OES;
103 case gfx::IO_SURFACE_BUFFER:
104 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB.
105 return GL_TEXTURE_RECTANGLE_ARB;
106 case gfx::SHARED_MEMORY_BUFFER:
107 case gfx::EMPTY_BUFFER:
108 break;
109 }
110 NOTREACHED();
111 return GL_TEXTURE_2D;
112 #else // defined(USE_OZONE) || defined(OS_MACOSX)
113 return GL_TEXTURE_2D;
114 #endif
115 }
116
117 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/host/gpu_memory_buffer_support.h ('k') | gpu/ipc/host/gpu_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698