Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_GFX_SWAP_RESULT_H_ |
| 6 | #define UI_GFX_SWAP_RESULT_H_ |
| 7 | |
Christopher Cameron | 63803049 | 2020-06-01 18:41:43 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
Kalvin Lee | 7d17d557 | 2024-11-10 13:52:45 | [diff] [blame] | 10 | #include "base/component_export.h" |
Brian Anderson | feaa47c | 2017-11-17 23:40:21 | [diff] [blame] | 11 | #include "base/time/time.h" |
Eliot Courtney | 534052e | 2021-04-30 04:31:31 | [diff] [blame] | 12 | #include "ui/gfx/gpu_fence_handle.h" |
Brian Anderson | feaa47c | 2017-11-17 23:40:21 | [diff] [blame] | 13 | |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 14 | namespace gfx { |
| 15 | |
Christopher Cameron | 870810e | 2020-06-03 06:29:41 | [diff] [blame] | 16 | struct CALayerParams; |
Christopher Cameron | 63803049 | 2020-06-01 18:41:43 | [diff] [blame] | 17 | |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 18 | enum class SwapResult { |
| 19 | SWAP_ACK, |
| 20 | SWAP_FAILED, |
Brian Ho | 4757028 | 2021-07-02 19:48:48 | [diff] [blame] | 21 | // Typically, the Viz thread should decide whether to skip a swap based off |
| 22 | // the damage. In rare cases, however, the GPU main thread might skip the |
| 23 | // swap after the Viz thread requests it (e.g. the Viz thread might not know |
| 24 | // that the buffers are not fully initialized yet). For the purposes of |
| 25 | // metrics bookkeeping, we label this scenario as SWAP_SKIPPED and treat it |
| 26 | // much like we do a SWAP_FAILED (e.g. failed PresentationFeedback). |
| 27 | // TODO(https://crbug.com/1226090): Consider more explicit handling of |
| 28 | // SWAP_SKIPPED. |
| 29 | SWAP_SKIPPED, |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 30 | SWAP_NAK_RECREATE_BUFFERS, |
Maksim Sisov | 006ecc19 | 2024-06-14 06:07:24 | [diff] [blame] | 31 | // This swap result identifies cases when flipping non-simple overlay planes |
| 32 | // fails. |
| 33 | SWAP_NON_SIMPLE_OVERLAYS_FAILED, |
| 34 | SWAP_RESULT_LAST = SWAP_NON_SIMPLE_OVERLAYS_FAILED, |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 35 | }; |
| 36 | |
Daniel Libby | 78f8ea2 | 2019-06-11 23:31:52 | [diff] [blame] | 37 | struct SwapTimings { |
| 38 | // When the GPU service first started processing the SwapBuffers request. |
| 39 | base::TimeTicks swap_start; |
| 40 | |
| 41 | // On most platforms, this is when the GPU service finished processing the |
| 42 | // SwapBuffers request. On ChromeOS, this corresponds to the present time. |
| 43 | // TODO(brianderson): Differentiate the concepts without introducing |
| 44 | // dicontinuities in associated UMA data. |
| 45 | base::TimeTicks swap_end; |
Nathan Zabriskie | 965898a | 2019-09-18 22:05:25 | [diff] [blame] | 46 | |
kylechar | 7fbb9e9 | 2022-07-05 03:07:39 | [diff] [blame] | 47 | // When Display Compositor thread scheduled work to GPU Thread. For |
| 48 | // SkiaRenderer it's PostTask time for FinishPaintRenderPass or SwapBuffers |
| 49 | // whichever comes first. |
Vasiliy Telezhnikov | 2a1e964f | 2020-07-02 17:29:12 | [diff] [blame] | 50 | base::TimeTicks viz_scheduled_draw; |
| 51 | |
| 52 | // When GPU thread started draw submitted by Display Compositor thread. For |
kylechar | 7fbb9e9 | 2022-07-05 03:07:39 | [diff] [blame] | 53 | // SkiaRenderer it's FinishPaintRenderPass/SwapBuffers. |
Vasiliy Telezhnikov | 2a1e964f | 2020-07-02 17:29:12 | [diff] [blame] | 54 | base::TimeTicks gpu_started_draw; |
| 55 | |
Lucas Berthou | e2649ff | 2021-03-25 08:43:02 | [
|