Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 static_assert(int(blink::kWebBrowserControlsHidden) == int(cc::HIDDEN), | 179 static_assert(int(blink::kWebBrowserControlsHidden) == int(cc::HIDDEN), |
| 180 "mismatching enums: HIDDEN"); | 180 "mismatching enums: HIDDEN"); |
| 181 static_assert(int(blink::kWebBrowserControlsShown) == int(cc::SHOWN), | 181 static_assert(int(blink::kWebBrowserControlsShown) == int(cc::SHOWN), |
| 182 "mismatching enums: SHOWN"); | 182 "mismatching enums: SHOWN"); |
| 183 | 183 |
| 184 static cc::BrowserControlsState ConvertBrowserControlsState( | 184 static cc::BrowserControlsState ConvertBrowserControlsState( |
| 185 WebBrowserControlsState state) { | 185 WebBrowserControlsState state) { |
| 186 return static_cast<cc::BrowserControlsState>(state); | 186 return static_cast<cc::BrowserControlsState>(state); |
| 187 } | 187 } |
| 188 | 188 |
| 189 double MonotonicallyIncreasingTime() { | |
| 190 return base::TimeTicks::Now().ToInternalValue() / | |
| 191 static_cast<double>(base::Time::kMicrosecondsPerSecond); | |
|
sunnyps
2017/05/02 01:20:46
nit: can you put the static_case<double> on the fi
panicker
2017/05/02 21:21:36
Done.
| |
| 192 } | |
| 193 | |
| 189 } // namespace | 194 } // namespace |
| 190 | 195 |
| 196 RenderWidgetCompositor::ReportTimeSwapPromise::ReportTimeSwapPromise( | |
| 197 ReportTimeCallback callback, | |
| 198 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) | |
| 199 : callback_(callback), task_runner_(task_runner) {} | |
| 200 | |
| 201 RenderWidgetCompositor::ReportTimeSwapPromise::~ReportTimeSwapPromise() {} | |
| 202 | |
| 203 void RenderWidgetCompositor::ReportTimeSwapPromise::DidSwap() { | |
| 204 task_runner_->PostTask( | |
| 205 FROM_HERE, | |
| 206 base::BindOnce(callback_, true, MonotonicallyIncreasingTime())); | |
| 207 } | |
| 208 | |
| 209 cc::SwapPromise::DidNotSwapAction | |
| 210 RenderWidgetCompositor::ReportTimeSwapPromise::DidNotSwap( | |
| 211 cc::SwapPromise::DidNotSwapReason reason) { | |
| 212 task_runner_->PostTask(FROM_HERE, base::BindOnce(callback_, false, 0)); | |
| 213 return cc::SwapPromise::DidNotSwapAction::BREAK_PROMISE; | |
| 214 } | |
| 215 | |
| 216 int64_t RenderWidgetCompositor::ReportTimeSwapPromise::TraceId() const { | |
| 217 return 0; | |
| 218 } | |
| 219 | |
| 191 // static | 220 // static |
| 192 std::unique_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 221 std::unique_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
| 193 RenderWidgetCompositorDelegate* delegate, | 222 RenderWidgetCompositorDelegate* delegate, |
| 194 CompositorDependencies* compositor_deps) { | 223 CompositorDependencies* compositor_deps) { |
| 195 std::unique_ptr<RenderWidgetCompositor> compositor( | 224 std::unique_ptr<RenderWidgetCompositor> compositor( |
| 196 new RenderWidgetCompositor(delegate, compositor_deps)); | 225 new RenderWidgetCompositor(delegate, compositor_deps)); |
| 197 return compositor; | 226 return compositor; |
| 198 } | 227 } |
| 199 | 228 |
| 200 RenderWidgetCompositor::RenderWidgetCompositor( | 229 RenderWidgetCompositor::RenderWidgetCompositor( |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 | 1177 |
| 1149 void RenderWidgetCompositor::SetContentSourceId(uint32_t id) { | 1178 void RenderWidgetCompositor::SetContentSourceId(uint32_t id) { |
| 1150 layer_tree_host_->SetContentSourceId(id); | 1179 layer_tree_host_->SetContentSourceId(id); |
| 1151 } | 1180 } |
| 1152 | 1181 |
| 1153 void RenderWidgetCompositor::SetLocalSurfaceId( | 1182 void RenderWidgetCompositor::SetLocalSurfaceId( |
| 1154 const cc::LocalSurfaceId& local_surface_id) { | 1183 const cc::LocalSurfaceId& local_surface_id) { |
| 1155 layer_tree_host_->SetLocalSurfaceId(local_surface_id); | 1184 layer_tree_host_->SetLocalSurfaceId(local_surface_id); |
| 1156 } | 1185 } |
| 1157 | 1186 |
| 1187 void RenderWidgetCompositor::NotifySwapTime( | |
| 1188 base::Callback<void(bool, double)> callback) { | |
| 1189 QueueSwapPromise(base::MakeUnique<ReportTimeSwapPromise>( | |
| 1190 std::move(callback), base::ThreadTaskRunnerHandle::Get())); | |
| 1191 } | |
| 1192 | |
| 1158 } // namespace content | 1193 } // namespace content |
| OLD | NEW |