| 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" |
| 11 #include "gpu/command_buffer/common/capabilities.h" | 11 #include "gpu/command_buffer/common/capabilities.h" |
| 12 | 12 |
| 13 namespace gpu { | 13 namespace gpu { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { | 17 gfx::BufferFormat BufferFormatForInternalFormat(unsigned internalformat) { |
| 18 switch (internalformat) { | 18 switch (internalformat) { |
| 19 case GL_RED_EXT: | 19 case GL_RED_EXT: |
| 20 return gfx::BufferFormat::R_8; | 20 return gfx::BufferFormat::R_8; |
| 21 case GL_RG_EXT: |
| 22 return gfx::BufferFormat::RG_88; |
| 21 case GL_RGB: | 23 case GL_RGB: |
| 22 return gfx::BufferFormat::BGRX_8888; | 24 return gfx::BufferFormat::BGRX_8888; |
| 23 case GL_RGBA: | 25 case GL_RGBA: |
| 24 return gfx::BufferFormat::RGBA_8888; | 26 return gfx::BufferFormat::RGBA_8888; |
| 25 case GL_BGRA_EXT: | 27 case GL_BGRA_EXT: |
| 26 return gfx::BufferFormat::BGRA_8888; | 28 return gfx::BufferFormat::BGRA_8888; |
| 27 case GL_ATC_RGB_AMD: | 29 case GL_ATC_RGB_AMD: |
| 28 return gfx::BufferFormat::ATC; | 30 return gfx::BufferFormat::ATC; |
| 29 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 31 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
| 30 return gfx::BufferFormat::ATCIA; | 32 return gfx::BufferFormat::ATCIA; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 gfx::BufferFormat format) { | 67 gfx::BufferFormat format) { |
| 66 switch (format) { | 68 switch (format) { |
| 67 case gfx::BufferFormat::ATC: | 69 case gfx::BufferFormat::ATC: |
| 68 case gfx::BufferFormat::ATCIA: | 70 case gfx::BufferFormat::ATCIA: |
| 69 case gfx::BufferFormat::BGRA_8888: | 71 case gfx::BufferFormat::BGRA_8888: |
| 70 case gfx::BufferFormat::BGRX_8888: | 72 case gfx::BufferFormat::BGRX_8888: |
| 71 case gfx::BufferFormat::DXT1: | 73 case gfx::BufferFormat::DXT1: |
| 72 case gfx::BufferFormat::DXT5: | 74 case gfx::BufferFormat::DXT5: |
| 73 case gfx::BufferFormat::ETC1: | 75 case gfx::BufferFormat::ETC1: |
| 74 case gfx::BufferFormat::R_8: | 76 case gfx::BufferFormat::R_8: |
| 77 case gfx::BufferFormat::RG_88: |
| 75 case gfx::BufferFormat::RGBA_8888: | 78 case gfx::BufferFormat::RGBA_8888: |
| 76 case gfx::BufferFormat::YVU_420: | 79 case gfx::BufferFormat::YVU_420: |
| 77 case gfx::BufferFormat::YUV_420_BIPLANAR: | 80 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 78 case gfx::BufferFormat::UYVY_422: | 81 case gfx::BufferFormat::UYVY_422: |
| 79 return format == BufferFormatForInternalFormat(internalformat); | 82 return format == BufferFormatForInternalFormat(internalformat); |
| 80 case gfx::BufferFormat::BGR_565: | 83 case gfx::BufferFormat::BGR_565: |
| 81 case gfx::BufferFormat::RGBX_8888: | 84 case gfx::BufferFormat::RGBX_8888: |
| 82 return internalformat == GL_RGB; | 85 return internalformat == GL_RGB; |
| 83 case gfx::BufferFormat::RGBA_4444: | 86 case gfx::BufferFormat::RGBA_4444: |
| 84 return internalformat == GL_RGBA; | 87 return internalformat == GL_RGBA; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 97 case gfx::BufferFormat::BGRA_8888: | 100 case gfx::BufferFormat::BGRA_8888: |
| 98 case gfx::BufferFormat::BGRX_8888: | 101 case gfx::BufferFormat::BGRX_8888: |
| 99 return capabilities.texture_format_bgra8888; | 102 return capabilities.texture_format_bgra8888; |
| 100 case gfx::BufferFormat::DXT1: | 103 case gfx::BufferFormat::DXT1: |
| 101 return capabilities.texture_format_dxt1; | 104 return capabilities.texture_format_dxt1; |
| 102 case gfx::BufferFormat::DXT5: | 105 case gfx::BufferFormat::DXT5: |
| 103 return capabilities.texture_format_dxt5; | 106 return capabilities.texture_format_dxt5; |
| 104 case gfx::BufferFormat::ETC1: | 107 case gfx::BufferFormat::ETC1: |
| 105 return capabilities.texture_format_etc1; | 108 return capabilities.texture_format_etc1; |
| 106 case gfx::BufferFormat::R_8: | 109 case gfx::BufferFormat::R_8: |
| 110 case gfx::BufferFormat::RG_88: |
| 107 return capabilities.texture_rg; | 111 return capabilities.texture_rg; |
| 108 case gfx::BufferFormat::UYVY_422: | 112 case gfx::BufferFormat::UYVY_422: |
| 109 return capabilities.image_ycbcr_422; | 113 return capabilities.image_ycbcr_422; |
| 110 case gfx::BufferFormat::BGR_565: | 114 case gfx::BufferFormat::BGR_565: |
| 111 case gfx::BufferFormat::RGBA_4444: | 115 case gfx::BufferFormat::RGBA_4444: |
| 112 case gfx::BufferFormat::RGBA_8888: | 116 case gfx::BufferFormat::RGBA_8888: |
| 113 case gfx::BufferFormat::RGBX_8888: | 117 case gfx::BufferFormat::RGBX_8888: |
| 114 case gfx::BufferFormat::YVU_420: | 118 case gfx::BufferFormat::YVU_420: |
| 115 return true; | 119 return true; |
| 116 case gfx::BufferFormat::YUV_420_BIPLANAR: | 120 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 117 return capabilities.image_ycbcr_420v; | 121 return capabilities.image_ycbcr_420v; |
| 118 } | 122 } |
| 119 | 123 |
| 120 NOTREACHED(); | 124 NOTREACHED(); |
| 121 return false; | 125 return false; |
| 122 } | 126 } |
| 123 | 127 |
| 124 bool IsImageSizeValidForGpuMemoryBufferFormat(const gfx::Size& size, | 128 bool IsImageSizeValidForGpuMemoryBufferFormat(const gfx::Size& size, |
| 125 gfx::BufferFormat format) { | 129 gfx::BufferFormat format) { |
| 126 switch (format) { | 130 switch (format) { |
| 127 case gfx::BufferFormat::ATC: | 131 case gfx::BufferFormat::ATC: |
| 128 case gfx::BufferFormat::ATCIA: | 132 case gfx::BufferFormat::ATCIA: |
| 129 case gfx::BufferFormat::DXT1: | 133 case gfx::BufferFormat::DXT1: |
| 130 case gfx::BufferFormat::DXT5: | 134 case gfx::BufferFormat::DXT5: |
| 131 case gfx::BufferFormat::ETC1: | 135 case gfx::BufferFormat::ETC1: |
| 132 // Compressed images must have a width and height that's evenly divisible | 136 // Compressed images must have a width and height that's evenly divisible |
| 133 // by the block size. | 137 // by the block size. |
| 134 return size.width() % 4 == 0 && size.height() % 4 == 0; | 138 return size.width() % 4 == 0 && size.height() % 4 == 0; |
| 135 case gfx::BufferFormat::R_8: | 139 case gfx::BufferFormat::R_8: |
| 140 case gfx::BufferFormat::RG_88: |
| 136 case gfx::BufferFormat::BGR_565: | 141 case gfx::BufferFormat::BGR_565: |
| 137 case gfx::BufferFormat::RGBA_4444: | 142 case gfx::BufferFormat::RGBA_4444: |
| 138 case gfx::BufferFormat::RGBA_8888: | 143 case gfx::BufferFormat::RGBA_8888: |
| 139 case gfx::BufferFormat::RGBX_8888: | 144 case gfx::BufferFormat::RGBX_8888: |
| 140 case gfx::BufferFormat::BGRA_8888: | 145 case gfx::BufferFormat::BGRA_8888: |
| 141 case gfx::BufferFormat::BGRX_8888: | 146 case gfx::BufferFormat::BGRX_8888: |
| 142 return true; | 147 return true; |
| 143 case gfx::BufferFormat::YVU_420: | 148 case gfx::BufferFormat::YVU_420: |
| 144 case gfx::BufferFormat::YUV_420_BIPLANAR: | 149 case gfx::BufferFormat::YUV_420_BIPLANAR: |
| 145 // U and V planes are subsampled by a factor of 2. | 150 // U and V planes are subsampled by a factor of 2. |
| 146 return size.width() % 2 == 0 && size.height() % 2 == 0; | 151 return size.width() % 2 == 0 && size.height() % 2 == 0; |
| 147 case gfx::BufferFormat::UYVY_422: | 152 case gfx::BufferFormat::UYVY_422: |
| 148 return size.width() % 2 == 0; | 153 return size.width() % 2 == 0; |
| 149 } | 154 } |
| 150 | 155 |
| 151 NOTREACHED(); | 156 NOTREACHED(); |
| 152 return false; | 157 return false; |
| 153 } | 158 } |
| 154 | 159 |
| 155 } // namespace gpu | 160 } // namespace gpu |
| OLD | NEW |