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

Unified Diff: content/common/gpu/gpu_memory_buffer_factory_io_surface.cc

Issue 1389133002: content: Use type-parameterized tests for GpuMemoryBuffer implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add blankline Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
diff --git a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
index a6ce59fdd627b57c58a0eee83af99206a8e8712c..a6b41f3d1d10b84eb9886433dd5cb030ac9d42a4 100644
--- a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
+++ b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc
@@ -83,18 +83,6 @@ int32 PixelFormat(gfx::BufferFormat format) {
return 0;
}
-const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = {
- {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT},
- {gfx::BufferFormat::R_8, gfx::BufferUsage::PERSISTENT_MAP},
- {gfx::BufferFormat::R_8, gfx::BufferUsage::MAP},
- {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::PERSISTENT_MAP},
- {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP},
- {gfx::BufferFormat::UYVY_422, gfx::BufferUsage::MAP},
- {gfx::BufferFormat::UYVY_422, gfx::BufferUsage::PERSISTENT_MAP},
- {gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferUsage::MAP},
- {gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferUsage::PERSISTENT_MAP},
-};
-
} // namespace
GpuMemoryBufferFactoryIOSurface::GpuMemoryBufferFactoryIOSurface() {
@@ -107,29 +95,24 @@ GpuMemoryBufferFactoryIOSurface::~GpuMemoryBufferFactoryIOSurface() {
bool GpuMemoryBufferFactoryIOSurface::IsGpuMemoryBufferConfigurationSupported(
gfx::BufferFormat format,
gfx::BufferUsage usage) {
- for (auto& configuration : kSupportedConfigurations) {
- if (configuration.format == format && configuration.usage == usage)
- return true;
+ switch (usage) {
+ case gfx::BufferUsage::SCANOUT:
+ return format == gfx::BufferFormat::BGRA_8888;
+ case gfx::BufferUsage::MAP:
+ case gfx::BufferUsage::PERSISTENT_MAP:
+ 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;
}
-void GpuMemoryBufferFactoryIOSurface::GetSupportedGpuMemoryBufferConfigurations(
- std::vector<Configuration>* configurations) {
- configurations->assign(
- kSupportedConfigurations,
- kSupportedConfigurations + arraysize(kSupportedConfigurations));
-}
-
-gfx::GpuMemoryBufferHandle
-GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
- gfx::GpuMemoryBufferId id,
+// static
+IOSurfaceRef GpuMemoryBufferFactoryIOSurface::CreateIOSurface(
const gfx::Size& size,
- gfx::BufferFormat format,
- gfx::BufferUsage usage,
- int client_id,
- gfx::PluginWindowHandle surface_handle) {
+ gfx::BufferFormat format) {
size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format);
base::ScopedCFTypeRef<CFMutableArrayRef> planes(CFArrayCreateMutable(
kCFAllocatorDefault, num_planes, &kCFTypeArrayCallBacks));
@@ -158,7 +141,18 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format));
CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes);
- base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties));
+ return IOSurfaceCreate(properties);
+}
+
+gfx::GpuMemoryBufferHandle
+GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId id,
+ const gfx::Size& size,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage,
+ int client_id,
+ gfx::PluginWindowHandle surface_handle) {
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface(CreateIOSurface(size, format));
if (!io_surface)
return gfx::GpuMemoryBufferHandle();

Powered by Google App Engine
This is Rietveld 408576698