| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gl/gl_image_memory.h" | 5 #include "ui/gl/gl_image_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
| 10 #include "ui/gl/scoped_binders.h" | 10 #include "ui/gl/scoped_binders.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 case BufferFormat::DXT1: | 40 case BufferFormat::DXT1: |
| 41 case BufferFormat::DXT5: | 41 case BufferFormat::DXT5: |
| 42 case BufferFormat::ETC1: | 42 case BufferFormat::ETC1: |
| 43 case BufferFormat::R_8: | 43 case BufferFormat::R_8: |
| 44 case BufferFormat::RGBA_4444: | 44 case BufferFormat::RGBA_4444: |
| 45 case BufferFormat::RGBA_8888: | 45 case BufferFormat::RGBA_8888: |
| 46 case BufferFormat::BGRA_8888: | 46 case BufferFormat::BGRA_8888: |
| 47 return true; | 47 return true; |
| 48 case BufferFormat::RGBX_8888: | 48 case BufferFormat::RGBX_8888: |
| 49 case BufferFormat::YUV_420: | 49 case BufferFormat::YUV_420: |
| 50 case BufferFormat::YUV_420_BIPLANAR: |
| 50 return false; | 51 return false; |
| 51 } | 52 } |
| 52 | 53 |
| 53 NOTREACHED(); | 54 NOTREACHED(); |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 bool IsCompressedFormat(BufferFormat format) { | 58 bool IsCompressedFormat(BufferFormat format) { |
| 58 switch (format) { | 59 switch (format) { |
| 59 case BufferFormat::ATC: | 60 case BufferFormat::ATC: |
| 60 case BufferFormat::ATCIA: | 61 case BufferFormat::ATCIA: |
| 61 case BufferFormat::DXT1: | 62 case BufferFormat::DXT1: |
| 62 case BufferFormat::DXT5: | 63 case BufferFormat::DXT5: |
| 63 case BufferFormat::ETC1: | 64 case BufferFormat::ETC1: |
| 64 case BufferFormat::YUV_420: | 65 case BufferFormat::YUV_420: |
| 66 case BufferFormat::YUV_420_BIPLANAR: |
| 65 return true; | 67 return true; |
| 66 case BufferFormat::R_8: | 68 case BufferFormat::R_8: |
| 67 case BufferFormat::RGBA_4444: | 69 case BufferFormat::RGBA_4444: |
| 68 case BufferFormat::RGBA_8888: | 70 case BufferFormat::RGBA_8888: |
| 69 case BufferFormat::BGRA_8888: | 71 case BufferFormat::BGRA_8888: |
| 70 case BufferFormat::RGBX_8888: | 72 case BufferFormat::RGBX_8888: |
| 71 return false; | 73 return false; |
| 72 } | 74 } |
| 73 | 75 |
| 74 NOTREACHED(); | 76 NOTREACHED(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 89 return GL_ETC1_RGB8_OES; | 91 return GL_ETC1_RGB8_OES; |
| 90 case BufferFormat::R_8: | 92 case BufferFormat::R_8: |
| 91 return GL_RED; | 93 return GL_RED; |
| 92 case BufferFormat::RGBA_4444: | 94 case BufferFormat::RGBA_4444: |
| 93 case BufferFormat::RGBA_8888: | 95 case BufferFormat::RGBA_8888: |
| 94 return GL_RGBA; | 96 return GL_RGBA; |
| 95 case BufferFormat::BGRA_8888: | 97 case BufferFormat::BGRA_8888: |
| 96 return GL_BGRA_EXT; | 98 return GL_BGRA_EXT; |
| 97 case BufferFormat::RGBX_8888: | 99 case BufferFormat::RGBX_8888: |
| 98 case BufferFormat::YUV_420: | 100 case BufferFormat::YUV_420: |
| 101 case BufferFormat::YUV_420_BIPLANAR: |
| 99 NOTREACHED(); | 102 NOTREACHED(); |
| 100 return 0; | 103 return 0; |
| 101 } | 104 } |
| 102 | 105 |
| 103 NOTREACHED(); | 106 NOTREACHED(); |
| 104 return 0; | 107 return 0; |
| 105 } | 108 } |
| 106 | 109 |
| 107 GLenum DataFormat(BufferFormat format) { | 110 GLenum DataFormat(BufferFormat format) { |
| 108 return TextureFormat(format); | 111 return TextureFormat(format); |
| 109 } | 112 } |
| 110 | 113 |
| 111 GLenum DataType(BufferFormat format) { | 114 GLenum DataType(BufferFormat format) { |
| 112 switch (format) { | 115 switch (format) { |
| 113 case BufferFormat::RGBA_4444: | 116 case BufferFormat::RGBA_4444: |
| 114 return GL_UNSIGNED_SHORT_4_4_4_4; | 117 return GL_UNSIGNED_SHORT_4_4_4_4; |
| 115 case BufferFormat::RGBA_8888: | 118 case BufferFormat::RGBA_8888: |
| 116 case BufferFormat::BGRA_8888: | 119 case BufferFormat::BGRA_8888: |
| 117 case BufferFormat::R_8: | 120 case BufferFormat::R_8: |
| 118 return GL_UNSIGNED_BYTE; | 121 return GL_UNSIGNED_BYTE; |
| 119 case BufferFormat::ATC: | 122 case BufferFormat::ATC: |
| 120 case BufferFormat::ATCIA: | 123 case BufferFormat::ATCIA: |
| 121 case BufferFormat::DXT1: | 124 case BufferFormat::DXT1: |
| 122 case BufferFormat::DXT5: | 125 case BufferFormat::DXT5: |
| 123 case BufferFormat::ETC1: | 126 case BufferFormat::ETC1: |
| 124 case BufferFormat::RGBX_8888: | 127 case BufferFormat::RGBX_8888: |
| 125 case BufferFormat::YUV_420: | 128 case BufferFormat::YUV_420: |
| 129 case BufferFormat::YUV_420_BIPLANAR: |
| 126 NOTREACHED(); | 130 NOTREACHED(); |
| 127 return 0; | 131 return 0; |
| 128 } | 132 } |
| 129 | 133 |
| 130 NOTREACHED(); | 134 NOTREACHED(); |
| 131 return 0; | 135 return 0; |
| 132 } | 136 } |
| 133 | 137 |
| 134 GLsizei SizeInBytes(const Size& size, BufferFormat format) { | 138 GLsizei SizeInBytes(const Size& size, BufferFormat format) { |
| 135 size_t stride_in_bytes = 0; | 139 size_t stride_in_bytes = 0; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return true; | 200 return true; |
| 197 case BufferFormat::RGBA_8888: | 201 case BufferFormat::RGBA_8888: |
| 198 case BufferFormat::BGRA_8888: | 202 case BufferFormat::BGRA_8888: |
| 199 checked_stride *= 4; | 203 checked_stride *= 4; |
| 200 if (!checked_stride.IsValid()) | 204 if (!checked_stride.IsValid()) |
| 201 return false; | 205 return false; |
| 202 *stride_in_bytes = checked_stride.ValueOrDie(); | 206 *stride_in_bytes = checked_stride.ValueOrDie(); |
| 203 return true; | 207 return true; |
| 204 case BufferFormat::RGBX_8888: | 208 case BufferFormat::RGBX_8888: |
| 205 case BufferFormat::YUV_420: | 209 case BufferFormat::YUV_420: |
| 210 case BufferFormat::YUV_420_BIPLANAR: |
| 206 NOTREACHED(); | 211 NOTREACHED(); |
| 207 return false; | 212 return false; |
| 208 } | 213 } |
| 209 | 214 |
| 210 NOTREACHED(); | 215 NOTREACHED(); |
| 211 return false; | 216 return false; |
| 212 } | 217 } |
| 213 | 218 |
| 214 bool GLImageMemory::Initialize(const unsigned char* memory, | 219 bool GLImageMemory::Initialize(const unsigned char* memory, |
| 215 BufferFormat format) { | 220 BufferFormat format) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 size_.width(), | 437 size_.width(), |
| 433 size_.height(), | 438 size_.height(), |
| 434 0, // border | 439 0, // border |
| 435 DataFormat(format_), | 440 DataFormat(format_), |
| 436 DataType(format_), | 441 DataType(format_), |
| 437 memory_); | 442 memory_); |
| 438 } | 443 } |
| 439 } | 444 } |
| 440 | 445 |
| 441 } // namespace gfx | 446 } // namespace gfx |
| OLD | NEW |