OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/surfaces/display_output_surface.h" | 5 #include "services/ui/surfaces/display_output_surface.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
13 #include "cc/output/output_surface_client.h" | 13 #include "cc/output/output_surface_client.h" |
14 #include "cc/output/output_surface_frame.h" | 14 #include "cc/output/output_surface_frame.h" |
15 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
16 #include "gpu/command_buffer/client/context_support.h" | 16 #include "gpu/command_buffer/client/context_support.h" |
17 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 #include "gpu/ipc/gl_in_process_context.h" |
| 19 #include "components/latency_tracker/latency_tracker.h" |
18 | 20 |
19 namespace ui { | 21 namespace ui { |
20 | 22 |
21 DisplayOutputSurface::DisplayOutputSurface( | 23 DisplayOutputSurface::DisplayOutputSurface( |
22 scoped_refptr<cc::InProcessContextProvider> context_provider, | 24 scoped_refptr<cc::InProcessContextProvider> context_provider, |
23 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) | 25 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) |
24 : cc::OutputSurface(context_provider), | 26 : cc::OutputSurface(context_provider), |
25 synthetic_begin_frame_source_(synthetic_begin_frame_source), | 27 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 28 latency_tracker_(new latency_tracker::LatencyTracker), |
26 weak_ptr_factory_(this) { | 29 weak_ptr_factory_(this) { |
27 capabilities_.flipped_output_surface = | 30 capabilities_.flipped_output_surface = |
28 context_provider->ContextCapabilities().flips_vertically; | 31 context_provider->ContextCapabilities().flips_vertically; |
29 capabilities_.supports_stencil = | 32 capabilities_.supports_stencil = |
30 context_provider->ContextCapabilities().num_stencil_bits > 0; | 33 context_provider->ContextCapabilities().num_stencil_bits > 0; |
31 context_provider->SetSwapBuffersCompletionCallback( | 34 context_provider->SetSwapBuffersCompletionCallback( |
32 base::Bind(&DisplayOutputSurface::OnGpuSwapBuffersCompleted, | 35 base::Bind(&DisplayOutputSurface::OnGpuSwapBuffersCompleted, |
33 weak_ptr_factory_.GetWeakPtr())); | 36 weak_ptr_factory_.GetWeakPtr())); |
34 context_provider->SetUpdateVSyncParametersCallback( | 37 context_provider->SetUpdateVSyncParametersCallback( |
35 base::Bind(&DisplayOutputSurface::OnVSyncParametersUpdated, | 38 base::Bind(&DisplayOutputSurface::OnVSyncParametersUpdated, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 bool has_alpha, | 75 bool has_alpha, |
73 bool use_stencil) { | 76 bool use_stencil) { |
74 size_ = size; | 77 size_ = size; |
75 has_set_draw_rectangle_since_last_resize_ = false; | 78 has_set_draw_rectangle_since_last_resize_ = false; |
76 context_provider()->ContextGL()->ResizeCHROMIUM( | 79 context_provider()->ContextGL()->ResizeCHROMIUM( |
77 size.width(), size.height(), device_scale_factor, has_alpha); | 80 size.width(), size.height(), device_scale_factor, has_alpha); |
78 } | 81 } |
79 | 82 |
80 void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { | 83 void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { |
81 DCHECK(context_provider_); | 84 DCHECK(context_provider_); |
| 85 |
| 86 if (frame.latency_info.size() > 0) |
| 87 in_process_context_provider()->SetLatencyInfo(frame.latency_info); |
| 88 |
82 set_draw_rectangle_for_frame_ = false; | 89 set_draw_rectangle_for_frame_ = false; |
83 if (frame.sub_buffer_rect) { | 90 if (frame.sub_buffer_rect) { |
84 context_provider_->ContextSupport()->PartialSwapBuffers( | 91 context_provider_->ContextSupport()->PartialSwapBuffers( |
85 *frame.sub_buffer_rect); | 92 *frame.sub_buffer_rect); |
86 } else { | 93 } else { |
87 context_provider_->ContextSupport()->Swap(); | 94 context_provider_->ContextSupport()->Swap(/*frame.latency_info*/); |
88 } | 95 } |
89 } | 96 } |
90 | 97 |
91 uint32_t DisplayOutputSurface::GetFramebufferCopyTextureFormat() { | 98 uint32_t DisplayOutputSurface::GetFramebufferCopyTextureFormat() { |
92 // TODO(danakj): What attributes are used for the default framebuffer here? | 99 // TODO(danakj): What attributes are used for the default framebuffer here? |
93 // Can it have alpha? cc::InProcessContextProvider doesn't take any | 100 // Can it have alpha? cc::InProcessContextProvider doesn't take any |
94 // attributes. | 101 // attributes. |
95 return GL_RGB; | 102 return GL_RGB; |
96 } | 103 } |
97 | 104 |
(...skipping 21 matching lines...) Expand all Loading... |
119 void DisplayOutputSurface::ApplyExternalStencil() {} | 126 void DisplayOutputSurface::ApplyExternalStencil() {} |
120 | 127 |
121 void DisplayOutputSurface::DidReceiveSwapBuffersAck(gfx::SwapResult result) { | 128 void DisplayOutputSurface::DidReceiveSwapBuffersAck(gfx::SwapResult result) { |
122 client_->DidReceiveSwapBuffersAck(); | 129 client_->DidReceiveSwapBuffersAck(); |
123 } | 130 } |
124 | 131 |
125 void DisplayOutputSurface::OnGpuSwapBuffersCompleted( | 132 void DisplayOutputSurface::OnGpuSwapBuffersCompleted( |
126 const std::vector<ui::LatencyInfo>& latency_info, | 133 const std::vector<ui::LatencyInfo>& latency_info, |
127 gfx::SwapResult result, | 134 gfx::SwapResult result, |
128 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | 135 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { |
| 136 for (const auto& lat_elt : latency_info) { |
| 137 for (const auto& lc : lat_elt.latency_components()) { |
| 138 // TODO: Make this check a method in LatencyTracker, also use it in RWHImp
l? |
| 139 if (lc.first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
| 140 lc.first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT || |
| 141 lc.first.first == ui::TAB_SHOW_COMPONENT) { |
| 142 // TODO(mfomitchev): Figure out how to pass the proper value for |
| 143 // |is_running_navigation_hint_task|. |
| 144 latency_tracker_->OnGpuSwapBufersCompleted(lat_elt, false); |
| 145 } |
| 146 } |
| 147 } |
129 DidReceiveSwapBuffersAck(result); | 148 DidReceiveSwapBuffersAck(result); |
130 } | 149 } |
131 | 150 |
132 void DisplayOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase, | 151 void DisplayOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase, |
133 base::TimeDelta interval) { | 152 base::TimeDelta interval) { |
134 // TODO(brianderson): We should not be receiving 0 intervals. | 153 // TODO(brianderson): We should not be receiving 0 intervals. |
135 synthetic_begin_frame_source_->OnUpdateVSyncParameters( | 154 synthetic_begin_frame_source_->OnUpdateVSyncParameters( |
136 timebase, | 155 timebase, |
137 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); | 156 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); |
138 } | 157 } |
139 | 158 |
140 } // namespace ui | 159 } // namespace ui |
OLD | NEW |