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

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

Issue 2061993003: Pass responsibility for IOSurface-texture reuse to the gpu process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp85_query_in_use
Patch Set: Compile errors. Created 4 years, 6 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 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 swap_buffer_rect_ = gfx::Rect(surface_size); 2694 swap_buffer_rect_ = gfx::Rect(surface_size);
2695 } 2695 }
2696 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; 2696 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_;
2697 } 2697 }
2698 2698
2699 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); 2699 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_));
2700 pending_overlay_resources_.clear(); 2700 pending_overlay_resources_.clear();
2701 2701
2702 // We always hold onto resources until an extra frame has swapped, to make 2702 // We always hold onto resources until an extra frame has swapped, to make
2703 // sure we don't update the buffer while it's being scanned out. 2703 // sure we don't update the buffer while it's being scanned out.
2704 if (!settings_->release_overlay_resources_on_swap_complete && 2704 if (!settings_->release_overlay_resources_after_gpu_query &&
2705 swapping_overlay_resources_.size() > 2) { 2705 swapping_overlay_resources_.size() > 2) {
2706 swapping_overlay_resources_.pop_front(); 2706 swapping_overlay_resources_.pop_front();
2707 } 2707 }
2708 2708
2709 output_surface_->SwapBuffers(&compositor_frame); 2709 output_surface_->SwapBuffers(&compositor_frame);
2710 2710
2711 swap_buffer_rect_ = gfx::Rect(); 2711 swap_buffer_rect_ = gfx::Rect();
2712 } 2712 }
2713 2713
2714 void GLRenderer::SwapBuffersComplete() { 2714 void GLRenderer::SwapBuffersComplete() {
2715 // On OS X, the logic in this block moves resources into 2715 // Once a resouce has been swap-ACKed, send a query to the GPU process to ask
2716 // |swapped_and_acked_overlay_resources_|, and then erases resources from 2716 // if the resource is no longer being consumed by the system compositor. The
2717 // |swapped_and_acked_overlay_resources_| that are no longer in use by the 2717 // response will come with the next swap-ACK.
2718 // Window Server. On other platforms, since resources are never in use by the 2718 if (settings_->release_overlay_resources_after_gpu_query) {
2719 // Window Server, this is equivalent to just erasing all resources from the
2720 // first element of |swapping_overlay_resources_|.
2721 if (settings_->release_overlay_resources_on_swap_complete) {
2722 // Move resources known to be acked into
2723 // |swapped_and_acked_overlay_resources_|.
2724 if (!swapping_overlay_resources_.empty()) { 2719 if (!swapping_overlay_resources_.empty()) {
2725 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) { 2720 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
2726 swapped_and_acked_overlay_resources_[lock->GetResourceId()] = 2721 unsigned texture = lock->GetTextureId();
2727 std::move(lock); 2722 if (swapped_and_acked_overlay_resources_.find(texture) ==
2723 swapped_and_acked_overlay_resources_.end()) {
2724 swapped_and_acked_overlay_resources_[texture] = std::move(lock);
2725 }
2728 } 2726 }
2729 swapping_overlay_resources_.pop_front(); 2727 swapping_overlay_resources_.pop_front();
2730 } 2728 }
2731 2729
2732 // Release resources that are no longer in use by the Window Server. 2730 if (!swapped_and_acked_overlay_resources_.empty()) {
2733 auto it = swapped_and_acked_overlay_resources_.begin(); 2731 std::vector<unsigned> textures;
2734 while (it != swapped_and_acked_overlay_resources_.end()) { 2732 textures.reserve(swapped_and_acked_overlay_resources_.size());
2735 if (it->second->GetGpuMemoryBuffer() && 2733 for (auto& pair : swapped_and_acked_overlay_resources_) {
2736 it->second->GetGpuMemoryBuffer()->IsInUseByMacOSWindowServer()) { 2734 textures.push_back(pair.first);
2737 ++it;
2738 continue;
2739 } 2735 }
2740 2736 gl_->ScheduleCALayerInUseQueryCHROMIUM(textures.size(), textures.data());
2741 it = swapped_and_acked_overlay_resources_.erase(it);
2742 } 2737 }
2743 } 2738 }
2744 } 2739 }
2740
2741 void GLRenderer::DidReceiveTextureInUseResponses(
2742 const gpu::TextureInUseResponses& responses) {
2743 DCHECK(settings_->release_overlay_resources_after_gpu_query);
2744 for (const gpu::TextureInUseResponse& response : responses) {
2745 if (!response.in_use) {
2746 auto it = swapped_and_acked_overlay_resources_.find(response.texture);
dcheng 2016/06/15 08:47:21 Out of curiosity, why isn't this just a call to er
erikchen 2016/06/20 16:16:31 Mistake, fixed.
2747 if (it != swapped_and_acked_overlay_resources_.end())
2748 swapped_and_acked_overlay_resources_.erase(it);
2749 }
2750 }
2751 }
2745 2752
2746 void GLRenderer::EnforceMemoryPolicy() { 2753 void GLRenderer::EnforceMemoryPolicy() {
2747 if (!visible()) { 2754 if (!visible()) {
2748 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); 2755 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
2749 ReleaseRenderPassTextures(); 2756 ReleaseRenderPassTextures();
2750 DiscardBackbuffer(); 2757 DiscardBackbuffer();
2751 output_surface_->context_provider()->DeleteCachedResources(); 2758 output_surface_->context_provider()->DeleteCachedResources();
2752 gl_->Flush(); 2759 gl_->Flush();
2753 } 2760 }
2754 PrepareGeometry(NO_BINDING); 2761 PrepareGeometry(NO_BINDING);
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 texture_id = pending_overlay_resources_.back()->GetTextureId(); 3651 texture_id = pending_overlay_resources_.back()->GetTextureId();
3645 } 3652 }
3646 3653
3647 context_support_->ScheduleOverlayPlane( 3654 context_support_->ScheduleOverlayPlane(
3648 overlay.plane_z_order, overlay.transform, texture_id, 3655 overlay.plane_z_order, overlay.transform, texture_id,
3649 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3656 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3650 } 3657 }
3651 } 3658 }
3652 3659
3653 } // namespace cc 3660 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698