| 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 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2702 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); | 2702 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); |
| 2703 | 2703 |
| 2704 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 2704 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
| 2705 } | 2705 } |
| 2706 | 2706 |
| 2707 void GLRenderer::Finish() { | 2707 void GLRenderer::Finish() { |
| 2708 TRACE_EVENT0("cc", "GLRenderer::Finish"); | 2708 TRACE_EVENT0("cc", "GLRenderer::Finish"); |
| 2709 gl_->Finish(); | 2709 gl_->Finish(); |
| 2710 } | 2710 } |
| 2711 | 2711 |
| 2712 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { | 2712 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { |
| 2713 DCHECK(!is_backbuffer_discarded_); | 2713 DCHECK(!is_backbuffer_discarded_); |
| 2714 | 2714 |
| 2715 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2715 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
| 2716 // We're done! Time to swapbuffers! | 2716 // We're done! Time to swapbuffers! |
| 2717 | 2717 |
| 2718 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2718 gfx::Size surface_size = output_surface_->SurfaceSize(); |
| 2719 | 2719 |
| 2720 CompositorFrame compositor_frame; | 2720 CompositorFrame compositor_frame; |
| 2721 compositor_frame.metadata = metadata; | 2721 compositor_frame.metadata = std::move(metadata); |
| 2722 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2722 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); |
| 2723 compositor_frame.gl_frame_data->size = surface_size; | 2723 compositor_frame.gl_frame_data->size = surface_size; |
| 2724 if (capabilities_.using_partial_swap) { | 2724 if (capabilities_.using_partial_swap) { |
| 2725 // If supported, we can save significant bandwidth by only swapping the | 2725 // If supported, we can save significant bandwidth by only swapping the |
| 2726 // damaged/scissored region (clamped to the viewport). | 2726 // damaged/scissored region (clamped to the viewport). |
| 2727 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2727 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
| 2728 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2728 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
| 2729 swap_buffer_rect_.y() - | 2729 swap_buffer_rect_.y() - |
| 2730 swap_buffer_rect_.height(); | 2730 swap_buffer_rect_.height(); |
| 2731 compositor_frame.gl_frame_data->sub_buffer_rect = | 2731 compositor_frame.gl_frame_data->sub_buffer_rect = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2745 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); | 2745 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); |
| 2746 pending_overlay_resources_.clear(); | 2746 pending_overlay_resources_.clear(); |
| 2747 | 2747 |
| 2748 // We always hold onto resources until an extra frame has swapped, to make | 2748 // We always hold onto resources until an extra frame has swapped, to make |
| 2749 // sure we don't update the buffer while it's being scanned out. | 2749 // sure we don't update the buffer while it's being scanned out. |
| 2750 if (!settings_->release_overlay_resources_after_gpu_query && | 2750 if (!settings_->release_overlay_resources_after_gpu_query && |
| 2751 swapping_overlay_resources_.size() > 2) { | 2751 swapping_overlay_resources_.size() > 2) { |
| 2752 swapping_overlay_resources_.pop_front(); | 2752 swapping_overlay_resources_.pop_front(); |
| 2753 } | 2753 } |
| 2754 | 2754 |
| 2755 output_surface_->SwapBuffers(&compositor_frame); | 2755 output_surface_->SwapBuffers(std::move(compositor_frame)); |
| 2756 | 2756 |
| 2757 swap_buffer_rect_ = gfx::Rect(); | 2757 swap_buffer_rect_ = gfx::Rect(); |
| 2758 } | 2758 } |
| 2759 | 2759 |
| 2760 void GLRenderer::SwapBuffersComplete() { | 2760 void GLRenderer::SwapBuffersComplete() { |
| 2761 // Once a resouce has been swap-ACKed, send a query to the GPU process to ask | 2761 // Once a resouce has been swap-ACKed, send a query to the GPU process to ask |
| 2762 // if the resource is no longer being consumed by the system compositor. The | 2762 // if the resource is no longer being consumed by the system compositor. The |
| 2763 // response will come with the next swap-ACK. | 2763 // response will come with the next swap-ACK. |
| 2764 if (settings_->release_overlay_resources_after_gpu_query) { | 2764 if (settings_->release_overlay_resources_after_gpu_query) { |
| 2765 if (!swapping_overlay_resources_.empty()) { | 2765 if (!swapping_overlay_resources_.empty()) { |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3679 texture_id = pending_overlay_resources_.back()->texture_id(); | 3679 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3680 } | 3680 } |
| 3681 | 3681 |
| 3682 context_support_->ScheduleOverlayPlane( | 3682 context_support_->ScheduleOverlayPlane( |
| 3683 overlay.plane_z_order, overlay.transform, texture_id, | 3683 overlay.plane_z_order, overlay.transform, texture_id, |
| 3684 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3684 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3685 } | 3685 } |
| 3686 } | 3686 } |
| 3687 | 3687 |
| 3688 } // namespace cc | 3688 } // namespace cc |
| OLD | NEW |