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

Unified Diff: cc/resources/resource_provider.cc

Issue 1202843008: cc: Fix BytesPerPixel issue and refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: row bytes aligned Created 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index f081f6236f87a36410537af4a9c0e570f1191510..2a8220aa2ac56fb88add919d40531ca1ef41299f 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -1524,12 +1524,15 @@ void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId();
gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
resource->gl_pixel_buffer_id);
- unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8;
- gl->BufferData(
- GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
- resource->size.height() *
- MathUtil::RoundUp(bytes_per_pixel * resource->size.width(), 4u),
- NULL, GL_DYNAMIC_DRAW);
+
+ base::CheckedNumeric<int> num_bytes = resource->size.height();
reveman 2015/06/24 18:02:26 why CheckedNumeric?
+ int bytes_per_row_aligned =
reveman 2015/06/24 18:02:26 How about just bytes_per_row and round up to multi
+ (resource->size.width() * BitsPerPixel(resource->format)) / 8;
+ bytes_per_row_aligned = MathUtil::RoundUp(bytes_per_row, 4u);
+ num_bytes *= bytes_per_row_aligned;
+
+ gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
+ num_bytes.ValueOrDie(), NULL, GL_DYNAMIC_DRAW);
gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
}

Powered by Google App Engine
This is Rietveld 408576698