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 13 matching lines...) Expand all Loading... |
24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
27 #include "cc/base/container_util.h" | 27 #include "cc/base/container_util.h" |
28 #include "cc/base/math_util.h" | 28 #include "cc/base/math_util.h" |
29 #include "cc/output/compositor_frame.h" | 29 #include "cc/output/compositor_frame.h" |
30 #include "cc/output/compositor_frame_metadata.h" | 30 #include "cc/output/compositor_frame_metadata.h" |
31 #include "cc/output/context_provider.h" | 31 #include "cc/output/context_provider.h" |
32 #include "cc/output/copy_output_request.h" | 32 #include "cc/output/copy_output_request.h" |
33 #include "cc/output/dynamic_geometry_binding.h" | 33 #include "cc/output/dynamic_geometry_binding.h" |
34 #include "cc/output/gl_frame_data.h" | |
35 #include "cc/output/layer_quad.h" | 34 #include "cc/output/layer_quad.h" |
36 #include "cc/output/output_surface.h" | 35 #include "cc/output/output_surface.h" |
| 36 #include "cc/output/output_surface_frame.h" |
37 #include "cc/output/render_surface_filters.h" | 37 #include "cc/output/render_surface_filters.h" |
38 #include "cc/output/renderer_settings.h" | 38 #include "cc/output/renderer_settings.h" |
39 #include "cc/output/static_geometry_binding.h" | 39 #include "cc/output/static_geometry_binding.h" |
40 #include "cc/output/texture_mailbox_deleter.h" | 40 #include "cc/output/texture_mailbox_deleter.h" |
41 #include "cc/quads/draw_polygon.h" | 41 #include "cc/quads/draw_polygon.h" |
42 #include "cc/quads/picture_draw_quad.h" | 42 #include "cc/quads/picture_draw_quad.h" |
43 #include "cc/quads/render_pass.h" | 43 #include "cc/quads/render_pass.h" |
44 #include "cc/quads/stream_video_draw_quad.h" | 44 #include "cc/quads/stream_video_draw_quad.h" |
45 #include "cc/quads/texture_draw_quad.h" | 45 #include "cc/quads/texture_draw_quad.h" |
46 #include "cc/raster/scoped_gpu_raster.h" | 46 #include "cc/raster/scoped_gpu_raster.h" |
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 PrepareGeometry(SHARED_BINDING); | 2877 PrepareGeometry(SHARED_BINDING); |
2878 gfx::Transform quad_rect_matrix; | 2878 gfx::Transform quad_rect_matrix; |
2879 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); | 2879 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); |
2880 static float gl_matrix[16]; | 2880 static float gl_matrix[16]; |
2881 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); | 2881 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); |
2882 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); | 2882 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); |
2883 | 2883 |
2884 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 2884 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
2885 } | 2885 } |
2886 | 2886 |
2887 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { | 2887 void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) { |
2888 DCHECK(visible_); | 2888 DCHECK(visible_); |
2889 | 2889 |
2890 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2890 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
2891 // We're done! Time to swapbuffers! | 2891 // We're done! Time to swapbuffers! |
2892 | 2892 |
2893 CompositorFrame compositor_frame; | 2893 OutputSurfaceFrame output_frame; |
2894 compositor_frame.metadata = std::move(metadata); | 2894 output_frame.latency_info = std::move(latency_info); |
2895 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2895 output_frame.size = surface_size_for_swap_buffers_; |
2896 compositor_frame.gl_frame_data->size = surface_size_for_swap_buffers_; | |
2897 if (use_partial_swap_) { | 2896 if (use_partial_swap_) { |
2898 // If supported, we can save significant bandwidth by only swapping the | 2897 // If supported, we can save significant bandwidth by only swapping the |
2899 // damaged/scissored region (clamped to the viewport). | 2898 // damaged/scissored region (clamped to the viewport). |
2900 swap_buffer_rect_.Intersect(gfx::Rect(surface_size_for_swap_buffers_)); | 2899 swap_buffer_rect_.Intersect(gfx::Rect(surface_size_for_swap_buffers_)); |
2901 int flipped_y_pos_of_rect_bottom = surface_size_for_swap_buffers_.height() - | 2900 int flipped_y_pos_of_rect_bottom = surface_size_for_swap_buffers_.height() - |
2902 swap_buffer_rect_.y() - | 2901 swap_buffer_rect_.y() - |
2903 swap_buffer_rect_.height(); | 2902 swap_buffer_rect_.height(); |
2904 compositor_frame.gl_frame_data->sub_buffer_rect = | 2903 output_frame.sub_buffer_rect = |
2905 gfx::Rect(swap_buffer_rect_.x(), | 2904 gfx::Rect(swap_buffer_rect_.x(), |
2906 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2905 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
2907 : swap_buffer_rect_.y(), | 2906 : swap_buffer_rect_.y(), |
2908 swap_buffer_rect_.width(), swap_buffer_rect_.height()); | 2907 swap_buffer_rect_.width(), swap_buffer_rect_.height()); |
2909 } else { | 2908 } else { |
2910 // Expand the swap rect to the full surface unless it's empty, and empty | 2909 // Expand the swap rect to the full surface unless it's empty, and empty |
2911 // swap is allowed. | 2910 // swap is allowed. |
2912 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { | 2911 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { |
2913 swap_buffer_rect_ = gfx::Rect(surface_size_for_swap_buffers_); | 2912 swap_buffer_rect_ = gfx::Rect(surface_size_for_swap_buffers_); |
2914 } | 2913 } |
2915 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; | 2914 output_frame.sub_buffer_rect = swap_buffer_rect_; |
2916 } | 2915 } |
2917 | 2916 |
2918 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); | 2917 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); |
2919 pending_overlay_resources_.clear(); | 2918 pending_overlay_resources_.clear(); |
2920 | 2919 |
2921 output_surface_->SwapBuffers(std::move(compositor_frame)); | 2920 output_surface_->SwapBuffers(std::move(output_frame)); |
2922 | 2921 |
2923 swap_buffer_rect_ = gfx::Rect(); | 2922 swap_buffer_rect_ = gfx::Rect(); |
2924 } | 2923 } |
2925 | 2924 |
2926 void GLRenderer::SwapBuffersComplete() { | 2925 void GLRenderer::SwapBuffersComplete() { |
2927 if (settings_->release_overlay_resources_after_gpu_query) { | 2926 if (settings_->release_overlay_resources_after_gpu_query) { |
2928 // Once a resource has been swap-ACKed, send a query to the GPU process to | 2927 // Once a resource has been swap-ACKed, send a query to the GPU process to |
2929 // ask if the resource is no longer being consumed by the system compositor. | 2928 // ask if the resource is no longer being consumed by the system compositor. |
2930 // The response will come with the next swap-ACK. | 2929 // The response will come with the next swap-ACK. |
2931 if (!swapping_overlay_resources_.empty()) { | 2930 if (!swapping_overlay_resources_.empty()) { |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4033 | 4032 |
4034 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4033 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4035 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4034 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4036 sorting_context_id, gl_transform); | 4035 sorting_context_id, gl_transform); |
4037 gl_->ScheduleCALayerCHROMIUM( | 4036 gl_->ScheduleCALayerCHROMIUM( |
4038 texture_id, contents_rect, ca_layer_overlay->background_color, | 4037 texture_id, contents_rect, ca_layer_overlay->background_color, |
4039 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4038 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4040 } | 4039 } |
4041 | 4040 |
4042 } // namespace cc | 4041 } // namespace cc |
OLD | NEW |