Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 resource_provider_->SetBatchReturnResources(true); | |
|
Daniele Castagna
2017/03/24 01:44:43
Should we have something like ScopedBacthReturnRes
| |
| 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(); |
| 2669 resource_provider_->SetBatchReturnResources(false); | |
| 2667 } | 2670 } |
| 2668 } | 2671 } |
| 2669 | 2672 |
| 2670 void GLRenderer::DidReceiveTextureInUseResponses( | 2673 void GLRenderer::DidReceiveTextureInUseResponses( |
| 2671 const gpu::TextureInUseResponses& responses) { | 2674 const gpu::TextureInUseResponses& responses) { |
| 2672 DCHECK(settings_->release_overlay_resources_after_gpu_query); | 2675 DCHECK(settings_->release_overlay_resources_after_gpu_query); |
| 2676 resource_provider_->SetBatchReturnResources(true); | |
| 2673 for (const gpu::TextureInUseResponse& response : responses) { | 2677 for (const gpu::TextureInUseResponse& response : responses) { |
| 2674 if (!response.in_use) { | 2678 if (!response.in_use) { |
| 2675 swapped_and_acked_overlay_resources_.erase(response.texture); | 2679 swapped_and_acked_overlay_resources_.erase(response.texture); |
| 2676 } | 2680 } |
| 2677 } | 2681 } |
| 2682 resource_provider_->SetBatchReturnResources(false); | |
| 2678 color_lut_cache_.Swap(); | 2683 color_lut_cache_.Swap(); |
| 2679 } | 2684 } |
| 2680 | 2685 |
| 2681 void GLRenderer::GetFramebufferPixelsAsync( | 2686 void GLRenderer::GetFramebufferPixelsAsync( |
| 2682 const gfx::Rect& rect, | 2687 const gfx::Rect& rect, |
| 2683 std::unique_ptr<CopyOutputRequest> request) { | 2688 std::unique_ptr<CopyOutputRequest> request) { |
| 2684 DCHECK(!request->IsEmpty()); | 2689 DCHECK(!request->IsEmpty()); |
| 2685 if (request->IsEmpty()) | 2690 if (request->IsEmpty()) |
| 2686 return; | 2691 return; |
| 2687 if (rect.IsEmpty()) | 2692 if (rect.IsEmpty()) |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3207 if (overlay_resource_pool_) { | 3212 if (overlay_resource_pool_) { |
| 3208 overlay_resource_pool_->CheckBusyResources(); | 3213 overlay_resource_pool_->CheckBusyResources(); |
| 3209 } | 3214 } |
| 3210 | 3215 |
| 3211 scoped_refptr<DCLayerOverlaySharedState> shared_state; | 3216 scoped_refptr<DCLayerOverlaySharedState> shared_state; |
| 3212 size_t copied_render_pass_count = 0; | 3217 size_t copied_render_pass_count = 0; |
| 3213 for (const DCLayerOverlay& dc_layer_overlay : | 3218 for (const DCLayerOverlay& dc_layer_overlay : |
| 3214 current_frame()->dc_layer_overlay_list) { | 3219 current_frame()->dc_layer_overlay_list) { |
| 3215 DCHECK(!dc_layer_overlay.rpdq); | 3220 DCHECK(!dc_layer_overlay.rpdq); |
| 3216 | 3221 |
| 3217 ResourceId contents_resource_id = dc_layer_overlay.contents_resource_id; | |
| 3218 unsigned texture_id = 0; | 3222 unsigned texture_id = 0; |
| 3219 if (contents_resource_id) { | 3223 for (const auto& contents_resource_id : dc_layer_overlay.resources) { |
| 3220 pending_overlay_resources_.push_back( | 3224 if (contents_resource_id) { |
| 3221 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( | 3225 pending_overlay_resources_.push_back( |
| 3222 resource_provider_, contents_resource_id)); | 3226 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( |
| 3223 texture_id = pending_overlay_resources_.back()->texture_id(); | 3227 resource_provider_, contents_resource_id)); |
| 3228 if (!texture_id) | |
| 3229 texture_id = pending_overlay_resources_.back()->texture_id(); | |
| 3230 } | |
| 3224 } | 3231 } |
| 3225 GLfloat contents_rect[4] = { | 3232 GLfloat contents_rect[4] = { |
| 3226 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), | 3233 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), |
| 3227 dc_layer_overlay.contents_rect.width(), | 3234 dc_layer_overlay.contents_rect.width(), |
| 3228 dc_layer_overlay.contents_rect.height(), | 3235 dc_layer_overlay.contents_rect.height(), |
| 3229 }; | 3236 }; |
| 3230 GLfloat bounds_rect[4] = { | 3237 GLfloat bounds_rect[4] = { |
| 3231 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), | 3238 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), |
| 3232 dc_layer_overlay.bounds_rect.width(), | 3239 dc_layer_overlay.bounds_rect.width(), |
| 3233 dc_layer_overlay.bounds_rect.height(), | 3240 dc_layer_overlay.bounds_rect.height(), |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3582 return; | 3589 return; |
| 3583 | 3590 |
| 3584 // Report GPU overdraw as a percentage of |max_result|. | 3591 // Report GPU overdraw as a percentage of |max_result|. |
| 3585 TRACE_COUNTER1( | 3592 TRACE_COUNTER1( |
| 3586 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3593 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
| 3587 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3594 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
| 3588 max_result); | 3595 max_result); |
| 3589 } | 3596 } |
| 3590 | 3597 |
| 3591 } // namespace cc | 3598 } // namespace cc |
| OLD | NEW |