OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/raster/one_copy_tile_task_worker_pool.h" | 5 #include "cc/raster/one_copy_tile_task_worker_pool.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 staging_buffer->query_id); | 318 staging_buffer->query_id); |
319 #endif | 319 #endif |
320 } | 320 } |
321 | 321 |
322 // Since compressed texture's cannot be pre-allocated we might have an | 322 // Since compressed texture's cannot be pre-allocated we might have an |
323 // unallocated resource in which case we need to perform a full size copy. | 323 // unallocated resource in which case we need to perform a full size copy. |
324 if (IsResourceFormatCompressed(resource->format())) { | 324 if (IsResourceFormatCompressed(resource->format())) { |
325 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, | 325 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, |
326 resource_lock->texture_id()); | 326 resource_lock->texture_id()); |
327 } else { | 327 } else { |
328 int bytes_per_row = | 328 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( |
danakj
2016/04/13 18:38:59
If it can overflow/underflow then you want to use
reveman
2016/04/17 20:22:59
I don't think we want unnecessary conditionals to
danakj
2016/04/18 19:47:53
ok sg thanks, just wanted to be sure. LGTM then
| |
329 (BitsPerPixel(resource->format()) * resource->size().width()) / 8; | 329 resource->size().width(), resource->format()); |
330 int chunk_size_in_rows = | 330 int chunk_size_in_rows = |
331 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); | 331 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); |
332 // Align chunk size to 4. Required to support compressed texture formats. | 332 // Align chunk size to 4. Required to support compressed texture formats. |
333 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); | 333 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); |
334 int y = 0; | 334 int y = 0; |
335 int height = resource->size().height(); | 335 int height = resource->size().height(); |
336 while (y < height) { | 336 while (y < height) { |
337 // Copy at most |chunk_size_in_rows|. | 337 // Copy at most |chunk_size_in_rows|. |
338 int rows_to_copy = std::min(chunk_size_in_rows, height - y); | 338 int rows_to_copy = std::min(chunk_size_in_rows, height - y); |
339 DCHECK_GT(rows_to_copy, 0); | 339 DCHECK_GT(rows_to_copy, 0); |
(...skipping 29 matching lines...) Expand all Loading... | |
369 gl->OrderingBarrierCHROMIUM(); | 369 gl->OrderingBarrierCHROMIUM(); |
370 | 370 |
371 // Generate sync token after the barrier for cross context synchronization. | 371 // Generate sync token after the barrier for cross context synchronization. |
372 gpu::SyncToken sync_token; | 372 gpu::SyncToken sync_token; |
373 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 373 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
374 resource_lock->UpdateResourceSyncToken(sync_token); | 374 resource_lock->UpdateResourceSyncToken(sync_token); |
375 } | 375 } |
376 } | 376 } |
377 | 377 |
378 } // namespace cc | 378 } // namespace cc |
OLD | NEW |