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

Unified Diff: cc/texture_uploader.cc

Issue 11413005: YUV software decode path stride fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unittest segfault fix.wq Created 8 years, 1 month 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 | « no previous file | cc/video_layer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/texture_uploader.cc
diff --git a/cc/texture_uploader.cc b/cc/texture_uploader.cc
index a1c812a855a9e0a1482f4728bb28a51973ca439a..607697cd3ece1dfd74871282cafe9c1f0b769f3c 100644
--- a/cc/texture_uploader.cc
+++ b/cc/texture_uploader.cc
@@ -229,11 +229,14 @@ void TextureUploader::uploadWithTexSubImage(const uint8* image,
const uint8* pixel_source;
unsigned int bytes_per_pixel = Resource::bytesPerPixel(format);
+ unsigned int upload_image_stride =
jamesr 2012/11/19 04:14:46 why is this change necessary?
+ (bytes_per_pixel * source_rect.width() + 3) & ~0x3;
danakj 2012/11/17 19:25:14 I'm certain this can be written in a way that make
+ m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 4);
- if (image_rect.width() == source_rect.width() && !offset.x()) {
- pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()];
+ if (upload_image_stride == image_rect.width() * bytes_per_pixel && !offset.x()) {
+ pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()];
} else {
- size_t needed_size = source_rect.width() * source_rect.height() * bytes_per_pixel;
+ size_t needed_size = upload_image_stride * source_rect.height();
if (m_subImageSize < needed_size) {
m_subImage.reset(new uint8[needed_size]);
m_subImageSize = needed_size;
@@ -241,7 +244,7 @@ void TextureUploader::uploadWithTexSubImage(const uint8* image,
// 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],
+ memcpy(&m_subImage[upload_image_stride * row],
&image[bytes_per_pixel * (offset.x() +
(offset.y() + row) * image_rect.width())],
source_rect.width() * bytes_per_pixel);
@@ -294,6 +297,11 @@ void TextureUploader::uploadWithMapTexSubImage(const uint8* image,
// Offset from image-rect to source-rect.
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
+ unsigned int bytes_per_pixel = Resource::bytesPerPixel(format);
+ unsigned int upload_image_stride =
+ (bytes_per_pixel * source_rect.width() + 3) & ~0x3;
danakj 2012/11/17 19:25:14 same. helper method?
+ m_context->pixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
// Upload tile data via a mapped transfer buffer
uint8* pixel_dest = static_cast<uint8*>(
m_context->mapTexSubImage2DCHROMIUM(GL_TEXTURE_2D,
@@ -312,17 +320,15 @@ void TextureUploader::uploadWithMapTexSubImage(const uint8* image,
return;
}
- unsigned int bytes_per_pixel = Resource::bytesPerPixel(format);
-
- if (image_rect.width() == source_rect.width() && !offset.x()) {
+ if (upload_image_stride == image_rect.width() * bytes_per_pixel && !offset.x()) {
memcpy(pixel_dest,
- &image[offset.y() * image_rect.width() * bytes_per_pixel],
- image_rect.width() * source_rect.height() * bytes_per_pixel);
+ &image[image_rect.width() * bytes_per_pixel * offset.y()],
+ source_rect.height() * image_rect.width() * bytes_per_pixel);
} else {
// Strides not equal, so do a row-by-row memcpy from the
// paint results into the pixelDest
for (int row = 0; row < source_rect.height(); ++row)
- memcpy(&pixel_dest[source_rect.width() * row * bytes_per_pixel],
+ memcpy(&pixel_dest[upload_image_stride * row],
&image[bytes_per_pixel * (offset.x() +
(offset.y() + row) * image_rect.width())],
source_rect.width() * bytes_per_pixel);
« no previous file with comments | « no previous file | cc/video_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698