Chromium Code Reviews| Index: cc/raster/one_copy_raster_buffer_provider.cc |
| diff --git a/cc/raster/one_copy_raster_buffer_provider.cc b/cc/raster/one_copy_raster_buffer_provider.cc |
| index fe0e8f2a1fdee7c404e4933bf7260996c3d88987..3266b817fbff8ff8c63cdfcd083c1e3a9c62aa25 100644 |
| --- a/cc/raster/one_copy_raster_buffer_provider.cc |
| +++ b/cc/raster/one_copy_raster_buffer_provider.cc |
| @@ -23,6 +23,7 @@ |
| #include "gpu/command_buffer/client/gles2_interface.h" |
| #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| #include "ui/gfx/buffer_format_util.h" |
| +#include "ui/gfx/gpu_fence.h" |
| namespace cc { |
| namespace { |
| @@ -224,6 +225,12 @@ void OneCopyRasterBufferProvider::PlaybackToStagingBuffer( |
| StagingBufferUsage(), gpu::kNullSurfaceHandle); |
| } |
| + // Allocate GpuFence if necessary. |
| + if (!staging_buffer->gpu_fence) { |
| + staging_buffer->gpu_fence = |
| + resource_provider_->gpu_memory_buffer_manager()->CreateGpuFence(); |
| + } |
| + |
| gfx::Rect playback_rect = raster_full_rect; |
| if (use_partial_raster_ && previous_content_id) { |
| // Reduce playback rect to dirty region if the content id of the staging |
| @@ -282,56 +289,36 @@ void OneCopyRasterBufferProvider::CopyOnWorkerThread( |
| gl, resource_lock, async_worker_context_enabled_); |
| unsigned resource_texture_id = scoped_texture.texture_id(); |
| - unsigned image_target = resource_provider_->GetImageTextureTarget( |
| - StagingBufferUsage(), staging_buffer->format); |
| - |
| - // Create and bind staging texture. |
| - if (!staging_buffer->texture_id) { |
| - gl->GenTextures(1, &staging_buffer->texture_id); |
| - gl->BindTexture(image_target, staging_buffer->texture_id); |
| - gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| - gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| - gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| - gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| - } else { |
| - gl->BindTexture(image_target, staging_buffer->texture_id); |
| - } |
| - // Create and bind image. |
| + // Create image. |
| if (!staging_buffer->image_id) { |
| if (staging_buffer->gpu_memory_buffer) { |
| staging_buffer->image_id = gl->CreateImageCHROMIUM( |
| staging_buffer->gpu_memory_buffer->AsClientBuffer(), |
| staging_buffer->size.width(), staging_buffer->size.height(), |
| GLInternalFormat(resource_lock->format())); |
| - gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id, 0); |
| } |
| - } else { |
| - gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| - gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id, 0); |
| } |
| - // Unbind staging texture. |
| - gl->BindTexture(image_target, 0); |
| + // GpuFence must be reset. |
| + DCHECK(!staging_buffer->gpu_fence || |
| + !staging_buffer->gpu_fence->IsSignaled()); |
| - if (resource_provider_->use_sync_query()) { |
| - if (!staging_buffer->query_id) |
| - gl->GenQueriesEXT(1, &staging_buffer->query_id); |
| - |
| -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| - // TODO(reveman): This avoids a performance problem on ARM ChromeOS |
| - // devices. crbug.com/580166 |
| - gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id); |
| -#else |
| - gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id); |
| -#endif |
| + // Create fence. |
| + if (!staging_buffer->fence_id) { |
| + if (staging_buffer->gpu_fence) { |
| + staging_buffer->fence_id = |
| + gl->CreateFenceCHROMIUM(staging_buffer->gpu_fence->AsClientFence()); |
| + } |
| } |
| // Since compressed texture's cannot be pre-allocated we might have an |
| // unallocated resource in which case we need to perform a full size copy. |
| if (IsResourceFormatCompressed(resource_lock->format())) { |
| - gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, |
| - resource_texture_id); |
| + gl->CopyImageSubDataCHROMIUM(staging_buffer->image_id, resource_texture_id, |
|
ericrk
2017/01/10 03:50:31
Internally (if I traced through the code correctly
reveman
2017/01/10 19:37:55
We might need to add some special code for this on
|
| + 0, 0, 0, 0, resource_lock->size().width(), |
| + resource_lock->size().height(), 0, |
| + staging_buffer->fence_id); |
| } else { |
| int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( |
| resource_lock->size().width(), resource_lock->format()); |
| @@ -346,9 +333,11 @@ void OneCopyRasterBufferProvider::CopyOnWorkerThread( |
| int rows_to_copy = std::min(chunk_size_in_rows, height - y); |
| DCHECK_GT(rows_to_copy, 0); |
| - gl->CopySubTextureCHROMIUM( |
| - staging_buffer->texture_id, resource_texture_id, 0, y, 0, y, |
| - resource_lock->size().width(), rows_to_copy, false, false, false); |
| + gl->CopyImageSubDataCHROMIUM(staging_buffer->image_id, |
| + resource_texture_id, 0, y, 0, y, |
| + resource_lock->size().width(), rows_to_copy, |
| + 0, staging_buffer->fence_id); |
| + |
| y += rows_to_copy; |
| // Increment |bytes_scheduled_since_last_flush_| by the amount of memory |
| @@ -362,14 +351,6 @@ void OneCopyRasterBufferProvider::CopyOnWorkerThread( |
| } |
| } |
| - if (resource_provider_->use_sync_query()) { |
| -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| - gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| -#else |
| - gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| -#endif |
| - } |
| - |
| const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| // Barrier to sync worker context output to cc context. |