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> |
11 #include <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/feature_list.h" | 17 #include "base/feature_list.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
21 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
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" | |
30 #include "cc/output/compositor_frame_metadata.h" | |
31 #include "cc/output/context_provider.h" | 29 #include "cc/output/context_provider.h" |
32 #include "cc/output/copy_output_request.h" | 30 #include "cc/output/copy_output_request.h" |
33 #include "cc/output/dynamic_geometry_binding.h" | 31 #include "cc/output/dynamic_geometry_binding.h" |
34 #include "cc/output/gl_frame_data.h" | |
35 #include "cc/output/layer_quad.h" | 32 #include "cc/output/layer_quad.h" |
36 #include "cc/output/output_surface.h" | 33 #include "cc/output/output_surface.h" |
| 34 #include "cc/output/output_surface_frame.h" |
37 #include "cc/output/render_surface_filters.h" | 35 #include "cc/output/render_surface_filters.h" |
38 #include "cc/output/renderer_settings.h" | 36 #include "cc/output/renderer_settings.h" |
39 #include "cc/output/static_geometry_binding.h" | 37 #include "cc/output/static_geometry_binding.h" |
40 #include "cc/output/texture_mailbox_deleter.h" | 38 #include "cc/output/texture_mailbox_deleter.h" |
41 #include "cc/quads/draw_polygon.h" | 39 #include "cc/quads/draw_polygon.h" |
42 #include "cc/quads/picture_draw_quad.h" | 40 #include "cc/quads/picture_draw_quad.h" |
43 #include "cc/quads/render_pass.h" | 41 #include "cc/quads/render_pass.h" |
44 #include "cc/quads/stream_video_draw_quad.h" | 42 #include "cc/quads/stream_video_draw_quad.h" |
45 #include "cc/quads/texture_draw_quad.h" | 43 #include "cc/quads/texture_draw_quad.h" |
46 #include "cc/raster/scoped_gpu_raster.h" | 44 #include "cc/raster/scoped_gpu_raster.h" |
(...skipping 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 PrepareGeometry(SHARED_BINDING); | 2875 PrepareGeometry(SHARED_BINDING); |
2878 gfx::Transform quad_rect_matrix; | 2876 gfx::Transform quad_rect_matrix; |
2879 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); | 2877 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); |
2880 static float gl_matrix[16]; | 2878 static float gl_matrix[16]; |
2881 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); | 2879 ToGLMatrix(&gl_matrix[0], projection_matrix * quad_rect_matrix); |
2882 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); | 2880 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]); |
2883 | 2881 |
2884 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); | 2882 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); |
2885 } | 2883 } |
2886 | 2884 |
2887 void GLRenderer::SwapBuffers(CompositorFrameMetadata metadata) { | 2885 void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) { |
2888 DCHECK(visible_); | 2886 DCHECK(visible_); |
2889 | 2887 |
2890 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2888 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
2891 // We're done! Time to swapbuffers! | 2889 // We're done! Time to swapbuffers! |
2892 | 2890 |
2893 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2891 gfx::Size surface_size = output_surface_->SurfaceSize(); |
2894 | 2892 |
2895 CompositorFrame compositor_frame; | 2893 OutputSurfaceFrame output_frame; |
2896 compositor_frame.metadata = std::move(metadata); | 2894 output_frame.latency_info = std::move(latency_info); |
2897 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2895 output_frame.size = surface_size; |
2898 compositor_frame.gl_frame_data->size = surface_size; | |
2899 if (use_partial_swap_) { | 2896 if (use_partial_swap_) { |
2900 // If supported, we can save significant bandwidth by only swapping the | 2897 // If supported, we can save significant bandwidth by only swapping the |
2901 // damaged/scissored region (clamped to the viewport). | 2898 // damaged/scissored region (clamped to the viewport). |
2902 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2899 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
2903 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2900 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
2904 swap_buffer_rect_.y() - | 2901 swap_buffer_rect_.y() - |
2905 swap_buffer_rect_.height(); | 2902 swap_buffer_rect_.height(); |
2906 compositor_frame.gl_frame_data->sub_buffer_rect = | 2903 output_frame.sub_buffer_rect = |
2907 gfx::Rect(swap_buffer_rect_.x(), | 2904 gfx::Rect(swap_buffer_rect_.x(), |
2908 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2905 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
2909 : swap_buffer_rect_.y(), | 2906 : swap_buffer_rect_.y(), |
2910 swap_buffer_rect_.width(), swap_buffer_rect_.height()); | 2907 swap_buffer_rect_.width(), swap_buffer_rect_.height()); |
2911 } else { | 2908 } else { |
2912 // 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 |
2913 // swap is allowed. | 2910 // swap is allowed. |
2914 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { | 2911 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { |
2915 swap_buffer_rect_ = gfx::Rect(surface_size); | 2912 swap_buffer_rect_ = gfx::Rect(surface_size); |
2916 } | 2913 } |
2917 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; | 2914 output_frame.sub_buffer_rect = swap_buffer_rect_; |
2918 } | 2915 } |
2919 | 2916 |
2920 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); | 2917 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); |
2921 pending_overlay_resources_.clear(); | 2918 pending_overlay_resources_.clear(); |
2922 | 2919 |
2923 output_surface_->SwapBuffers(std::move(compositor_frame)); | 2920 output_surface_->SwapBuffers(std::move(output_frame)); |
2924 | 2921 |
2925 swap_buffer_rect_ = gfx::Rect(); | 2922 swap_buffer_rect_ = gfx::Rect(); |
2926 } | 2923 } |
2927 | 2924 |
2928 void GLRenderer::SwapBuffersComplete() { | 2925 void GLRenderer::SwapBuffersComplete() { |
2929 if (settings_->release_overlay_resources_after_gpu_query) { | 2926 if (settings_->release_overlay_resources_after_gpu_query) { |
2930 // 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 |
2931 // 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. |
2932 // The response will come with the next swap-ACK. | 2929 // The response will come with the next swap-ACK. |
2933 if (!swapping_overlay_resources_.empty()) { | 2930 if (!swapping_overlay_resources_.empty()) { |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4035 | 4032 |
4036 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4033 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4037 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4034 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4038 sorting_context_id, gl_transform); | 4035 sorting_context_id, gl_transform); |
4039 gl_->ScheduleCALayerCHROMIUM( | 4036 gl_->ScheduleCALayerCHROMIUM( |
4040 texture_id, contents_rect, ca_layer_overlay->background_color, | 4037 texture_id, contents_rect, ca_layer_overlay->background_color, |
4041 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4038 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4042 } | 4039 } |
4043 | 4040 |
4044 } // namespace cc | 4041 } // namespace cc |
OLD | NEW |