| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/resources/video_resource_updater.h" | 5 #include "cc/resources/video_resource_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // upload to. | 304 // upload to. |
| 305 gfx::Size resource_size_pixels = plane_resource.resource_size; | 305 gfx::Size resource_size_pixels = plane_resource.resource_size; |
| 306 // The |video_stride_pixels| is the width of the video frame we are | 306 // The |video_stride_pixels| is the width of the video frame we are |
| 307 // uploading (including non-frame data to fill in the stride). | 307 // uploading (including non-frame data to fill in the stride). |
| 308 int video_stride_pixels = video_frame->stride(i); | 308 int video_stride_pixels = video_frame->stride(i); |
| 309 | 309 |
| 310 size_t bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>( | 310 size_t bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>( |
| 311 resource_size_pixels.width(), plane_resource.resource_format); | 311 resource_size_pixels.width(), plane_resource.resource_format); |
| 312 // Use 4-byte row alignment (OpenGL default) for upload performance. | 312 // Use 4-byte row alignment (OpenGL default) for upload performance. |
| 313 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. | 313 // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. |
| 314 size_t upload_image_stride = MathUtil::RoundUp<size_t>(bytes_per_row, 4u); | 314 size_t upload_image_stride = |
| 315 MathUtil::UncheckedRoundUp<size_t>(bytes_per_row, 4u); |
| 315 | 316 |
| 316 const uint8_t* pixels; | 317 const uint8_t* pixels; |
| 317 size_t video_bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>( | 318 size_t video_bytes_per_row = ResourceUtil::UncheckedWidthInBytes<size_t>( |
| 318 video_stride_pixels, plane_resource.resource_format); | 319 video_stride_pixels, plane_resource.resource_format); |
| 319 if (upload_image_stride == video_bytes_per_row) { | 320 if (upload_image_stride == video_bytes_per_row) { |
| 320 pixels = video_frame->data(i); | 321 pixels = video_frame->data(i); |
| 321 } else { | 322 } else { |
| 322 // Avoid malloc for each frame/plane if possible. | 323 // Avoid malloc for each frame/plane if possible. |
| 323 size_t needed_size = | 324 size_t needed_size = |
| 324 upload_image_stride * resource_size_pixels.height(); | 325 upload_image_stride * resource_size_pixels.height(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 resource_it->ref_count = 0; | 461 resource_it->ref_count = 0; |
| 461 updater->DeleteResource(resource_it); | 462 updater->DeleteResource(resource_it); |
| 462 return; | 463 return; |
| 463 } | 464 } |
| 464 | 465 |
| 465 --resource_it->ref_count; | 466 --resource_it->ref_count; |
| 466 DCHECK_GE(resource_it->ref_count, 0); | 467 DCHECK_GE(resource_it->ref_count, 0); |
| 467 } | 468 } |
| 468 | 469 |
| 469 } // namespace cc | 470 } // namespace cc |
| OLD | NEW |