| 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/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/gfx/buffer_format_util.h" | 10 #include "ui/gfx/buffer_format_util.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 for (int y = 0; y < size.height(); ++y) { | 218 for (int y = 0; y < size.height(); ++y) { |
| 219 for (int x = 0; x < size.width(); ++x) { | 219 for (int x = 0; x < size.width(); ++x) { |
| 220 data_to_rgb(&data[y * stride + x * 4], | 220 data_to_rgb(&data[y * stride + x * 4], |
| 221 &gles2_rgb_data[y * gles2_rgb_data_stride + x * 3]); | 221 &gles2_rgb_data[y * gles2_rgb_data_stride + x * 3]); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 *data_format = GL_RGB; | 225 *data_format = GL_RGB; |
| 226 *data_type = GL_UNSIGNED_BYTE; | 226 *data_type = GL_UNSIGNED_BYTE; |
| 227 *data_row_length = size.width(); | 227 *data_row_length = size.width(); |
| 228 return gles2_rgb_data.Pass(); | 228 return gles2_rgb_data; |
| 229 } | 229 } |
| 230 | 230 |
| 231 scoped_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, | 231 scoped_ptr<uint8_t[]> GLES2Data(const gfx::Size& size, |
| 232 BufferFormat format, | 232 BufferFormat format, |
| 233 size_t stride, | 233 size_t stride, |
| 234 const uint8_t* data, | 234 const uint8_t* data, |
| 235 GLenum* data_format, | 235 GLenum* data_format, |
| 236 GLenum* data_type, | 236 GLenum* data_type, |
| 237 GLint* data_row_length) { | 237 GLint* data_row_length) { |
| 238 TRACE_EVENT2("gpu", "GLES2Data", "width", size.width(), "height", | 238 TRACE_EVENT2("gpu", "GLES2Data", "width", size.width(), "height", |
| (...skipping 23 matching lines...) Expand all Loading... |
| 262 if (stride == gles2_data_stride) | 262 if (stride == gles2_data_stride) |
| 263 return nullptr; // No data conversion needed | 263 return nullptr; // No data conversion needed |
| 264 | 264 |
| 265 scoped_ptr<uint8_t[]> gles2_data( | 265 scoped_ptr<uint8_t[]> gles2_data( |
| 266 new uint8_t[gles2_data_stride * size.height()]); | 266 new uint8_t[gles2_data_stride * size.height()]); |
| 267 for (int y = 0; y < size.height(); ++y) { | 267 for (int y = 0; y < size.height(); ++y) { |
| 268 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], | 268 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], |
| 269 gles2_data_stride); | 269 gles2_data_stride); |
| 270 } | 270 } |
| 271 *data_row_length = size.width(); | 271 *data_row_length = size.width(); |
| 272 return gles2_data.Pass(); | 272 return gles2_data; |
| 273 } | 273 } |
| 274 case BufferFormat::ATC: | 274 case BufferFormat::ATC: |
| 275 case BufferFormat::ATCIA: | 275 case BufferFormat::ATCIA: |
| 276 case BufferFormat::DXT1: | 276 case BufferFormat::DXT1: |
| 277 case BufferFormat::DXT5: | 277 case BufferFormat::DXT5: |
| 278 case BufferFormat::ETC1: | 278 case BufferFormat::ETC1: |
| 279 return nullptr; // No data conversion needed | 279 return nullptr; // No data conversion needed |
| 280 case BufferFormat::YUV_420: | 280 case BufferFormat::YUV_420: |
| 281 case BufferFormat::YUV_420_BIPLANAR: | 281 case BufferFormat::YUV_420_BIPLANAR: |
| 282 case BufferFormat::UYVY_422: | 282 case BufferFormat::UYVY_422: |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return false; | 441 return false; |
| 442 } | 442 } |
| 443 | 443 |
| 444 // static | 444 // static |
| 445 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) { | 445 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) { |
| 446 DCHECK(ValidFormat(format)); | 446 DCHECK(ValidFormat(format)); |
| 447 return TextureFormat(format); | 447 return TextureFormat(format); |
| 448 } | 448 } |
| 449 | 449 |
| 450 } // namespace gl | 450 } // namespace gl |
| OLD | NEW |