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(CompositorFrameMetadata metadata) { |
danakj
2016/10/04 21:58:40
Can you make this method take a vector of latencyi
kylechar
2016/10/05 13:45:53
Done.
| |
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 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2893 gfx::Size surface_size = output_surface_->SurfaceSize(); |
2894 | 2894 |
2895 CompositorFrame compositor_frame; | 2895 OutputSurfaceFrame frame; |
danakj
2016/10/04 21:58:40
nit: name the variable output_frame or something a
kylechar
2016/10/05 13:45:53
Done.
| |
2896 compositor_frame.metadata = std::move(metadata); | 2896 frame.latency_info = std::move(metadata.latency_info); |
2897 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); | 2897 frame.size = surface_size; |
2898 compositor_frame.gl_frame_data->size = surface_size; | |
2899 if (use_partial_swap_) { | 2898 if (use_partial_swap_) { |
2900 // If supported, we can save significant bandwidth by only swapping the | 2899 // If supported, we can save significant bandwidth by only swapping the |
2901 // damaged/scissored region (clamped to the viewport). | 2900 // damaged/scissored region (clamped to the viewport). |
2902 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2901 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
2903 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2902 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
2904 swap_buffer_rect_.y() - | 2903 swap_buffer_rect_.y() - |
2905 swap_buffer_rect_.height(); | 2904 swap_buffer_rect_.height(); |
2906 compositor_frame.gl_frame_data->sub_buffer_rect = | 2905 frame.sub_buffer_rect = |
2907 gfx::Rect(swap_buffer_rect_.x(), | 2906 gfx::Rect(swap_buffer_rect_.x(), |
2908 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom | 2907 FlippedRootFramebuffer() ? flipped_y_pos_of_rect_bottom |
2909 : swap_buffer_rect_.y(), | 2908 : swap_buffer_rect_.y(), |
2910 swap_buffer_rect_.width(), swap_buffer_rect_.height()); | 2909 swap_buffer_rect_.width(), swap_buffer_rect_.height()); |
2911 } else { | 2910 } else { |
2912 // Expand the swap rect to the full surface unless it's empty, and empty | 2911 // Expand the swap rect to the full surface unless it's empty, and empty |
2913 // swap is allowed. | 2912 // swap is allowed. |
2914 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { | 2913 if (!swap_buffer_rect_.IsEmpty() || !allow_empty_swap_) { |
2915 swap_buffer_rect_ = gfx::Rect(surface_size); | 2914 swap_buffer_rect_ = gfx::Rect(surface_size); |
2916 } | 2915 } |
2917 compositor_frame.gl_frame_data->sub_buffer_rect = swap_buffer_rect_; | 2916 frame.sub_buffer_rect = swap_buffer_rect_; |
2918 } | 2917 } |
2919 | 2918 |
2920 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); | 2919 swapping_overlay_resources_.push_back(std::move(pending_overlay_resources_)); |
2921 pending_overlay_resources_.clear(); | 2920 pending_overlay_resources_.clear(); |
2922 | 2921 |
2923 output_surface_->SwapBuffers(std::move(compositor_frame)); | 2922 output_surface_->SwapBuffers(std::move(frame)); |
2924 | 2923 |
2925 swap_buffer_rect_ = gfx::Rect(); | 2924 swap_buffer_rect_ = gfx::Rect(); |
2926 } | 2925 } |
2927 | 2926 |
2928 void GLRenderer::SwapBuffersComplete() { | 2927 void GLRenderer::SwapBuffersComplete() { |
2929 if (settings_->release_overlay_resources_after_gpu_query) { | 2928 if (settings_->release_overlay_resources_after_gpu_query) { |
2930 // Once a resource has been swap-ACKed, send a query to the GPU process to | 2929 // 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. | 2930 // ask if the resource is no longer being consumed by the system compositor. |
2932 // The response will come with the next swap-ACK. | 2931 // The response will come with the next swap-ACK. |
2933 if (!swapping_overlay_resources_.empty()) { | 2932 if (!swapping_overlay_resources_.empty()) { |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4035 | 4034 |
4036 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4035 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4037 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4036 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4038 sorting_context_id, gl_transform); | 4037 sorting_context_id, gl_transform); |
4039 gl_->ScheduleCALayerCHROMIUM( | 4038 gl_->ScheduleCALayerCHROMIUM( |
4040 texture_id, contents_rect, ca_layer_overlay->background_color, | 4039 texture_id, contents_rect, ca_layer_overlay->background_color, |
4041 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4040 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4042 } | 4041 } |
4043 | 4042 |
4044 } // namespace cc | 4043 } // namespace cc |
OLD | NEW |