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

Unified Diff: cc/resources/video_resource_updater.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
« cc/resources/resource_provider.cc ('K') | « cc/resources/resource_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/video_resource_updater.cc
diff --git a/cc/resources/video_resource_updater.cc b/cc/resources/video_resource_updater.cc
index e973a3d5240d057877100f4c7a0fb8e366e7b148..9880db2ca40550f41f37da0f336d94c86ec081b1 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -307,14 +307,16 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
// uploading (including non-frame data to fill in the stride).
size_t video_stride_pixels = video_frame->stride(i);
- size_t bytes_per_pixel = BitsPerPixel(plane_resource.resource_format) / 8;
+ size_t bits_per_pixel = BitsPerPixel(plane_resource.resource_format);
reveman 2015/06/24 18:02:26 Not sure we need to change this. we have an explic
prashant.n 2015/06/25 15:23:04 I think for consistency it is okay.
+ size_t bytes_per_row =
+ (bits_per_pixel * resource_size_pixels.width()) / 8;
// Use 4-byte row alignment (OpenGL default) for upload performance.
// Assuming that GL_UNPACK_ALIGNMENT has not changed from default.
- size_t upload_image_stride = MathUtil::RoundUp<size_t>(
- bytes_per_pixel * resource_size_pixels.width(), 4u);
+ size_t upload_image_stride = MathUtil::RoundUp<size_t>(bytes_per_row, 4u);
const uint8_t* pixels;
- if (upload_image_stride == video_stride_pixels * bytes_per_pixel) {
+ size_t video_bytes_per_row = (video_stride_pixels * bits_per_pixel) / 8;
+ if (upload_image_stride == video_bytes_per_row) {
pixels = video_frame->data(i);
} else {
// Avoid malloc for each frame/plane if possible.
@@ -324,9 +326,9 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
upload_pixels_.resize(needed_size);
for (int row = 0; row < resource_size_pixels.height(); ++row) {
uint8_t* dst = &upload_pixels_[upload_image_stride * row];
- const uint8_t* src = video_frame->data(i) +
- bytes_per_pixel * video_stride_pixels * row;
- memcpy(dst, src, resource_size_pixels.width() * bytes_per_pixel);
+ const uint8_t* src =
+ video_frame->data(i) + (video_bytes_per_row * row);
+ memcpy(dst, src, bytes_per_row);
}
pixels = &upload_pixels_[0];
}
« cc/resources/resource_provider.cc ('K') | « cc/resources/resource_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698