Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: ui/gl/gl_image_memory.cc

Issue 2014223002: Follow-up fixes to changing namespace gfx to gl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_io_surface.mm ('k') | ui/gl/gl_image_ozone_native_pixmap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 dst[2] = src[0]; 298 dst[2] = src[0];
299 }, 299 },
300 data_format, data_type, data_row_length); 300 data_format, data_type, data_row_length);
301 case gfx::BufferFormat::RGBA_4444: 301 case gfx::BufferFormat::RGBA_4444:
302 case gfx::BufferFormat::RGBA_8888: 302 case gfx::BufferFormat::RGBA_8888:
303 case gfx::BufferFormat::BGRA_8888: 303 case gfx::BufferFormat::BGRA_8888:
304 case gfx::BufferFormat::R_8: { 304 case gfx::BufferFormat::R_8: {
305 size_t gles2_data_stride = 305 size_t gles2_data_stride =
306 RowSizeForBufferFormat(size.width(), format, 0); 306 RowSizeForBufferFormat(size.width(), format, 0);
307 if (stride == gles2_data_stride || 307 if (stride == gles2_data_stride ||
308 gl::g_driver_gl.ext.b_GL_EXT_unpack_subimage) 308 g_driver_gl.ext.b_GL_EXT_unpack_subimage)
309 return nullptr; // No data conversion needed 309 return nullptr; // No data conversion needed
310 310
311 std::unique_ptr<uint8_t[]> gles2_data( 311 std::unique_ptr<uint8_t[]> gles2_data(
312 new uint8_t[gles2_data_stride * size.height()]); 312 new uint8_t[gles2_data_stride * size.height()]);
313 for (int y = 0; y < size.height(); ++y) { 313 for (int y = 0; y < size.height(); ++y) {
314 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride], 314 memcpy(&gles2_data[y * gles2_data_stride], &data[y * stride],
315 gles2_data_stride); 315 gles2_data_stride);
316 } 316 }
317 *data_row_length = size.width(); 317 *data_row_length = size.width();
318 return gles2_data; 318 return gles2_data;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 glCompressedTexImage2D( 403 glCompressedTexImage2D(
404 target, 0, TextureFormat(format_), size_.width(), size_.height(), 0, 404 target, 0, TextureFormat(format_), size_.width(), size_.height(), 0,
405 static_cast<GLsizei>(BufferSizeForBufferFormat(size_, format_)), 405 static_cast<GLsizei>(BufferSizeForBufferFormat(size_, format_)),
406 memory_); 406 memory_);
407 } else { 407 } else {
408 GLenum data_format = DataFormat(format_); 408 GLenum data_format = DataFormat(format_);
409 GLenum data_type = DataType(format_); 409 GLenum data_type = DataType(format_);
410 GLint data_row_length = DataRowLength(stride_, format_); 410 GLint data_row_length = DataRowLength(stride_, format_);
411 std::unique_ptr<uint8_t[]> gles2_data; 411 std::unique_ptr<uint8_t[]> gles2_data;
412 412
413 if (gl::GLContext::GetCurrent()->GetVersionInfo()->is_es) { 413 if (GLContext::GetCurrent()->GetVersionInfo()->is_es) {
414 gles2_data = GLES2Data(size_, format_, stride_, memory_, &data_format, 414 gles2_data = GLES2Data(size_, format_, stride_, memory_, &data_format,
415 &data_type, &data_row_length); 415 &data_type, &data_row_length);
416 } 416 }
417 417
418 if (data_row_length != size_.width()) 418 if (data_row_length != size_.width())
419 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length); 419 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length);
420 420
421 glTexImage2D(target, 0, TextureFormat(format_), size_.width(), 421 glTexImage2D(target, 0, TextureFormat(format_), size_.width(),
422 size_.height(), 0, data_format, data_type, 422 size_.height(), 0, data_format, data_type,
423 gles2_data ? gles2_data.get() : memory_); 423 gles2_data ? gles2_data.get() : memory_);
(...skipping 29 matching lines...) Expand all
453 target, 0, offset.x(), offset.y(), rect.width(), rect.height(), 453 target, 0, offset.x(), offset.y(), rect.width(), rect.height(),
454 DataFormat(format_), 454 DataFormat(format_),
455 static_cast<GLsizei>(BufferSizeForBufferFormat(rect.size(), format_)), 455 static_cast<GLsizei>(BufferSizeForBufferFormat(rect.size(), format_)),
456 data); 456 data);
457 } else { 457 } else {
458 GLenum data_format = DataFormat(format_); 458 GLenum data_format = DataFormat(format_);
459 GLenum data_type = DataType(format_); 459 GLenum data_type = DataType(format_);
460 GLint data_row_length = DataRowLength(stride_, format_); 460 GLint data_row_length = DataRowLength(stride_, format_);
461 std::unique_ptr<uint8_t[]> gles2_data; 461 std::unique_ptr<uint8_t[]> gles2_data;
462 462
463 if (gl::GLContext::GetCurrent()->GetVersionInfo()->is_es) { 463 if (GLContext::GetCurrent()->GetVersionInfo()->is_es) {
464 gles2_data = GLES2Data(rect.size(), format_, stride_, data, &data_format, 464 gles2_data = GLES2Data(rect.size(), format_, stride_, data, &data_format,
465 &data_type, &data_row_length); 465 &data_type, &data_row_length);
466 } 466 }
467 467
468 if (data_row_length != rect.width()) 468 if (data_row_length != rect.width())
469 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length); 469 glPixelStorei(GL_UNPACK_ROW_LENGTH, data_row_length);
470 470
471 glTexSubImage2D(target, 0, offset.x(), offset.y(), rect.width(), 471 glTexSubImage2D(target, 0, offset.x(), offset.y(), rect.width(),
472 rect.height(), data_format, data_type, 472 rect.height(), data_format, data_type,
473 gles2_data ? gles2_data.get() : data); 473 gles2_data ? gles2_data.get() : data);
(...skipping 13 matching lines...) Expand all
487 return false; 487 return false;
488 } 488 }
489 489
490 // static 490 // static
491 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) { 491 unsigned GLImageMemory::GetInternalFormatForTesting(gfx::BufferFormat format) {
492 DCHECK(ValidFormat(format)); 492 DCHECK(ValidFormat(format));
493 return TextureFormat(format); 493 return TextureFormat(format);
494 } 494 }
495 495
496 } // namespace gl 496 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.mm ('k') | ui/gl/gl_image_ozone_native_pixmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698