| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "gpu/ipc/service/pass_through_image_transport_surface.h" | 5 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 PassThroughImageTransportSurface::StartSwapBuffers() { | 181 PassThroughImageTransportSurface::StartSwapBuffers() { |
| 182 // GetVsyncValues before SwapBuffers to work around Mali driver bug: | 182 // GetVsyncValues before SwapBuffers to work around Mali driver bug: |
| 183 // crbug.com/223558. | 183 // crbug.com/223558. |
| 184 SendVSyncUpdateIfAvailable(); | 184 SendVSyncUpdateIfAvailable(); |
| 185 | 185 |
| 186 UpdateSwapInterval(); | 186 UpdateSwapInterval(); |
| 187 | 187 |
| 188 base::TimeTicks swap_time = base::TimeTicks::Now(); | 188 base::TimeTicks swap_time = base::TimeTicks::Now(); |
| 189 for (auto& latency : latency_info_) { | 189 for (auto& latency : latency_info_) { |
| 190 latency.AddLatencyNumberWithTimestamp( | 190 latency.AddLatencyNumberWithTimestamp( |
| 191 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, 0, swap_time, 1); | 191 ui::INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT, 0, swap_time, 1); |
| 192 } | 192 } |
| 193 | 193 |
| 194 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info( | 194 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info( |
| 195 new std::vector<ui::LatencyInfo>()); | 195 new std::vector<ui::LatencyInfo>()); |
| 196 latency_info->swap(latency_info_); | 196 latency_info->swap(latency_info_); |
| 197 | 197 |
| 198 return latency_info; | 198 return latency_info; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void PassThroughImageTransportSurface::FinishSwapBuffers( | 201 void PassThroughImageTransportSurface::FinishSwapBuffers( |
| 202 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, | 202 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, |
| 203 gfx::SwapResult result) { | 203 gfx::SwapResult result) { |
| 204 base::TimeTicks swap_ack_time = base::TimeTicks::Now(); | 204 base::TimeTicks swap_ack_time = base::TimeTicks::Now(); |
| 205 bool has_browser_snapshot_request = false; | 205 bool has_browser_snapshot_request = false; |
| 206 for (auto& latency : *latency_info) { | 206 for (auto& latency : *latency_info) { |
| 207 latency.AddLatencyNumberWithTimestamp( | 207 latency.AddLatencyNumberWithTimestamp( |
| 208 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0, | 208 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, |
| 209 swap_ack_time, 1); | 209 swap_ack_time, 1); |
| 210 has_browser_snapshot_request |= latency.FindLatency( | 210 has_browser_snapshot_request |= latency.FindLatency( |
| 211 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, nullptr); | 211 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT, nullptr); |
| 212 } | 212 } |
| 213 if (has_browser_snapshot_request) | 213 if (has_browser_snapshot_request) |
| 214 WaitForSnapshotRendering(); | 214 WaitForSnapshotRendering(); |
| 215 | 215 |
| 216 if (delegate_) { | 216 if (delegate_) { |
| 217 SwapBuffersCompleteParams params; | 217 SwapBuffersCompleteParams params; |
| 218 params.latency_info = std::move(*latency_info); | 218 params.latency_info = std::move(*latency_info); |
| 219 params.result = result; | 219 params.result = result; |
| 220 delegate_->DidSwapBuffersComplete(std::move(params)); | 220 delegate_->DidSwapBuffersComplete(std::move(params)); |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 void PassThroughImageTransportSurface::FinishSwapBuffersAsync( | 224 void PassThroughImageTransportSurface::FinishSwapBuffersAsync( |
| 225 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, | 225 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, |
| 226 GLSurface::SwapCompletionCallback callback, | 226 GLSurface::SwapCompletionCallback callback, |
| 227 gfx::SwapResult result) { | 227 gfx::SwapResult result) { |
| 228 FinishSwapBuffers(std::move(latency_info), result); | 228 FinishSwapBuffers(std::move(latency_info), result); |
| 229 callback.Run(result); | 229 callback.Run(result); |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace gpu | 232 } // namespace gpu |
| OLD | NEW |