Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: services/ui/surfaces/display_output_surface.cc

Issue 2806163004: Plumbing input event latency reporting through Mus GPU. (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/surfaces/display_output_surface.h ('k') | ui/latency/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/latency/latency_tracker.h"
18 19
19 namespace ui { 20 namespace ui {
20 21
21 DisplayOutputSurface::DisplayOutputSurface( 22 DisplayOutputSurface::DisplayOutputSurface(
22 scoped_refptr<cc::InProcessContextProvider> context_provider, 23 scoped_refptr<cc::InProcessContextProvider> context_provider,
23 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) 24 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source)
24 : cc::OutputSurface(context_provider), 25 : cc::OutputSurface(context_provider),
25 synthetic_begin_frame_source_(synthetic_begin_frame_source), 26 synthetic_begin_frame_source_(synthetic_begin_frame_source),
27 latency_tracker_(new LatencyTracker),
Fady Samuel 2017/04/13 03:32:17 nit: base::MakeUnique<LatencyTracker>() or better
mfomitchev 2017/04/13 17:15:29 Done.
26 weak_ptr_factory_(this) { 28 weak_ptr_factory_(this) {
27 capabilities_.flipped_output_surface = 29 capabilities_.flipped_output_surface =
28 context_provider->ContextCapabilities().flips_vertically; 30 context_provider->ContextCapabilities().flips_vertically;
29 capabilities_.supports_stencil = 31 capabilities_.supports_stencil =
30 context_provider->ContextCapabilities().num_stencil_bits > 0; 32 context_provider->ContextCapabilities().num_stencil_bits > 0;
31 context_provider->SetSwapBuffersCompletionCallback( 33 context_provider->SetSwapBuffersCompletionCallback(
32 base::Bind(&DisplayOutputSurface::OnGpuSwapBuffersCompleted, 34 base::Bind(&DisplayOutputSurface::OnGpuSwapBuffersCompleted,
33 weak_ptr_factory_.GetWeakPtr())); 35 weak_ptr_factory_.GetWeakPtr()));
34 context_provider->SetUpdateVSyncParametersCallback( 36 context_provider->SetUpdateVSyncParametersCallback(
35 base::Bind(&DisplayOutputSurface::OnVSyncParametersUpdated, 37 base::Bind(&DisplayOutputSurface::OnVSyncParametersUpdated,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 bool has_alpha, 74 bool has_alpha,
73 bool use_stencil) { 75 bool use_stencil) {
74 size_ = size; 76 size_ = size;
75 has_set_draw_rectangle_since_last_resize_ = false; 77 has_set_draw_rectangle_since_last_resize_ = false;
76 context_provider()->ContextGL()->ResizeCHROMIUM( 78 context_provider()->ContextGL()->ResizeCHROMIUM(
77 size.width(), size.height(), device_scale_factor, has_alpha); 79 size.width(), size.height(), device_scale_factor, has_alpha);
78 } 80 }
79 81
80 void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { 82 void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) {
81 DCHECK(context_provider_); 83 DCHECK(context_provider_);
84
85 if (frame.latency_info.size() > 0)
86 context_provider_->ContextSupport()->AddLatencyInfo(frame.latency_info);
87
82 set_draw_rectangle_for_frame_ = false; 88 set_draw_rectangle_for_frame_ = false;
83 if (frame.sub_buffer_rect) { 89 if (frame.sub_buffer_rect) {
84 context_provider_->ContextSupport()->PartialSwapBuffers( 90 context_provider_->ContextSupport()->PartialSwapBuffers(
85 *frame.sub_buffer_rect); 91 *frame.sub_buffer_rect);
86 } else { 92 } else {
87 context_provider_->ContextSupport()->Swap(); 93 context_provider_->ContextSupport()->Swap();
88 } 94 }
89 } 95 }
90 96
91 uint32_t DisplayOutputSurface::GetFramebufferCopyTextureFormat() { 97 uint32_t DisplayOutputSurface::GetFramebufferCopyTextureFormat() {
(...skipping 24 matching lines...) Expand all
116 return false; 122 return false;
117 } 123 }
118 124
119 void DisplayOutputSurface::ApplyExternalStencil() {} 125 void DisplayOutputSurface::ApplyExternalStencil() {}
120 126
121 void DisplayOutputSurface::DidReceiveSwapBuffersAck(gfx::SwapResult result) { 127 void DisplayOutputSurface::DidReceiveSwapBuffersAck(gfx::SwapResult result) {
122 client_->DidReceiveSwapBuffersAck(); 128 client_->DidReceiveSwapBuffersAck();
123 } 129 }
124 130
125 void DisplayOutputSurface::OnGpuSwapBuffersCompleted( 131 void DisplayOutputSurface::OnGpuSwapBuffersCompleted(
126 const std::vector<ui::LatencyInfo>& latency_info, 132 const std::vector<LatencyInfo>& latency_info,
127 gfx::SwapResult result, 133 gfx::SwapResult result,
128 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { 134 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
135 for (const auto& latency : latency_info) {
136 if (latency.latency_components().size() > 0)
137 latency_tracker_->OnGpuSwapBuffersCompleted(latency);
138 }
129 DidReceiveSwapBuffersAck(result); 139 DidReceiveSwapBuffersAck(result);
130 } 140 }
131 141
132 void DisplayOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase, 142 void DisplayOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase,
133 base::TimeDelta interval) { 143 base::TimeDelta interval) {
134 // TODO(brianderson): We should not be receiving 0 intervals. 144 // TODO(brianderson): We should not be receiving 0 intervals.
135 synthetic_begin_frame_source_->OnUpdateVSyncParameters( 145 synthetic_begin_frame_source_->OnUpdateVSyncParameters(
136 timebase, 146 timebase,
137 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); 147 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval);
138 } 148 }
139 149
140 } // namespace ui 150 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/display_output_surface.h ('k') | ui/latency/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698