| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); | 311 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Unbind staging texture. | 314 // Unbind staging texture. |
| 315 gl->BindTexture(image_target, 0); | 315 gl->BindTexture(image_target, 0); |
| 316 | 316 |
| 317 if (resource_provider_->use_sync_query()) { | 317 if (resource_provider_->use_sync_query()) { |
| 318 if (!staging_buffer->query_id) | 318 if (!staging_buffer->query_id) |
| 319 gl->GenQueriesEXT(1, &staging_buffer->query_id); | 319 gl->GenQueriesEXT(1, &staging_buffer->query_id); |
| 320 | 320 |
| 321 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | |
| 322 // TODO(reveman): This avoids a performance problem on ARM ChromeOS | |
| 323 // devices. crbug.com/580166 | |
| 324 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id); | |
| 325 #else | |
| 326 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id); | 321 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id); |
| 327 #endif | |
| 328 } | 322 } |
| 329 | 323 |
| 330 // Since compressed texture's cannot be pre-allocated we might have an | 324 // Since compressed texture's cannot be pre-allocated we might have an |
| 331 // unallocated resource in which case we need to perform a full size copy. | 325 // unallocated resource in which case we need to perform a full size copy. |
| 332 if (IsResourceFormatCompressed(resource_lock->format())) { | 326 if (IsResourceFormatCompressed(resource_lock->format())) { |
| 333 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, | 327 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, |
| 334 resource_texture_id); | 328 resource_texture_id); |
| 335 } else { | 329 } else { |
| 336 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( | 330 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( |
| 337 resource_lock->size().width(), resource_lock->format()); | 331 resource_lock->size().width(), resource_lock->format()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 355 // used for this copy operation. | 349 // used for this copy operation. |
| 356 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; | 350 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; |
| 357 | 351 |
| 358 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { | 352 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) { |
| 359 gl->ShallowFlushCHROMIUM(); | 353 gl->ShallowFlushCHROMIUM(); |
| 360 bytes_scheduled_since_last_flush_ = 0; | 354 bytes_scheduled_since_last_flush_ = 0; |
| 361 } | 355 } |
| 362 } | 356 } |
| 363 } | 357 } |
| 364 | 358 |
| 365 if (resource_provider_->use_sync_query()) { | 359 if (resource_provider_->use_sync_query()) |
| 366 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | |
| 367 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | |
| 368 #else | |
| 369 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 360 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 370 #endif | |
| 371 } | |
| 372 | 361 |
| 373 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 362 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 374 | 363 |
| 375 // Barrier to sync worker context output to cc context. | 364 // Barrier to sync worker context output to cc context. |
| 376 gl->OrderingBarrierCHROMIUM(); | 365 gl->OrderingBarrierCHROMIUM(); |
| 377 | 366 |
| 378 // Generate sync token after the barrier for cross context synchronization. | 367 // Generate sync token after the barrier for cross context synchronization. |
| 379 gpu::SyncToken resource_sync_token; | 368 gpu::SyncToken resource_sync_token; |
| 380 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 369 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 381 resource_lock->set_sync_token(resource_sync_token); | 370 resource_lock->set_sync_token(resource_sync_token); |
| 382 resource_lock->set_synchronized(!async_worker_context_enabled_); | 371 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 383 } | 372 } |
| 384 | 373 |
| 385 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { | 374 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { |
| 386 return use_partial_raster_ | 375 return use_partial_raster_ |
| 387 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | 376 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT |
| 388 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | 377 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; |
| 389 } | 378 } |
| 390 | 379 |
| 391 } // namespace cc | 380 } // namespace cc |
| OLD | NEW |