| 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 23 matching lines...) Expand all Loading... |
| 34 return gfx::BufferFormat::DXT1; | 34 return gfx::BufferFormat::DXT1; |
| 35 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: | 35 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
| 36 return gfx::BufferFormat::DXT5; | 36 return gfx::BufferFormat::DXT5; |
| 37 case GL_ETC1_RGB8_OES: | 37 case GL_ETC1_RGB8_OES: |
| 38 return gfx::BufferFormat::ETC1; | 38 return gfx::BufferFormat::ETC1; |
| 39 case GL_RGB_YCRCB_420_CHROMIUM: | 39 case GL_RGB_YCRCB_420_CHROMIUM: |
| 40 return gfx::BufferFormat::YVU_420; | 40 return gfx::BufferFormat::YVU_420; |
| 41 case GL_RGB_YCBCR_420V_CHROMIUM: | 41 case GL_RGB_YCBCR_420V_CHROMIUM: |
| 42 return gfx::BufferFormat::YUV_420_BIPLANAR; | 42 return gfx::BufferFormat::YUV_420_BIPLANAR; |
| 43 case GL_RGB_YCBCR_422_CHROMIUM: | 43 case GL_RGB_YCBCR_422_CHROMIUM: |
| 44 #if defined(OS_MACOSX) |
| 45 // Mac supports UYVY IOSurface. |
| 44 return gfx::BufferFormat::UYVY_422; | 46 return gfx::BufferFormat::UYVY_422; |
| 47 #elif defined(OS_CHROMEOS) |
| 48 // Ozone supports YUYV NativePixmap. |
| 49 return gfx::BufferFormat::YUYV_422; |
| 50 #endif |
| 45 default: | 51 default: |
| 46 NOTREACHED(); | 52 NOTREACHED(); |
| 47 return gfx::BufferFormat::RGBA_8888; | 53 return gfx::BufferFormat::RGBA_8888; |
| 48 } | 54 } |
| 49 } | 55 } |
| 50 | 56 |
| 51 } // namespace | 57 } // namespace |
| 52 | 58 |
| 53 bool IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 59 bool IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| 54 unsigned internalformat, | 60 unsigned internalformat, |
| 55 gfx::BufferFormat format) { | 61 gfx::BufferFormat format) { |
| 56 switch (format) { | 62 switch (format) { |
| 57 case gfx::BufferFormat::ATC: | 63 case gfx::BufferFormat::ATC: |
| 58 case gfx::BufferFormat::ATCIA: | 64 case gfx::BufferFormat::ATCIA: |
| 59 case gfx::BufferFormat::BGRA_8888: | 65 case gfx::BufferFormat::BGRA_8888: |
| 60 case gfx::BufferFormat::BGRX_8888: | 66 case gfx::BufferFormat::BGRX_8888: |
| 61 case gfx::BufferFormat::DXT1: | 67 case gfx::BufferFormat::DXT1: |
| 62 case gfx::BufferFormat::DXT5: | 68 case gfx::BufferFormat::DXT5: |
| 63 case gfx::BufferFormat::ETC1: | 69 case gfx::BufferFormat::ETC1: |
| 64 case gfx::BufferFormat::R_8: | 70 case gfx::BufferFormat::R_8: |
| 65 case gfx::BufferFormat::RG_88: | 71 case gfx::BufferFormat::RG_88: |
| 66 case gfx::BufferFormat::RGBA_8888: | 72 case gfx::BufferFormat::RGBA_8888: |
| 67 case gfx::BufferFormat::YVU_420: | 73 case gfx::BufferFormat::YVU_420: |
| 68 case gfx::BufferFormat::YUV_420_BIPLANAR: | 74 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 69 case gfx::BufferFormat::UYVY_422: | 75 case gfx::BufferFormat::UYVY_422: |
| 76 case gfx::BufferFormat::YUYV_422: |
| 70 return format == BufferFormatForInternalFormat(internalformat); | 77 return format == BufferFormatForInternalFormat(internalformat); |
| 71 case gfx::BufferFormat::BGR_565: | 78 case gfx::BufferFormat::BGR_565: |
| 72 case gfx::BufferFormat::RGBX_8888: | 79 case gfx::BufferFormat::RGBX_8888: |
| 73 return internalformat == GL_RGB; | 80 return internalformat == GL_RGB; |
| 74 case gfx::BufferFormat::RGBA_4444: | 81 case gfx::BufferFormat::RGBA_4444: |
| 75 case gfx::BufferFormat::RGBA_F16: | 82 case gfx::BufferFormat::RGBA_F16: |
| 76 return internalformat == GL_RGBA; | 83 return internalformat == GL_RGBA; |
| 77 } | 84 } |
| 78 | 85 |
| 79 NOTREACHED(); | 86 NOTREACHED(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 93 case gfx::BufferFormat::DXT1: | 100 case gfx::BufferFormat::DXT1: |
| 94 return capabilities.texture_format_dxt1; | 101 return capabilities.texture_format_dxt1; |
| 95 case gfx::BufferFormat::DXT5: | 102 case gfx::BufferFormat::DXT5: |
| 96 return capabilities.texture_format_dxt5; | 103 return capabilities.texture_format_dxt5; |
| 97 case gfx::BufferFormat::ETC1: | 104 case gfx::BufferFormat::ETC1: |
| 98 return capabilities.texture_format_etc1; | 105 return capabilities.texture_format_etc1; |
| 99 case gfx::BufferFormat::R_8: | 106 case gfx::BufferFormat::R_8: |
| 100 case gfx::BufferFormat::RG_88: | 107 case gfx::BufferFormat::RG_88: |
| 101 return capabilities.texture_rg; | 108 return capabilities.texture_rg; |
| 102 case gfx::BufferFormat::UYVY_422: | 109 case gfx::BufferFormat::UYVY_422: |
| 110 case gfx::BufferFormat::YUYV_422: |
| 103 return capabilities.image_ycbcr_422; | 111 return capabilities.image_ycbcr_422; |
| 104 case gfx::BufferFormat::BGR_565: | 112 case gfx::BufferFormat::BGR_565: |
| 105 case gfx::BufferFormat::RGBA_4444: | 113 case gfx::BufferFormat::RGBA_4444: |
| 106 case gfx::BufferFormat::RGBA_8888: | 114 case gfx::BufferFormat::RGBA_8888: |
| 107 case gfx::BufferFormat::RGBX_8888: | 115 case gfx::BufferFormat::RGBX_8888: |
| 108 case gfx::BufferFormat::YVU_420: | 116 case gfx::BufferFormat::YVU_420: |
| 109 return true; | 117 return true; |
| 110 case gfx::BufferFormat::RGBA_F16: | 118 case gfx::BufferFormat::RGBA_F16: |
| 111 return capabilities.texture_half_float_linear; | 119 return capabilities.texture_half_float_linear; |
| 112 case gfx::BufferFormat::YUV_420_BIPLANAR: | 120 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 142 case gfx::BufferFormat::RGBX_8888: | 150 case gfx::BufferFormat::RGBX_8888: |
| 143 case gfx::BufferFormat::BGRA_8888: | 151 case gfx::BufferFormat::BGRA_8888: |
| 144 case gfx::BufferFormat::BGRX_8888: | 152 case gfx::BufferFormat::BGRX_8888: |
| 145 case gfx::BufferFormat::RGBA_F16: | 153 case gfx::BufferFormat::RGBA_F16: |
| 146 return true; | 154 return true; |
| 147 case gfx::BufferFormat::YVU_420: | 155 case gfx::BufferFormat::YVU_420: |
| 148 case gfx::BufferFormat::YUV_420_BIPLANAR: | 156 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 149 // U and V planes are subsampled by a factor of 2. | 157 // U and V planes are subsampled by a factor of 2. |
| 150 return size.width() % 2 == 0 && size.height() % 2 == 0; | 158 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 151 case gfx::BufferFormat::UYVY_422: | 159 case gfx::BufferFormat::UYVY_422: |
| 160 case gfx::BufferFormat::YUYV_422: |
| 152 return size.width() % 2 == 0; | 161 return size.width() % 2 == 0; |
| 153 } | 162 } |
| 154 | 163 |
| 155 NOTREACHED(); | 164 NOTREACHED(); |
| 156 return false; | 165 return false; |
| 157 } | 166 } |
| 158 | 167 |
| 159 } // namespace gpu | 168 } // namespace gpu |
| OLD | NEW |