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

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

Issue 2769573002: Return overlay resources to renderers in larger batches. (Closed)
Patch Set: make friend Created 3 years, 8 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
« no previous file with comments | « cc/output/dc_layer_overlay.cc ('k') | cc/quads/draw_quad.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 2660
2661 if (!swapped_and_acked_overlay_resources_.empty()) { 2661 if (!swapped_and_acked_overlay_resources_.empty()) {
2662 std::vector<unsigned> textures; 2662 std::vector<unsigned> textures;
2663 textures.reserve(swapped_and_acked_overlay_resources_.size()); 2663 textures.reserve(swapped_and_acked_overlay_resources_.size());
2664 for (auto& pair : swapped_and_acked_overlay_resources_) { 2664 for (auto& pair : swapped_and_acked_overlay_resources_) {
2665 textures.push_back(pair.first); 2665 textures.push_back(pair.first);
2666 } 2666 }
2667 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data()); 2667 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data());
2668 } 2668 }
2669 } else if (swapping_overlay_resources_.size() > 1) { 2669 } else if (swapping_overlay_resources_.size() > 1) {
2670 ResourceProvider::ScopedBatchReturnResources returner(resource_provider_);
2671
2670 // If a query is not needed to release the overlay buffers, we can assume 2672 // If a query is not needed to release the overlay buffers, we can assume
2671 // that once a swap buffer has completed we can remove the oldest buffers 2673 // that once a swap buffer has completed we can remove the oldest buffers
2672 // from the queue. 2674 // from the queue.
2673 swapping_overlay_resources_.pop_front(); 2675 swapping_overlay_resources_.pop_front();
2674 } 2676 }
2675 } 2677 }
2676 2678
2677 void GLRenderer::DidReceiveTextureInUseResponses( 2679 void GLRenderer::DidReceiveTextureInUseResponses(
2678 const gpu::TextureInUseResponses& responses) { 2680 const gpu::TextureInUseResponses& responses) {
2679 DCHECK(settings_->release_overlay_resources_after_gpu_query); 2681 DCHECK(settings_->release_overlay_resources_after_gpu_query);
2682 ResourceProvider::ScopedBatchReturnResources returner(resource_provider_);
2680 for (const gpu::TextureInUseResponse& response : responses) { 2683 for (const gpu::TextureInUseResponse& response : responses) {
2681 if (!response.in_use) { 2684 if (!response.in_use) {
2682 swapped_and_acked_overlay_resources_.erase(response.texture); 2685 swapped_and_acked_overlay_resources_.erase(response.texture);
2683 } 2686 }
2684 } 2687 }
2685 color_lut_cache_.Swap(); 2688 color_lut_cache_.Swap();
2686 } 2689 }
2687 2690
2688 void GLRenderer::GetFramebufferPixelsAsync( 2691 void GLRenderer::GetFramebufferPixelsAsync(
2689 const gfx::Rect& rect, 2692 const gfx::Rect& rect,
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
3214 if (overlay_resource_pool_) { 3217 if (overlay_resource_pool_) {
3215 overlay_resource_pool_->CheckBusyResources(); 3218 overlay_resource_pool_->CheckBusyResources();
3216 } 3219 }
3217 3220
3218 scoped_refptr<DCLayerOverlaySharedState> shared_state; 3221 scoped_refptr<DCLayerOverlaySharedState> shared_state;
3219 size_t copied_render_pass_count = 0; 3222 size_t copied_render_pass_count = 0;
3220 for (const DCLayerOverlay& dc_layer_overlay : 3223 for (const DCLayerOverlay& dc_layer_overlay :
3221 current_frame()->dc_layer_overlay_list) { 3224 current_frame()->dc_layer_overlay_list) {
3222 DCHECK(!dc_layer_overlay.rpdq); 3225 DCHECK(!dc_layer_overlay.rpdq);
3223 3226
3224 ResourceId contents_resource_id = dc_layer_overlay.contents_resource_id;
3225 unsigned texture_id = 0; 3227 unsigned texture_id = 0;
3226 if (contents_resource_id) { 3228 for (const auto& contents_resource_id : dc_layer_overlay.resources) {
3227 pending_overlay_resources_.push_back( 3229 if (contents_resource_id) {
3228 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( 3230 pending_overlay_resources_.push_back(
3229 resource_provider_, contents_resource_id)); 3231 base::MakeUnique<ResourceProvider::ScopedReadLockGL>(
3230 texture_id = pending_overlay_resources_.back()->texture_id(); 3232 resource_provider_, contents_resource_id));
3233 if (!texture_id)
3234 texture_id = pending_overlay_resources_.back()->texture_id();
3235 }
3231 } 3236 }
3232 GLfloat contents_rect[4] = { 3237 GLfloat contents_rect[4] = {
3233 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), 3238 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(),
3234 dc_layer_overlay.contents_rect.width(), 3239 dc_layer_overlay.contents_rect.width(),
3235 dc_layer_overlay.contents_rect.height(), 3240 dc_layer_overlay.contents_rect.height(),
3236 }; 3241 };
3237 GLfloat bounds_rect[4] = { 3242 GLfloat bounds_rect[4] = {
3238 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), 3243 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(),
3239 dc_layer_overlay.bounds_rect.width(), 3244 dc_layer_overlay.bounds_rect.width(),
3240 dc_layer_overlay.bounds_rect.height(), 3245 dc_layer_overlay.bounds_rect.height(),
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 return; 3594 return;
3590 3595
3591 // Report GPU overdraw as a percentage of |max_result|. 3596 // Report GPU overdraw as a percentage of |max_result|.
3592 TRACE_COUNTER1( 3597 TRACE_COUNTER1(
3593 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3598 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3594 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3599 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3595 max_result); 3600 max_result);
3596 } 3601 }
3597 3602
3598 } // namespace cc 3603 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/dc_layer_overlay.cc ('k') | cc/quads/draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698