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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 }, | 307 }, |
308 data_format, data_type, data_row_length); | 308 data_format, data_type, data_row_length); |
309 case gfx::BufferFormat::RGBA_4444: | 309 case gfx::BufferFormat::RGBA_4444: |
310 case gfx::BufferFormat::RGBA_8888: | 310 case gfx::BufferFormat::RGBA_8888: |
311 case gfx::BufferFormat::BGRA_8888: | 311 case gfx::BufferFormat::BGRA_8888: |
312 case gfx::BufferFormat::R_8: | 312 case gfx::BufferFormat::R_8: |
313 case gfx::BufferFormat::RG_88: { | 313 case gfx::BufferFormat::RG_88: { |
314 size_t gles2_data_stride = | 314 size_t gles2_data_stride = |
315 RowSizeForBufferFormat(size.width(), format, 0); | 315 RowSizeForBufferFormat(size.width(), format, 0); |
316 if (stride == gles2_data_stride || | 316 if (stride == gles2_data_stride || |
317 g_driver_gl.ext.b_GL_EXT_unpack_subimage) | 317 g_current_gl_driver->ext.b_GL_EXT_unpack_subimage) |
318 return nullptr; // No data conversion needed | 318 return nullptr; // No data conversion needed |
319 | 319 |
320 std::unique_ptr<uint8_t[]> gles2_data( | 320 std::unique_ptr<uint8_t[]> gles2_data( |
321 new uint8_t[gles2_data_stride * size.height()]); | 321 new uint8_t[gles2_data_stride * size.height()]); |
322 for (int y = 0; y < size.height(); ++y) { | 322 for (int y = 0; y < size.height(); ++y) { |
323 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], | 323 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], |
324 gles2_data_stride); | 324 gles2_data_stride); |
325 } | 325 } |
326 *data_row_length = size.width(); | 326 *data_row_length = size.width(); |
327 return gles2_data; | 327 return gles2_data; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 return false; | 490 return false; |
491 } | 491 } |
492 | 492 |
493 // static | 493 // static |
494 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { | 494 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { |
495 DCHECK(ValidFormat(format)); | 495 DCHECK(ValidFormat(format)); |
496 return TextureFormat(format); | 496 return TextureFormat(format); |
497 } | 497 } |
498 | 498 |
499 } // namespace gl | 499 } // namespace gl |
OLD | NEW |