Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2769573002: Return overlay resources to renderers in larger batches. (Closed)
Patch Set: add ScopedBatchReturnResources Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 2653
2654 if (!swapped_and_acked_overlay_resources_.empty()) { 2654 if (!swapped_and_acked_overlay_resources_.empty()) {
2655 std::vector<unsigned> textures; 2655 std::vector<unsigned> textures;
2656 textures.reserve(swapped_and_acked_overlay_resources_.size()); 2656 textures.reserve(swapped_and_acked_overlay_resources_.size());
2657 for (auto& pair : swapped_and_acked_overlay_resources_) { 2657 for (auto& pair : swapped_and_acked_overlay_resources_) {
2658 textures.push_back(pair.first); 2658 textures.push_back(pair.first);
2659 } 2659 }
2660 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data()); 2660 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data());
2661 } 2661 }
2662 } else if (swapping_overlay_resources_.size() > 1) { 2662 } else if (swapping_overlay_resources_.size() > 1) {
2663 ResourceProvider::ScopedBatchReturnResources returner(resource_provider_);
2664
2663 // If a query is not needed to release the overlay buffers, we can assume 2665 // If a query is not needed to release the overlay buffers, we can assume
2664 // that once a swap buffer has completed we can remove the oldest buffers 2666 // that once a swap buffer has completed we can remove the oldest buffers
2665 // from the queue. 2667 // from the queue.
2666 swapping_overlay_resources_.pop_front(); 2668 swapping_overlay_resources_.pop_front();
2667 } 2669 }
2668 } 2670 }
2669 2671
2670 void GLRenderer::DidReceiveTextureInUseResponses( 2672 void GLRenderer::DidReceiveTextureInUseResponses(
2671 const gpu::TextureInUseResponses& responses) { 2673 const gpu::TextureInUseResponses& responses) {
2672 DCHECK(settings_->release_overlay_resources_after_gpu_query); 2674 DCHECK(settings_->release_overlay_resources_after_gpu_query);
2675 ResourceProvider::ScopedBatchReturnResources returner(resource_provider_);
2673 for (const gpu::TextureInUseResponse& response : responses) { 2676 for (const gpu::TextureInUseResponse& response : responses) {
2674 if (!response.in_use) { 2677 if (!response.in_use) {
2675 swapped_and_acked_overlay_resources_.erase(response.texture); 2678 swapped_and_acked_overlay_resources_.erase(response.texture);
2676 } 2679 }
2677 } 2680 }
2678 color_lut_cache_.Swap(); 2681 color_lut_cache_.Swap();
2679 } 2682 }
2680 2683
2681 void GLRenderer::GetFramebufferPixelsAsync( 2684 void GLRenderer::GetFramebufferPixelsAsync(
2682 const gfx::Rect& rect, 2685 const gfx::Rect& rect,
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 if (overlay_resource_pool_) { 3210 if (overlay_resource_pool_) {
3208 overlay_resource_pool_->CheckBusyResources(); 3211 overlay_resource_pool_->CheckBusyResources();
3209 } 3212 }
3210 3213
3211 scoped_refptr<DCLayerOverlaySharedState> shared_state; 3214 scoped_refptr<DCLayerOverlaySharedState> shared_state;
3212 size_t copied_render_pass_count = 0; 3215 size_t copied_render_pass_count = 0;
3213 for (const DCLayerOverlay& dc_layer_overlay : 3216 for (const DCLayerOverlay& dc_layer_overlay :
3214 current_frame()->dc_layer_overlay_list) { 3217 current_frame()->dc_layer_overlay_list) {
3215 DCHECK(!dc_layer_overlay.rpdq); 3218 DCHECK(!dc_layer_overlay.rpdq);
3216 3219
3217 ResourceId contents_resource_id = dc_layer_overlay.contents_resource_id;
3218 unsigned texture_id = 0; 3220 unsigned texture_id = 0;
3219 if (contents_resource_id) { 3221 for (const auto& contents_resource_id : dc_layer_overlay.resources) {
3220 pending_overlay_resources_.push_back( 3222 if (contents_resource_id) {
3221 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( 3223 pending_overlay_resources_.push_back(
3222 resource_provider_, contents_resource_id)); 3224 base::MakeUnique<ResourceProvider::ScopedReadLockGL>(
3223 texture_id = pending_overlay_resources_.back()->texture_id(); 3225 resource_provider_, contents_resource_id));
3226 if (!texture_id)
3227 texture_id = pending_overlay_resources_.back()->texture_id();
3228 }
3224 } 3229 }
3225 GLfloat contents_rect[4] = { 3230 GLfloat contents_rect[4] = {
3226 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), 3231 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(),
3227 dc_layer_overlay.contents_rect.width(), 3232 dc_layer_overlay.contents_rect.width(),
3228 dc_layer_overlay.contents_rect.height(), 3233 dc_layer_overlay.contents_rect.height(),
3229 }; 3234 };
3230 GLfloat bounds_rect[4] = { 3235 GLfloat bounds_rect[4] = {
3231 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), 3236 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(),
3232 dc_layer_overlay.bounds_rect.width(), 3237 dc_layer_overlay.bounds_rect.width(),
3233 dc_layer_overlay.bounds_rect.height(), 3238 dc_layer_overlay.bounds_rect.height(),
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 return; 3587 return;
3583 3588
3584 // Report GPU overdraw as a percentage of |max_result|. 3589 // Report GPU overdraw as a percentage of |max_result|.
3585 TRACE_COUNTER1( 3590 TRACE_COUNTER1(
3586 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3591 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3587 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3592 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3588 max_result); 3593 max_result);
3589 } 3594 }
3590 3595
3591 } // namespace cc 3596 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698