| 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/command_buffer/common/gpu_memory_buffer_support.h" | 5 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 case gfx::BufferFormat::RG_88: | 77 case gfx::BufferFormat::RG_88: |
| 78 case gfx::BufferFormat::RGBA_8888: | 78 case gfx::BufferFormat::RGBA_8888: |
| 79 case gfx::BufferFormat::YVU_420: | 79 case gfx::BufferFormat::YVU_420: |
| 80 case gfx::BufferFormat::YUV_420_BIPLANAR: | 80 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 81 case gfx::BufferFormat::UYVY_422: | 81 case gfx::BufferFormat::UYVY_422: |
| 82 return format == BufferFormatForInternalFormat(internalformat); | 82 return format == BufferFormatForInternalFormat(internalformat); |
| 83 case gfx::BufferFormat::BGR_565: | 83 case gfx::BufferFormat::BGR_565: |
| 84 case gfx::BufferFormat::RGBX_8888: | 84 case gfx::BufferFormat::RGBX_8888: |
| 85 return internalformat == GL_RGB; | 85 return internalformat == GL_RGB; |
| 86 case gfx::BufferFormat::RGBA_4444: | 86 case gfx::BufferFormat::RGBA_4444: |
| 87 case gfx::BufferFormat::RGBA_F16: |
| 87 return internalformat == GL_RGBA; | 88 return internalformat == GL_RGBA; |
| 88 } | 89 } |
| 89 | 90 |
| 90 NOTREACHED(); | 91 NOTREACHED(); |
| 91 return false; | 92 return false; |
| 92 } | 93 } |
| 93 | 94 |
| 94 bool IsGpuMemoryBufferFormatSupported(gfx::BufferFormat format, | 95 bool IsImageFromGpuMemoryBufferFormatSupported( |
| 95 const gpu::Capabilities& capabilities) { | 96 gfx::BufferFormat format, |
| 97 const gpu::Capabilities& capabilities) { |
| 96 switch (format) { | 98 switch (format) { |
| 97 case gfx::BufferFormat::ATC: | 99 case gfx::BufferFormat::ATC: |
| 98 case gfx::BufferFormat::ATCIA: | 100 case gfx::BufferFormat::ATCIA: |
| 99 return capabilities.texture_format_atc; | 101 return capabilities.texture_format_atc; |
| 100 case gfx::BufferFormat::BGRA_8888: | 102 case gfx::BufferFormat::BGRA_8888: |
| 101 case gfx::BufferFormat::BGRX_8888: | 103 case gfx::BufferFormat::BGRX_8888: |
| 102 return capabilities.texture_format_bgra8888; | 104 return capabilities.texture_format_bgra8888; |
| 103 case gfx::BufferFormat::DXT1: | 105 case gfx::BufferFormat::DXT1: |
| 104 return capabilities.texture_format_dxt1; | 106 return capabilities.texture_format_dxt1; |
| 105 case gfx::BufferFormat::DXT5: | 107 case gfx::BufferFormat::DXT5: |
| 106 return capabilities.texture_format_dxt5; | 108 return capabilities.texture_format_dxt5; |
| 107 case gfx::BufferFormat::ETC1: | 109 case gfx::BufferFormat::ETC1: |
| 108 return capabilities.texture_format_etc1; | 110 return capabilities.texture_format_etc1; |
| 109 case gfx::BufferFormat::R_8: | 111 case gfx::BufferFormat::R_8: |
| 110 case gfx::BufferFormat::RG_88: | 112 case gfx::BufferFormat::RG_88: |
| 111 return capabilities.texture_rg; | 113 return capabilities.texture_rg; |
| 112 case gfx::BufferFormat::UYVY_422: | 114 case gfx::BufferFormat::UYVY_422: |
| 113 return capabilities.image_ycbcr_422; | 115 return capabilities.image_ycbcr_422; |
| 114 case gfx::BufferFormat::BGR_565: | 116 case gfx::BufferFormat::BGR_565: |
| 115 case gfx::BufferFormat::RGBA_4444: | 117 case gfx::BufferFormat::RGBA_4444: |
| 116 case gfx::BufferFormat::RGBA_8888: | 118 case gfx::BufferFormat::RGBA_8888: |
| 117 case gfx::BufferFormat::RGBX_8888: | 119 case gfx::BufferFormat::RGBX_8888: |
| 118 case gfx::BufferFormat::YVU_420: | 120 case gfx::BufferFormat::YVU_420: |
| 119 return true; | 121 return true; |
| 122 case gfx::BufferFormat::RGBA_F16: |
| 123 return capabilities.texture_half_float_linear; |
| 120 case gfx::BufferFormat::YUV_420_BIPLANAR: | 124 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 121 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 125 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 122 // TODO(dcastagna): Determine ycbcr_420v_image on CrOS at runtime | 126 // TODO(dcastagna): Determine ycbcr_420v_image on CrOS at runtime |
| 123 // querying minigbm. crbug.com/646148 | 127 // querying minigbm. crbug.com/646148 |
| 124 return true; | 128 return true; |
| 125 #else | 129 #else |
| 126 return capabilities.image_ycbcr_420v; | 130 return capabilities.image_ycbcr_420v; |
| 127 #endif | 131 #endif |
| 128 } | 132 } |
| 129 | 133 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 143 // by the block size. | 147 // by the block size. |
| 144 return size.width() % 4 == 0 && size.height() % 4 == 0; | 148 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 145 case gfx::BufferFormat::R_8: | 149 case gfx::BufferFormat::R_8: |
| 146 case gfx::BufferFormat::RG_88: | 150 case gfx::BufferFormat::RG_88: |
| 147 case gfx::BufferFormat::BGR_565: | 151 case gfx::BufferFormat::BGR_565: |
| 148 case gfx::BufferFormat::RGBA_4444: | 152 case gfx::BufferFormat::RGBA_4444: |
| 149 case gfx::BufferFormat::RGBA_8888: | 153 case gfx::BufferFormat::RGBA_8888: |
| 150 case gfx::BufferFormat::RGBX_8888: | 154 case gfx::BufferFormat::RGBX_8888: |
| 151 case gfx::BufferFormat::BGRA_8888: | 155 case gfx::BufferFormat::BGRA_8888: |
| 152 case gfx::BufferFormat::BGRX_8888: | 156 case gfx::BufferFormat::BGRX_8888: |
| 157 case gfx::BufferFormat::RGBA_F16: |
| 153 return true; | 158 return true; |
| 154 case gfx::BufferFormat::YVU_420: | 159 case gfx::BufferFormat::YVU_420: |
| 155 case gfx::BufferFormat::YUV_420_BIPLANAR: | 160 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 156 // U and V planes are subsampled by a factor of 2. | 161 // U and V planes are subsampled by a factor of 2. |
| 157 return size.width() % 2 == 0 && size.height() % 2 == 0; | 162 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 158 case gfx::BufferFormat::UYVY_422: | 163 case gfx::BufferFormat::UYVY_422: |
| 159 return size.width() % 2 == 0; | 164 return size.width() % 2 == 0; |
| 160 } | 165 } |
| 161 | 166 |
| 162 NOTREACHED(); | 167 NOTREACHED(); |
| 163 return false; | 168 return false; |
| 164 } | 169 } |
| 165 | 170 |
| 166 } // namespace gpu | 171 } // namespace gpu |
| OLD | NEW |