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

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: Fixed Android build break. Created 5 years, 5 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/resources/scoped_resource_unittest.cc ('k') | cc/tiles/tile.cc » ('j') | 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 dd5606e2da4584760f7d76c86df23d3ec7e86f50..88e8360f0b7392b4644a0e4ebb8aef3bec6514db 100644
--- a/cc/resources/video_resource_updater.cc
+++ b/cc/resources/video_resource_updater.cc
@@ -305,16 +305,18 @@ VideoFrameExternalResources VideoResourceUpdater::CreateForSoftwarePlanes(
gfx::Size resource_size_pixels = plane_resource.resource_size;
// The |video_stride_pixels| is the width of the video frame we are
// uploading (including non-frame data to fill in the stride).
- size_t video_stride_pixels = video_frame->stride(i);
+ int video_stride_pixels = video_frame->stride(i);
- size_t bytes_per_pixel = BitsPerPixel(plane_resource.resource_format) / 8;
+ size_t bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>(
+ resource_size_pixels.width(), plane_resource.resource_format);
// 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 = ResourceUtil::UncheckedWidthInBytes<size_t>(
+ video_stride_pixels, plane_resource.resource_format);
+ 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];
}
« no previous file with comments | « cc/resources/scoped_resource_unittest.cc ('k') | cc/tiles/tile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698