Chromium Code Reviews| Index: cc/raster/one_copy_tile_task_worker_pool.cc |
| diff --git a/cc/raster/one_copy_tile_task_worker_pool.cc b/cc/raster/one_copy_tile_task_worker_pool.cc |
| index b2f8c11309d118863c4e384f951a9ed8eb486899..eb7a94bed1def77533b498639748679446485489 100644 |
| --- a/cc/raster/one_copy_tile_task_worker_pool.cc |
| +++ b/cc/raster/one_copy_tile_task_worker_pool.cc |
| @@ -112,15 +112,18 @@ OneCopyTileTaskWorkerPool::StagingBuffer::~StagingBuffer() { |
| void OneCopyTileTaskWorkerPool::StagingBuffer::DestroyGLResources( |
| gpu::gles2::GLES2Interface* gl) { |
| if (query_id) { |
| - gl->DeleteQueriesEXT(1, &query_id); |
| + if (gl) |
| + gl->DeleteQueriesEXT(1, &query_id); |
|
piman
2015/09/04 22:19:13
Does that mean we may leak resources?
|
| query_id = 0; |
| } |
| if (image_id) { |
| - gl->DestroyImageCHROMIUM(image_id); |
| + if (gl) |
| + gl->DestroyImageCHROMIUM(image_id); |
| image_id = 0; |
| } |
| if (texture_id) { |
| - gl->DeleteTextures(1, &texture_id); |
| + if (gl) |
| + gl->DeleteTextures(1, &texture_id); |
| texture_id = 0; |
| } |
| } |
| @@ -420,53 +423,53 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread( |
| ContextProvider::ScopedContextLock scoped_context(context_provider); |
| gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); |
| - DCHECK(gl); |
| - |
| - unsigned image_target = resource_provider_->GetImageTextureTarget( |
| - resource_provider_->memory_efficient_texture_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); |
| - } |
| + if (gl) { |
| + unsigned image_target = resource_provider_->GetImageTextureTarget( |
| + resource_provider_->memory_efficient_texture_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. |
| - 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_provider_->memory_efficient_texture_format())); |
| + // Create and bind 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_provider_->memory_efficient_texture_format())); |
| + gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| + } |
| + } else { |
| + gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| } |
| - } else { |
| - gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| - gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); |
| - } |
| - // Unbind staging texture. |
| - gl->BindTexture(image_target, 0); |
| + // Unbind staging texture. |
| + gl->BindTexture(image_target, 0); |
| - if (resource_provider_->use_sync_query()) { |
| - if (!staging_buffer->query_id) |
| - gl->GenQueriesEXT(1, &staging_buffer->query_id); |
| + if (resource_provider_->use_sync_query()) { |
| + if (!staging_buffer->query_id) |
| + gl->GenQueriesEXT(1, &staging_buffer->query_id); |
| #if defined(OS_CHROMEOS) |
| - // TODO(reveman): This avoids a performance problem on some ChromeOS |
| - // devices. This needs to be removed to support native GpuMemoryBuffer |
| - // implementations. crbug.com/436314 |
| - gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id); |
| + // TODO(reveman): This avoids a performance problem on some ChromeOS |
| + // devices. This needs to be removed to support native GpuMemoryBuffer |
| + // implementations. crbug.com/436314 |
| + gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, |
| + staging_buffer->query_id); |
| #else |
| - gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| - staging_buffer->query_id); |
| + gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, |
| + staging_buffer->query_id); |
| #endif |
| } |
| @@ -511,6 +514,7 @@ void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread( |
| // Barrier to sync worker context output to cc context. |
| gl->OrderingBarrierCHROMIUM(); |
|
piman
2015/09/04 22:19:13
Missing indents?
|
| + } |
| } |
| staging_buffer->last_usage = base::TimeTicks::Now(); |
| @@ -548,32 +552,32 @@ OneCopyTileTaskWorkerPool::AcquireStagingBuffer(const Resource* resource, |
| ContextProvider::ScopedContextLock scoped_context(context_provider); |
| gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); |
| - DCHECK(gl); |
| - |
| - // Check if any busy buffers have become available. |
| - if (resource_provider_->use_sync_query()) { |
| - while (!busy_buffers_.empty()) { |
| - if (!CheckForQueryResult(gl, busy_buffers_.front()->query_id)) |
| - break; |
| + if (gl) { |
| + // Check if any busy buffers have become available. |
| + if (resource_provider_->use_sync_query()) { |
| + while (!busy_buffers_.empty()) { |
| + if (!CheckForQueryResult(gl, busy_buffers_.front()->query_id)) |
| + break; |
| - free_buffers_.push_back(busy_buffers_.take_front()); |
| + free_buffers_.push_back(busy_buffers_.take_front()); |
| + } |
| } |
| - } |
| - // Wait for number of non-free buffers to become less than the limit. |
| - while ((buffers_.size() - free_buffers_.size()) >= max_staging_buffers_) { |
| - // Stop when there are no more busy buffers to wait for. |
| - if (busy_buffers_.empty()) |
| - break; |
| + // Wait for number of non-free buffers to become less than the limit. |
| + while ((buffers_.size() - free_buffers_.size()) >= max_staging_buffers_) { |
| + // Stop when there are no more busy buffers to wait for. |
| + if (busy_buffers_.empty()) |
| + break; |
| - if (resource_provider_->use_sync_query()) { |
| - WaitForQueryResult(gl, busy_buffers_.front()->query_id); |
| - free_buffers_.push_back(busy_buffers_.take_front()); |
| - } else { |
| - // Fall-back to glFinish if CHROMIUM_sync_query is not available. |
| - gl->Finish(); |
| - while (!busy_buffers_.empty()) |
| + if (resource_provider_->use_sync_query()) { |
| + WaitForQueryResult(gl, busy_buffers_.front()->query_id); |
| free_buffers_.push_back(busy_buffers_.take_front()); |
| + } else { |
| + // Fall-back to glFinish if CHROMIUM_sync_query is not available. |
| + gl->Finish(); |
| + while (!busy_buffers_.empty()) |
| + free_buffers_.push_back(busy_buffers_.take_front()); |
| + } |
| } |
| } |
| @@ -684,7 +688,6 @@ void OneCopyTileTaskWorkerPool::ReleaseBuffersNotUsedSince( |
| ContextProvider::ScopedContextLock scoped_context(context_provider); |
| gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); |
| - DCHECK(gl); |
| // Note: Front buffer is guaranteed to be LRU so we can stop releasing |
| // buffers as soon as we find a buffer that has been used since |time|. |