| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 5 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_LINUX) | 10 #if defined(OS_LINUX) |
| 11 #include "ui/gfx/client_native_pixmap_factory.h" | 11 #include "ui/gfx/client_native_pixmap_factory.h" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 namespace gpu { | 14 namespace gpu { |
| 15 | 15 |
| 16 gfx::GpuMemoryBufferType GetNativeGpuMemoryBufferType() { | 16 gfx::GpuMemoryBufferType GetNativeGpuMemoryBufferType() { |
| 17 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| 18 return gfx::IO_SURFACE_BUFFER; | 18 return gfx::IO_SURFACE_BUFFER; |
| 19 #endif | 19 #endif |
| 20 #if defined(OS_LINUX) | 20 #if defined(OS_LINUX) |
| 21 return gfx::NATIVE_PIXMAP; | 21 return gfx::NATIVE_PIXMAP; |
| 22 #endif | 22 #endif |
| 23 #if defined(OS_WIN) |
| 24 return gfx::DIRECT_COMPOSITION; |
| 25 #else |
| 23 return gfx::EMPTY_BUFFER; | 26 return gfx::EMPTY_BUFFER; |
| 27 #endif |
| 24 } | 28 } |
| 25 | 29 |
| 26 bool IsNativeGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, | 30 bool IsNativeGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, |
| 27 gfx::BufferUsage usage) { | 31 gfx::BufferUsage usage) { |
| 28 DCHECK_NE(gfx::SHARED_MEMORY_BUFFER, GetNativeGpuMemoryBufferType()); | 32 DCHECK_NE(gfx::SHARED_MEMORY_BUFFER, GetNativeGpuMemoryBufferType()); |
| 29 DCHECK_NE(gfx::EMPTY_BUFFER, GetNativeGpuMemoryBufferType()); | 33 DCHECK_NE(gfx::EMPTY_BUFFER, GetNativeGpuMemoryBufferType()); |
| 30 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 31 switch (usage) { | 35 switch (usage) { |
| 32 case gfx::BufferUsage::GPU_READ: | 36 case gfx::BufferUsage::GPU_READ: |
| 33 case gfx::BufferUsage::SCANOUT: | 37 case gfx::BufferUsage::SCANOUT: |
| 34 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: | 38 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: |
| 35 return format == gfx::BufferFormat::BGRA_8888 || | 39 return format == gfx::BufferFormat::BGRA_8888 || |
| 36 format == gfx::BufferFormat::RGBA_8888 || | 40 format == gfx::BufferFormat::RGBA_8888 || |
| 37 format == gfx::BufferFormat::BGRX_8888; | 41 format == gfx::BufferFormat::BGRX_8888; |
| 38 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: | 42 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
| 39 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: | 43 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
| 40 return format == gfx::BufferFormat::R_8 || | 44 return format == gfx::BufferFormat::R_8 || |
| 41 format == gfx::BufferFormat::BGRA_8888 || | 45 format == gfx::BufferFormat::BGRA_8888 || |
| 42 format == gfx::BufferFormat::RGBA_F16 || | 46 format == gfx::BufferFormat::RGBA_F16 || |
| 43 format == gfx::BufferFormat::UYVY_422 || | 47 format == gfx::BufferFormat::UYVY_422 || |
| 44 format == gfx::BufferFormat::YUV_420_BIPLANAR; | 48 format == gfx::BufferFormat::YUV_420_BIPLANAR; |
| 49 case gfx::BufferUsage::SCANOUT_ASYNC: |
| 50 return false; |
| 45 } | 51 } |
| 46 NOTREACHED(); | 52 NOTREACHED(); |
| 47 return false; | 53 return false; |
| 48 #endif | 54 #endif |
| 49 | 55 |
| 50 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
| 51 if (!gfx::ClientNativePixmapFactory::GetInstance()) { | 57 if (!gfx::ClientNativePixmapFactory::GetInstance()) { |
| 52 // unittests don't have to set ClientNativePixmapFactory. | 58 // unittests don't have to set ClientNativePixmapFactory. |
| 53 return false; | 59 return false; |
| 54 } | 60 } |
| 55 return gfx::ClientNativePixmapFactory::GetInstance() | 61 return gfx::ClientNativePixmapFactory::GetInstance() |
| 56 ->IsConfigurationSupported(format, usage); | 62 ->IsConfigurationSupported(format, usage); |
| 57 #endif | 63 #endif |
| 58 | 64 |
| 59 NOTREACHED(); | 65 #if defined(OS_WIN) |
| 66 switch (usage) { |
| 67 case gfx::BufferUsage::SCANOUT: |
| 68 case gfx::BufferUsage::SCANOUT_ASYNC: |
| 69 return format == gfx::BufferFormat::BGRA_8888 || |
| 70 format == gfx::BufferFormat::RGBA_8888 || |
| 71 format == gfx::BufferFormat::BGRX_8888 || |
| 72 format == gfx::BufferFormat::BGRA_8888; |
| 73 case gfx::BufferUsage::GPU_READ: |
| 74 case gfx::BufferUsage::SCANOUT_CPU_READ_WRITE: |
| 75 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE: |
| 76 case gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT: |
| 77 return false; |
| 78 } |
| 79 #endif |
| 80 |
| 60 return false; | 81 return false; |
| 82 |
| 83 // NOTREACHED(); |
| 84 // return false; |
| 61 } | 85 } |
| 62 | 86 |
| 63 } // namespace gpu | 87 } // namespace gpu |
| OLD | NEW |