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 eeec46039404502fccf79b4e59ea3d3154d6dc90..0bb014523685bf756b10ccdae19806b3c085fcf9 100644 |
--- a/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
+++ b/content/common/gpu/gpu_memory_buffer_factory_io_surface.cc |
@@ -26,6 +26,7 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary, |
int32 BytesPerPixel(gfx::BufferFormat format) { |
switch (format) { |
case gfx::BufferFormat::R_8: |
+ case gfx::BufferFormat::YUV_420_BIPLANAR: |
return 1; |
case gfx::BufferFormat::BGRA_8888: |
return 4; |
@@ -52,6 +53,8 @@ int32 PixelFormat(gfx::BufferFormat format) { |
return 'L008'; |
case gfx::BufferFormat::BGRA_8888: |
return 'BGRA'; |
+ case gfx::BufferFormat::YUV_420_BIPLANAR: |
+ return '420v'; |
case gfx::BufferFormat::ATC: |
case gfx::BufferFormat::ATCIA: |
case gfx::BufferFormat::DXT1: |
@@ -74,7 +77,11 @@ const GpuMemoryBufferFactory::Configuration kSupportedConfigurations[] = { |
{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::BGRA_8888, gfx::BufferUsage::MAP}, |
+ {gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferUsage::MAP}, |
+ {gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferUsage::PERSISTENT_MAP}, |
+ {gfx::BufferFormat::YUV_420_BIPLANAR, gfx::BufferUsage::SCANOUT}, |
reveman
2015/08/10 22:40:55
SCANOUT is supported by some other formats too, co
Andre
2015/08/11 03:50:46
Done, removed the SCANOUT usage from this patch.
I
|
+}; |
} // namespace |
@@ -111,16 +118,42 @@ GpuMemoryBufferFactoryIOSurface::CreateGpuMemoryBuffer( |
gfx::BufferUsage usage, |
int client_id, |
gfx::PluginWindowHandle surface_handle) { |
- base::ScopedCFTypeRef<CFMutableDictionaryRef> properties; |
- properties.reset(CFDictionaryCreateMutable(kCFAllocatorDefault, |
- 0, |
- &kCFTypeDictionaryKeyCallBacks, |
- &kCFTypeDictionaryValueCallBacks)); |
+ base::ScopedCFTypeRef<CFMutableDictionaryRef> properties( |
+ CFDictionaryCreateMutable(kCFAllocatorDefault, 0, |
+ &kCFTypeDictionaryKeyCallBacks, |
+ &kCFTypeDictionaryValueCallBacks)); |
AddIntegerValue(properties, kIOSurfaceWidth, size.width()); |
AddIntegerValue(properties, kIOSurfaceHeight, size.height()); |
- AddIntegerValue(properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); |
AddIntegerValue(properties, kIOSurfacePixelFormat, PixelFormat(format)); |
+ if (format == gfx::BufferFormat::YUV_420_BIPLANAR) { |
+ // This format has 2 planes, Y and interleaved UV. |
+ base::ScopedCFTypeRef<CFMutableDictionaryRef> y_plane( |
+ CFDictionaryCreateMutable(kCFAllocatorDefault, 0, |
+ &kCFTypeDictionaryKeyCallBacks, |
+ &kCFTypeDictionaryValueCallBacks)); |
+ AddIntegerValue(y_plane, kIOSurfacePlaneWidth, size.width()); |
+ AddIntegerValue(y_plane, kIOSurfacePlaneHeight, size.height()); |
+ AddIntegerValue(y_plane, kIOSurfacePlaneBytesPerElement, 1); |
+ |
+ base::ScopedCFTypeRef<CFMutableDictionaryRef> uv_plane( |
+ CFDictionaryCreateMutable(kCFAllocatorDefault, 0, |
+ &kCFTypeDictionaryKeyCallBacks, |
+ &kCFTypeDictionaryValueCallBacks)); |
+ AddIntegerValue(uv_plane, kIOSurfacePlaneWidth, size.width() / 2); |
+ AddIntegerValue(uv_plane, kIOSurfacePlaneHeight, size.height() / 2); |
+ AddIntegerValue(uv_plane, kIOSurfacePlaneBytesPerElement, 2); |
+ |
+ base::ScopedCFTypeRef<CFMutableArrayRef> planes( |
+ CFArrayCreateMutable(kCFAllocatorDefault, 2, &kCFTypeArrayCallBacks)); |
+ CFArrayAppendValue(planes, y_plane); |
+ CFArrayAppendValue(planes, uv_plane); |
+ CFDictionaryAddValue(properties, kIOSurfacePlaneInfo, planes); |
reveman
2015/08/10 22:40:55
Could we refactor this code to set kIOSurfacePlane
Andre
2015/08/11 03:50:46
Done.
|
+ } else { |
+ AddIntegerValue( |
+ properties, kIOSurfaceBytesPerElement, BytesPerPixel(format)); |
+ } |
+ |
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceCreate(properties)); |
if (!io_surface) |
return gfx::GpuMemoryBufferHandle(); |