| 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_raster_buffer_provider.h" | 5 #include "cc/raster/one_copy_raster_buffer_provider.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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Align chunk size to 4. Required to support compressed texture formats. | 344 // Align chunk size to 4. Required to support compressed texture formats. |
| 345 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); | 345 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); |
| 346 int y = 0; | 346 int y = 0; |
| 347 int height = resource_lock->size().height(); | 347 int height = resource_lock->size().height(); |
| 348 while (y < height) { | 348 while (y < height) { |
| 349 // Copy at most |chunk_size_in_rows|. | 349 // Copy at most |chunk_size_in_rows|. |
| 350 int rows_to_copy = std::min(chunk_size_in_rows, height - y); | 350 int rows_to_copy = std::min(chunk_size_in_rows, height - y); |
| 351 DCHECK_GT(rows_to_copy, 0); | 351 DCHECK_GT(rows_to_copy, 0); |
| 352 | 352 |
| 353 gl->CopySubTextureCHROMIUM( | 353 gl->CopySubTextureCHROMIUM( |
| 354 staging_buffer->texture_id, resource_texture_id, 0, y, 0, y, | 354 staging_buffer->texture_id, 0, resource_texture_id, 0, 0, y, 0, y, |
| 355 resource_lock->size().width(), rows_to_copy, false, false, false); | 355 resource_lock->size().width(), rows_to_copy, false, false, false); |
| 356 y += rows_to_copy; | 356 y += rows_to_copy; |
| 357 | 357 |
| 358 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory | 358 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory |
| 359 // used for this copy operation. | 359 // used for this copy operation. |
| 360 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; | 360 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; |
| 361 | 361 |
| 362 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { | 362 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { |
| 363 gl->ShallowFlushCHROMIUM(); | 363 gl->ShallowFlushCHROMIUM(); |
| 364 bytes_scheduled_since_last_flush_ = 0; | 364 bytes_scheduled_since_last_flush_ = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 386 resource_lock->set_synchronized(!async_worker_context_enabled_); | 386 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 387 } | 387 } |
| 388 | 388 |
| 389 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { | 389 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { |
| 390 return use_partial_raster_ | 390 return use_partial_raster_ |
| 391 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | 391 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT |
| 392 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | 392 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace cc | 395 } // namespace cc |
| OLD | NEW |