| 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::BGRX_8888: | 48 case BufferFormat::BGRX_8888: |
| 49 case BufferFormat::YUV_420: | 49 case BufferFormat::YUV_420: |
| 50 case BufferFormat::YUV_420_BIPLANAR: |
| 50 case BufferFormat::UYVY_422: | 51 case BufferFormat::UYVY_422: |
| 51 return false; | 52 return false; |
| 52 } | 53 } |
| 53 | 54 |
| 54 NOTREACHED(); | 55 NOTREACHED(); |
| 55 return false; | 56 return false; |
| 56 } | 57 } |
| 57 | 58 |
| 58 bool IsCompressedFormat(BufferFormat format) { | 59 bool IsCompressedFormat(BufferFormat format) { |
| 59 switch (format) { | 60 switch (format) { |
| 60 case BufferFormat::ATC: | 61 case BufferFormat::ATC: |
| 61 case BufferFormat::ATCIA: | 62 case BufferFormat::ATCIA: |
| 62 case BufferFormat::DXT1: | 63 case BufferFormat::DXT1: |
| 63 case BufferFormat::DXT5: | 64 case BufferFormat::DXT5: |
| 64 case BufferFormat::ETC1: | 65 case BufferFormat::ETC1: |
| 65 return true; | 66 return true; |
| 66 case BufferFormat::R_8: | 67 case BufferFormat::R_8: |
| 67 case BufferFormat::RGBA_4444: | 68 case BufferFormat::RGBA_4444: |
| 68 case BufferFormat::RGBA_8888: | 69 case BufferFormat::RGBA_8888: |
| 69 case BufferFormat::BGRA_8888: | 70 case BufferFormat::BGRA_8888: |
| 70 case BufferFormat::BGRX_8888: | 71 case BufferFormat::BGRX_8888: |
| 71 case BufferFormat::YUV_420: | 72 case BufferFormat::YUV_420: |
| 73 case BufferFormat::YUV_420_BIPLANAR: |
| 72 case BufferFormat::UYVY_422: | 74 case BufferFormat::UYVY_422: |
| 73 return false; | 75 return false; |
| 74 } | 76 } |
| 75 | 77 |
| 76 NOTREACHED(); | 78 NOTREACHED(); |
| 77 return false; | 79 return false; |
| 78 } | 80 } |
| 79 | 81 |
| 80 GLenum TextureFormat(BufferFormat format) { | 82 GLenum TextureFormat(BufferFormat format) { |
| 81 switch (format) { | 83 switch (format) { |
| 82 case BufferFormat::ATC: | 84 case BufferFormat::ATC: |
| 83 return GL_ATC_RGB_AMD; | 85 return GL_ATC_RGB_AMD; |
| 84 case BufferFormat::ATCIA: | 86 case BufferFormat::ATCIA: |
| 85 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD; | 87 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD; |
| 86 case BufferFormat::DXT1: | 88 case BufferFormat::DXT1: |
| 87 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; | 89 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; |
| 88 case BufferFormat::DXT5: | 90 case BufferFormat::DXT5: |
| 89 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; | 91 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; |
| 90 case BufferFormat::ETC1: | 92 case BufferFormat::ETC1: |
| 91 return GL_ETC1_RGB8_OES; | 93 return GL_ETC1_RGB8_OES; |
| 92 case BufferFormat::R_8: | 94 case BufferFormat::R_8: |
| 93 return GL_RED; | 95 return GL_RED; |
| 94 case BufferFormat::RGBA_4444: | 96 case BufferFormat::RGBA_4444: |
| 95 case BufferFormat::RGBA_8888: | 97 case BufferFormat::RGBA_8888: |
| 96 return GL_RGBA; | 98 return GL_RGBA; |
| 97 case BufferFormat::BGRA_8888: | 99 case BufferFormat::BGRA_8888: |
| 98 return GL_BGRA_EXT; | 100 return GL_BGRA_EXT; |
| 99 case BufferFormat::BGRX_8888: | 101 case BufferFormat::BGRX_8888: |
| 100 case BufferFormat::YUV_420: | 102 case BufferFormat::YUV_420: |
| 103 case BufferFormat::YUV_420_BIPLANAR: |
| 101 case BufferFormat::UYVY_422: | 104 case BufferFormat::UYVY_422: |
| 102 NOTREACHED(); | 105 NOTREACHED(); |
| 103 return 0; | 106 return 0; |
| 104 } | 107 } |
| 105 | 108 |
| 106 NOTREACHED(); | 109 NOTREACHED(); |
| 107 return 0; | 110 return 0; |
| 108 } | 111 } |
| 109 | 112 |
| 110 GLenum DataFormat(BufferFormat format) { | 113 GLenum DataFormat(BufferFormat format) { |
| 111 return TextureFormat(format); | 114 return TextureFormat(format); |
| 112 } | 115 } |
| 113 | 116 |
| 114 GLenum DataType(BufferFormat format) { | 117 GLenum DataType(BufferFormat format) { |
| 115 switch (format) { | 118 switch (format) { |
| 116 case BufferFormat::RGBA_4444: | 119 case BufferFormat::RGBA_4444: |
| 117 return GL_UNSIGNED_SHORT_4_4_4_4; | 120 return GL_UNSIGNED_SHORT_4_4_4_4; |
| 118 case BufferFormat::RGBA_8888: | 121 case BufferFormat::RGBA_8888: |
| 119 case BufferFormat::BGRA_8888: | 122 case BufferFormat::BGRA_8888: |
| 120 case BufferFormat::R_8: | 123 case BufferFormat::R_8: |
| 121 return GL_UNSIGNED_BYTE; | 124 return GL_UNSIGNED_BYTE; |
| 122 case BufferFormat::ATC: | 125 case BufferFormat::ATC: |
| 123 case BufferFormat::ATCIA: | 126 case BufferFormat::ATCIA: |
| 124 case BufferFormat::DXT1: | 127 case BufferFormat::DXT1: |
| 125 case BufferFormat::DXT5: | 128 case BufferFormat::DXT5: |
| 126 case BufferFormat::ETC1: | 129 case BufferFormat::ETC1: |
| 127 case BufferFormat::BGRX_8888: | 130 case BufferFormat::BGRX_8888: |
| 128 case BufferFormat::YUV_420: | 131 case BufferFormat::YUV_420: |
| 132 case BufferFormat::YUV_420_BIPLANAR: |
| 129 case BufferFormat::UYVY_422: | 133 case BufferFormat::UYVY_422: |
| 130 NOTREACHED(); | 134 NOTREACHED(); |
| 131 return 0; | 135 return 0; |
| 132 } | 136 } |
| 133 | 137 |
| 134 NOTREACHED(); | 138 NOTREACHED(); |
| 135 return 0; | 139 return 0; |
| 136 } | 140 } |
| 137 | 141 |
| 138 GLsizei SizeInBytes(const Size& size, BufferFormat format) { | 142 GLsizei SizeInBytes(const Size& size, BufferFormat format) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return true; | 204 return true; |
| 201 case BufferFormat::RGBA_8888: | 205 case BufferFormat::RGBA_8888: |
| 202 case BufferFormat::BGRA_8888: | 206 case BufferFormat::BGRA_8888: |
| 203 checked_stride *= 4; | 207 checked_stride *= 4; |
| 204 if (!checked_stride.IsValid()) | 208 if (!checked_stride.IsValid()) |
| 205 return false; | 209 return false; |
| 206 *stride_in_bytes = checked_stride.ValueOrDie(); | 210 *stride_in_bytes = checked_stride.ValueOrDie(); |
| 207 return true; | 211 return true; |
| 208 case BufferFormat::BGRX_8888: | 212 case BufferFormat::BGRX_8888: |
| 209 case BufferFormat::YUV_420: | 213 case BufferFormat::YUV_420: |
| 214 case BufferFormat::YUV_420_BIPLANAR: |
| 210 case BufferFormat::UYVY_422: | 215 case BufferFormat::UYVY_422: |
| 211 NOTREACHED(); | 216 NOTREACHED(); |
| 212 return false; | 217 return false; |
| 213 } | 218 } |
| 214 | 219 |
| 215 NOTREACHED(); | 220 NOTREACHED(); |
| 216 return false; | 221 return false; |
| 217 } | 222 } |
| 218 | 223 |
| 219 bool GLImageMemory::Initialize(const unsigned char* memory, | 224 bool GLImageMemory::Initialize(const unsigned char* memory, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 size_t size_in_bytes = memory_ ? SizeInBytes(size_, format_) : 0; | 455 size_t size_in_bytes = memory_ ? SizeInBytes(size_, format_) : 0; |
| 451 | 456 |
| 452 base::trace_event::MemoryAllocatorDump* dump = | 457 base::trace_event::MemoryAllocatorDump* dump = |
| 453 pmd->CreateAllocatorDump(dump_name); | 458 pmd->CreateAllocatorDump(dump_name); |
| 454 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 459 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 455 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 460 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 456 static_cast<uint64_t>(size_in_bytes)); | 461 static_cast<uint64_t>(size_in_bytes)); |
| 457 } | 462 } |
| 458 | 463 |
| 459 } // namespace gfx | 464 } // namespace gfx |
| OLD | NEW |