summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2016-03-23 17:27:12 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-24 00:28:29 +0000
commitc27742238e78f1e2f7f6fe37f101eb0d07483416 (patch)
treee15a09d867f489fc54367b3bbfa5d04432b395b6 /gpu
parent26befa044b2ce9ed1b5dfd83eb5a67d1a964bb8c (diff)
downloadchromium_src-c27742238e78f1e2f7f6fe37f101eb0d07483416.zip
chromium_src-c27742238e78f1e2f7f6fe37f101eb0d07483416.tar.gz
chromium_src-c27742238e78f1e2f7f6fe37f101eb0d07483416.tar.bz2
Pull gpu service/client shared memory buffer code to GpuMemoryBufferSupport
GpuMemoryBufferFactory is a gpu service concept and should not be accessed from the client. Client code accessed GpuMemoryBufferFactory to get the native GPU buffer type and to check whether a provided buffer is supported. Depending on GpuMemoryBufferFactory ends up pulling in other service-only bits. This CL addresses this issue. The two static methods accessed by clients are pulled into a new class: GpuMemoryBufferSupport placed in gpu/ipc/common. BUG=597170 CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel Review URL: https://codereview.chromium.org/1831513003 Cr-Commit-Position: refs/heads/master@{#382987}
Diffstat (limited to 'gpu')
-rw-r--r--gpu/gpu_ipc_common.gypi23
-rw-r--r--gpu/ipc/common/BUILD.gn8
-rw-r--r--gpu/ipc/common/gpu_memory_buffer_support.cc74
-rw-r--r--gpu/ipc/common/gpu_memory_buffer_support.h25
4 files changed, 122 insertions, 8 deletions
diff --git a/gpu/gpu_ipc_common.gypi b/gpu/gpu_ipc_common.gypi
index 6f2bfaa9..9e9ea60 100644
--- a/gpu/gpu_ipc_common.gypi
+++ b/gpu/gpu_ipc_common.gypi
@@ -20,16 +20,18 @@
'..',
],
'sources': [
- "ipc/common/gpu_memory_uma_stats.h",
- "ipc/common/gpu_message_generator.cc",
- "ipc/common/gpu_message_generator.h",
- "ipc/common/gpu_messages.h",
+ 'ipc/common/gpu_memory_buffer_support.cc',
+ 'ipc/common/gpu_memory_buffer_support.h',
+ 'ipc/common/gpu_memory_uma_stats.h',
+ 'ipc/common/gpu_message_generator.cc',
+ 'ipc/common/gpu_message_generator.h',
+ 'ipc/common/gpu_messages.h',
'ipc/common/gpu_param_traits.cc',
'ipc/common/gpu_param_traits.h',
'ipc/common/gpu_param_traits_macros.h',
- "ipc/common/gpu_stream_constants.h",
- "ipc/common/gpu_surface_lookup.cc",
- "ipc/common/gpu_surface_lookup.h",
+ 'ipc/common/gpu_stream_constants.h',
+ 'ipc/common/gpu_surface_lookup.cc',
+ 'ipc/common/gpu_surface_lookup.h',
],
'conditions': [
# This section applies to gpu_ipc_win64, used by the NaCl Win64 helper
@@ -41,5 +43,10 @@
'../ipc/ipc.gyp:ipc',
],
}],
- ],
+ ['use_ozone==1', {
+ 'dependencies': [
+ '../ui/ozone/ozone.gyp:ozone_platform',
+ ],
+ }],
+ ],
}
diff --git a/gpu/ipc/common/BUILD.gn b/gpu/ipc/common/BUILD.gn
index 5bbbf43..074f7d9 100644
--- a/gpu/ipc/common/BUILD.gn
+++ b/gpu/ipc/common/BUILD.gn
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/ui.gni")
+
group("common") {
if (is_component_build) {
public_deps = [
@@ -52,6 +54,8 @@ source_set("ipc_common_sources") {
visibility = [ "//gpu/*" ]
sources = [
+ "gpu_memory_buffer_support.cc",
+ "gpu_memory_buffer_support.h",
"gpu_memory_uma_stats.h",
"gpu_message_generator.cc",
"gpu_message_generator.h",
@@ -91,4 +95,8 @@ source_set("ipc_common_sources") {
"android/surface_texture_peer.h",
]
}
+
+ if (use_ozone) {
+ deps += [ "//ui/ozone" ]
+ }
}
diff --git a/gpu/ipc/common/gpu_memory_buffer_support.cc b/gpu/ipc/common/gpu_memory_buffer_support.cc
new file mode 100644
index 0000000..0d1c510
--- /dev/null
+++ b/gpu/ipc/common/gpu_memory_buffer_support.cc
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/ipc/common/gpu_memory_buffer_support.h"
+
+#include "base/logging.h"
+#include "build/build_config.h"
+
+#if defined(USE_OZONE)
+#include "ui/ozone/public/client_native_pixmap_factory.h"
+#endif
+
+namespace gpu {
+
+gfx::GpuMemoryBufferType GetNativeGpuMemoryBufferType() {
+#if defined(OS_MACOSX)
+ return gfx::IO_SURFACE_BUFFER;
+#endif
+#if defined(OS_ANDROID)
+ return gfx::SURFACE_TEXTURE_BUFFER;
+#endif
+#if defined(USE_OZONE)
+ return gfx::OZONE_NATIVE_PIXMAP;
+#endif
+ return gfx::EMPTY_BUFFER;
+}
+
+bool IsNativeGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format,
+ gfx::BufferUsage usage) {
+#if defined(OS_MACOSX)
+ switch (usage) {
+ case gfx::BufferUsage::GPU_READ:
+ case gfx::BufferUsage::SCANOUT:
+ return format == gfx::BufferFormat::BGRA_8888 ||
+ format == gfx::BufferFormat::RGBA_8888;
+ case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
+ case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
+ return format == gfx::BufferFormat::R_8 ||
+ format == gfx::BufferFormat::BGRA_8888 ||
+ format == gfx::BufferFormat::UYVY_422 ||
+ format == gfx::BufferFormat::YUV_420_BIPLANAR;
+ }
+ NOTREACHED();
+ return false;
+#endif
+
+#if defined(OS_ANDROID)
+ switch (usage) {
+ case gfx::BufferUsage::GPU_READ:
+ case gfx::BufferUsage::SCANOUT:
+ case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT:
+ return false;
+ case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE:
+ return format == gfx::BufferFormat::RGBA_8888;
+ }
+ NOTREACHED();
+ return false;
+#endif
+
+#if defined(USE_OZONE)
+ if (!ui::ClientNativePixmapFactory::GetInstance()) {
+ // unittests don't have to set ClientNativePixmapFactory.
+ return false;
+ }
+ return ui::ClientNativePixmapFactory::GetInstance()->IsConfigurationSupported(
+ format, usage);
+#endif
+
+ NOTREACHED();
+ return false;
+}
+
+} // namespace gpu
diff --git a/gpu/ipc/common/gpu_memory_buffer_support.h b/gpu/ipc/common/gpu_memory_buffer_support.h
new file mode 100644
index 0000000..6c32f46
--- /dev/null
+++ b/gpu/ipc/common/gpu_memory_buffer_support.h
@@ -0,0 +1,25 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_IPC_COMMON_GPU_MEMORY_BUFFER_SUPPORT_H_
+#define GPU_IPC_COMMON_GPU_MEMORY_BUFFER_SUPPORT_H_
+
+#include "gpu/gpu_export.h"
+#include "ui/gfx/buffer_types.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+
+namespace gpu {
+
+// Returns the native GPU memory buffer factory type. Returns EMPTY_BUFFER
+// type if native buffers are not supported.
+GPU_EXPORT gfx::GpuMemoryBufferType GetNativeGpuMemoryBufferType();
+
+// Returns whether the provided buffer format is supported.
+GPU_EXPORT bool IsNativeGpuMemoryBufferConfigurationSupported(
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage);
+
+} // namespace gpu
+
+#endif // GPU_IPC_COMMON_GPU_MEMORY_BUFFER_SUPPORT_H_