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

Unified Diff: cc/texture_uploader.cc

Issue 11228044: Revert 163477 - Fix glTexSubImage2D for non-32bpp formats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/texture.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/texture_uploader.cc
===================================================================
--- cc/texture_uploader.cc (revision 163484)
+++ cc/texture_uploader.cc (working copy)
@@ -12,7 +12,6 @@
#include "base/debug/alias.h"
#include "base/debug/trace_event.h"
#include "base/metrics/histogram.h"
-#include "cc/texture.h"
#include "cc/prioritized_texture.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
@@ -213,12 +212,10 @@
source_rect.y() - image_rect.y());
const uint8_t* pixel_source;
- unsigned int bytes_per_pixel = Texture::bytesPerPixel(format);
-
if (image_rect.width() == source_rect.width() && !offset.x()) {
- pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()];
+ pixel_source = &image[4 * offset.y() * image_rect.width()];
} else {
- size_t needed_size = source_rect.width() * source_rect.height() * bytes_per_pixel;
+ size_t needed_size = source_rect.width() * source_rect.height() * 4;
if (m_subImageSize < needed_size) {
m_subImage.reset(new uint8_t[needed_size]);
m_subImageSize = needed_size;
@@ -226,10 +223,10 @@
// Strides not equal, so do a row-by-row memcpy from the
// paint results into a temp buffer for uploading.
for (int row = 0; row < source_rect.height(); ++row)
- memcpy(&m_subImage[source_rect.width() * bytes_per_pixel * row],
- &image[bytes_per_pixel * (offset.x() +
- (offset.y() + row) * image_rect.width())],
- source_rect.width() * bytes_per_pixel);
+ memcpy(&m_subImage[source_rect.width() * 4 * row],
+ &image[4 * (offset.x() +
+ (offset.y() + row) * image_rect.width())],
+ source_rect.width() * 4);
pixel_source = &m_subImage[0];
}
@@ -298,7 +295,20 @@
return;
}
- unsigned int bytes_per_pixel = Texture::bytesPerPixel(format);
+ unsigned int components_per_pixel = 0;
+ switch (format) {
+ case GL_RGBA:
+ case GL_BGRA_EXT:
+ components_per_pixel = 4;
+ break;
+ case GL_LUMINANCE:
+ components_per_pixel = 1;
+ break;
+ default:
+ NOTREACHED();
+ }
+ unsigned int bytes_per_component = 1;
+ unsigned int bytes_per_pixel = components_per_pixel * bytes_per_component;
if (image_rect.width() == source_rect.width() && !offset.x()) {
memcpy(pixel_dest,
@@ -309,8 +319,8 @@
// paint results into the pixelDest
for (int row = 0; row < source_rect.height(); ++row)
memcpy(&pixel_dest[source_rect.width() * row * bytes_per_pixel],
- &image[bytes_per_pixel * (offset.x() +
- (offset.y() + row) * image_rect.width())],
+ &image[4 * (offset.x() +
+ (offset.y() + row) * image_rect.width())],
source_rect.width() * bytes_per_pixel);
}
« no previous file with comments | « cc/texture.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698