blob: 82a8b6bc0c96901d361ac8113ea4820e23cedf85 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2012 The Chromium Authors
achaulkec8c2db2015-05-29 16:35:032// 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 Cameron638030492020-06-01 18:41:438#include <memory>
9
Kalvin Lee7d17d5572024-11-10 13:52:4510#include "base/component_export.h"
Brian Andersonfeaa47c2017-11-17 23:40:2111#include "base/time/time.h"
Eliot Courtney534052e2021-04-30 04:31:3112#include "ui/gfx/gpu_fence_handle.h"
Brian Andersonfeaa47c2017-11-17 23:40:2113
achaulkec8c2db2015-05-29 16:35:0314namespace gfx {
15
Christopher Cameron870810e2020-06-03 06:29:4116struct CALayerParams;
Christopher Cameron638030492020-06-01 18:41:4317
achaulkec8c2db2015-05-29 16:35:0318enum class SwapResult {
19 SWAP_ACK,
20 SWAP_FAILED,
Brian Ho47570282021-07-02 19:48:4821 // 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,
achaulkec8c2db2015-05-29 16:35:0330 SWAP_NAK_RECREATE_BUFFERS,
Maksim Sisov006ecc192024-06-14 06:07:2431 // 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,
achaulkec8c2db2015-05-29 16:35:0335};
36
Daniel Libby78f8ea22019-06-11 23:31:5237struct 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 Zabriskie965898a2019-09-18 22:05:2546
kylechar7fbb9e92022-07-05 03:07:3947 // 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 Telezhnikov2a1e964f2020-07-02 17:29:1250 base::TimeTicks viz_scheduled_draw;
51
52 // When GPU thread started draw submitted by Display Compositor thread. For
kylechar7fbb9e92022-07-05 03:07:3953 // SkiaRenderer it's FinishPaintRenderPass/SwapBuffers.
Vasiliy Telezhnikov2a1e964f2020-07-02 17:29:1254 base::TimeTicks gpu_started_draw;
55
Lucas Berthoue2649ff2021-03-25 08:43:02