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

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

Issue 2006153002: Revert of Add logic to ResourceProvider to correctly lock GpuMemoryBuffer Resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/gl_renderer.h ('k') | cc/resources/resource_provider.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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 GLRenderer::~GLRenderer() { 389 GLRenderer::~GLRenderer() {
390 while (!pending_async_read_pixels_.empty()) { 390 while (!pending_async_read_pixels_.empty()) {
391 PendingAsyncReadPixels* pending_read = 391 PendingAsyncReadPixels* pending_read =
392 pending_async_read_pixels_.back().get(); 392 pending_async_read_pixels_.back().get();
393 pending_read->finished_read_pixels_callback.Cancel(); 393 pending_read->finished_read_pixels_callback.Cancel();
394 pending_async_read_pixels_.pop_back(); 394 pending_async_read_pixels_.pop_back();
395 } 395 }
396 396
397 swapped_overlay_resources_.clear();
397 CleanupSharedObjects(); 398 CleanupSharedObjects();
398 } 399 }
399 400
400 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { 401 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const {
401 return capabilities_; 402 return capabilities_;
402 } 403 }
403 404
404 void GLRenderer::DidChangeVisibility() { 405 void GLRenderer::DidChangeVisibility() {
405 EnforceMemoryPolicy(); 406 EnforceMemoryPolicy();
406 407
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 : swap_buffer_rect_.y(), 2710 : swap_buffer_rect_.y(),
2710 swap_buffer_rect_.width(), swap_buffer_rect_.height()); 2711 swap_buffer_rect_.width(), swap_buffer_rect_.height());
2711 } else { 2712 } else {
2712 // Expand the swap rect to the full surface unless it's empty, and empty 2713 // Expand the swap rect to the full surface unless it's empty, and empty
2713 // swap is allowed. 2714 // swap is allowed.
2714 if (!swap_buffer_rect_.IsEmpty() || !capabilities_.allow_empty_swap) { 2715 if (!swap_buffer_rect_.IsEmpty() || !capabilities_.allow_empty_swap) {
2715 swap_buffer_rect_ = gfx::Rect(surface_size); 2716 swap_buffer_rect_ = gfx::Rect(surface_size);
2716 } 2717 }
2717 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; 2718 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_;
2718 } 2719 }
2719 2720 output_surface_->SwapBuffers(&compositor_frame);
2720 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_));
2721 pending_overlay_resources_.clear();
2722 2721
2723 // We always hold onto resources until an extra frame has swapped, to make 2722 // We always hold onto resources until an extra frame has swapped, to make
2724 // sure we don't update the buffer while it's being scanned out. 2723 // sure we don't update the buffer while it's being scanned out.
2724 swapped_overlay_resources_.push_back(std::move(pending_overlay_resources_));
2725 pending_overlay_resources_.clear();
2725 if (!settings_->release_overlay_resources_on_swap_complete && 2726 if (!settings_->release_overlay_resources_on_swap_complete &&
2726 swapping_overlay_resources_.size() > 2) { 2727 swapped_overlay_resources_.size() > 2) {
2727 swapping_overlay_resources_.pop_front(); 2728 swapped_overlay_resources_.pop_front();
2728 } 2729 }
2729
2730 output_surface_->SwapBuffers(&compositor_frame);
2731
2732 swap_buffer_rect_ = gfx::Rect(); 2730 swap_buffer_rect_ = gfx::Rect();
2733 } 2731 }
2734 2732
2735 void GLRenderer::SwapBuffersComplete() { 2733 void GLRenderer::SwapBuffersComplete() {
2736 // On OS X, the logic in this block moves resources into 2734 if (settings_->release_overlay_resources_on_swap_complete &&
2737 // |swapped_and_acked_overlay_resources_|, and then erases resources from 2735 !swapped_overlay_resources_.empty()) {
2738 // |swapped_and_acked_overlay_resources_| that are no longer in use by the 2736 swapped_overlay_resources_.pop_front();
2739 // Window Server. On other platforms, since resources are never in use by the
2740 // Window Server, this is equivalent to just erasing all resources from the
2741 // first element of |swapping_overlay_resources_|.
2742 if (settings_->release_overlay_resources_on_swap_complete) {
2743 // Move resources known to be acked into
2744 // |swapped_and_acked_overlay_resources_|.
2745 if (!swapping_overlay_resources_.empty()) {
2746 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
2747 swapped_and_acked_overlay_resources_[lock->GetResourceId()] =
2748 std::move(lock);
2749 }
2750 swapping_overlay_resources_.pop_front();
2751 }
2752
2753 // Release resources that are no longer in use by the Window Server.
2754 auto it = swapped_and_acked_overlay_resources_.begin();
2755 while (it != swapped_and_acked_overlay_resources_.end()) {
2756 if (it->second->GetGpuMemoryBuffer() &&
2757 it->second->GetGpuMemoryBuffer()->IsInUseByMacOSWindowServer()) {
2758 ++it;
2759 continue;
2760 }
2761
2762 it = swapped_and_acked_overlay_resources_.erase(it);
2763 }
2764 } 2737 }
2765 } 2738 }
2766 2739
2767 void GLRenderer::EnforceMemoryPolicy() { 2740 void GLRenderer::EnforceMemoryPolicy() {
2768 if (!visible()) { 2741 if (!visible()) {
2769 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); 2742 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
2770 ReleaseRenderPassTextures(); 2743 ReleaseRenderPassTextures();
2771 DiscardBackbuffer(); 2744 DiscardBackbuffer();
2772 output_surface_->context_provider()->DeleteCachedResources(); 2745 output_surface_->context_provider()->DeleteCachedResources();
2773 gl_->Flush(); 2746 gl_->Flush();
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 3597
3625 bool GLRenderer::IsContextLost() { 3598 bool GLRenderer::IsContextLost() {
3626 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 3599 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
3627 } 3600 }
3628 3601
3629 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { 3602 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) {
3630 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { 3603 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) {
3631 unsigned texture_id = 0; 3604 unsigned texture_id = 0;
3632 if (ca_layer_overlay.contents_resource_id) { 3605 if (ca_layer_overlay.contents_resource_id) {
3633 pending_overlay_resources_.push_back( 3606 pending_overlay_resources_.push_back(
3634 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer( 3607 base::WrapUnique(new ResourceProvider::ScopedReadLockGL(
3635 resource_provider_, ca_layer_overlay.contents_resource_id))); 3608 resource_provider_, ca_layer_overlay.contents_resource_id)));
3636 texture_id = pending_overlay_resources_.back()->GetTextureId(); 3609 texture_id = pending_overlay_resources_.back()->texture_id();
3637 } 3610 }
3638 GLfloat contents_rect[4] = { 3611 GLfloat contents_rect[4] = {
3639 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), 3612 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(),
3640 ca_layer_overlay.contents_rect.width(), 3613 ca_layer_overlay.contents_rect.width(),
3641 ca_layer_overlay.contents_rect.height(), 3614 ca_layer_overlay.contents_rect.height(),
3642 }; 3615 };
3643 GLfloat bounds_rect[4] = { 3616 GLfloat bounds_rect[4] = {
3644 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), 3617 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(),
3645 ca_layer_overlay.bounds_rect.width(), 3618 ca_layer_overlay.bounds_rect.width(),
3646 ca_layer_overlay.bounds_rect.height(), 3619 ca_layer_overlay.bounds_rect.height(),
(...skipping 20 matching lines...) Expand all
3667 return; 3640 return;
3668 3641
3669 OverlayCandidateList& overlays = frame->overlay_list; 3642 OverlayCandidateList& overlays = frame->overlay_list;
3670 for (const OverlayCandidate& overlay : overlays) { 3643 for (const OverlayCandidate& overlay : overlays) {
3671 unsigned texture_id = 0; 3644 unsigned texture_id = 0;
3672 if (overlay.use_output_surface_for_resource) { 3645 if (overlay.use_output_surface_for_resource) {
3673 texture_id = output_surface_->GetOverlayTextureId(); 3646 texture_id = output_surface_->GetOverlayTextureId();
3674 DCHECK(texture_id || IsContextLost()); 3647 DCHECK(texture_id || IsContextLost());
3675 } else { 3648 } else {
3676 pending_overlay_resources_.push_back( 3649 pending_overlay_resources_.push_back(
3677 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer( 3650 base::WrapUnique(new ResourceProvider::ScopedReadLockGL(
3678 resource_provider_, overlay.resource_id))); 3651 resource_provider_, overlay.resource_id)));
3679 texture_id = pending_overlay_resources_.back()->GetTextureId(); 3652 texture_id = pending_overlay_resources_.back()->texture_id();
3680 } 3653 }
3681 3654
3682 context_support_->ScheduleOverlayPlane( 3655 context_support_->ScheduleOverlayPlane(
3683 overlay.plane_z_order, overlay.transform, texture_id, 3656 overlay.plane_z_order, overlay.transform, texture_id,
3684 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3657 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3685 } 3658 }
3686 } 3659 }
3687 3660
3688 } // namespace cc 3661 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/resources/resource_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698