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

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

Issue 2166973002: cc: Release pending overlay resources on swap-ack. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Fix tests. Created 4 years, 5 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 | « no previous file | cc/output/overlay_unittest.cc » ('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 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after
2758 swapping_overlay_resources_.size() > 2) { 2758 swapping_overlay_resources_.size() > 2) {
2759 swapping_overlay_resources_.pop_front(); 2759 swapping_overlay_resources_.pop_front();
2760 } 2760 }
2761 2761
2762 output_surface_->SwapBuffers(std::move(compositor_frame)); 2762 output_surface_->SwapBuffers(std::move(compositor_frame));
2763 2763
2764 swap_buffer_rect_ = gfx::Rect(); 2764 swap_buffer_rect_ = gfx::Rect();
2765 } 2765 }
2766 2766
2767 void GLRenderer::SwapBuffersComplete() { 2767 void GLRenderer::SwapBuffersComplete() {
2768 // Once a resouce has been swap-ACKed, send a query to the GPU process to ask
2769 // if the resource is no longer being consumed by the system compositor. The
2770 // response will come with the next swap-ACK.
2771 if (settings_->release_overlay_resources_after_gpu_query) { 2768 if (settings_->release_overlay_resources_after_gpu_query) {
2769 // Once a resource has been swap-ACKed, send a query to the GPU process to
2770 // ask if the resource is no longer being consumed by the system compositor.
2771 // The response will come with the next swap-ACK.
2772 if (!swapping_overlay_resources_.empty()) { 2772 if (!swapping_overlay_resources_.empty()) {
2773 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) { 2773 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
2774 unsigned texture = lock->texture_id(); 2774 unsigned texture = lock->texture_id();
2775 if (swapped_and_acked_overlay_resources_.find(texture) == 2775 if (swapped_and_acked_overlay_resources_.find(texture) ==
2776 swapped_and_acked_overlay_resources_.end()) { 2776 swapped_and_acked_overlay_resources_.end()) {
2777 swapped_and_acked_overlay_resources_[texture] = std::move(lock); 2777 swapped_and_acked_overlay_resources_[texture] = std::move(lock);
2778 } 2778 }
2779 } 2779 }
2780 swapping_overlay_resources_.pop_front(); 2780 swapping_overlay_resources_.pop_front();
2781 } 2781 }
2782 2782
2783 if (!swapped_and_acked_overlay_resources_.empty()) { 2783 if (!swapped_and_acked_overlay_resources_.empty()) {
2784 std::vector<unsigned> textures; 2784 std::vector<unsigned> textures;
2785 textures.reserve(swapped_and_acked_overlay_resources_.size()); 2785 textures.reserve(swapped_and_acked_overlay_resources_.size());
2786 for (auto& pair : swapped_and_acked_overlay_resources_) { 2786 for (auto& pair : swapped_and_acked_overlay_resources_) {
2787 textures.push_back(pair.first); 2787 textures.push_back(pair.first);
2788 } 2788 }
2789 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data()); 2789 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data());
2790 } 2790 }
2791 } else if (swapping_overlay_resources_.size() > 1) {
2792 // If a query is not needed to release the overlay buffers, we can
2793 // assume that once a swap buffer is completed only the last set of
2794 // submitted overlay buffers are still in use by GL/Hardware Display.
2795 DCHECK_EQ(2u, swapping_overlay_resources_.size());
2796 swapping_overlay_resources_.pop_front();
2791 } 2797 }
2792 } 2798 }
2793 2799
2794 void GLRenderer::DidReceiveTextureInUseResponses( 2800 void GLRenderer::DidReceiveTextureInUseResponses(
2795 const gpu::TextureInUseResponses& responses) { 2801 const gpu::TextureInUseResponses& responses) {
2796 DCHECK(settings_->release_overlay_resources_after_gpu_query); 2802 DCHECK(settings_->release_overlay_resources_after_gpu_query);
2797 for (const gpu::TextureInUseResponse& response : responses) { 2803 for (const gpu::TextureInUseResponse& response : responses) {
2798 if (!response.in_use) { 2804 if (!response.in_use) {
2799 swapped_and_acked_overlay_resources_.erase(response.texture); 2805 swapped_and_acked_overlay_resources_.erase(response.texture);
2800 } 2806 }
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3690 texture_id = pending_overlay_resources_.back()->texture_id(); 3696 texture_id = pending_overlay_resources_.back()->texture_id();
3691 } 3697 }
3692 3698
3693 context_support_->ScheduleOverlayPlane( 3699 context_support_->ScheduleOverlayPlane(
3694 overlay.plane_z_order, overlay.transform, texture_id, 3700 overlay.plane_z_order, overlay.transform, texture_id,
3695 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3701 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3696 } 3702 }
3697 } 3703 }
3698 3704
3699 } // namespace cc 3705 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698