File: swap_result.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (99 lines) | stat: -rw-r--r-- 3,667 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GFX_SWAP_RESULT_H_
#define UI_GFX_SWAP_RESULT_H_

#include <memory>

#include "base/component_export.h"
#include "base/time/time.h"
#include "ui/gfx/gpu_fence_handle.h"

namespace gfx {

struct CALayerParams;

enum class SwapResult {
  SWAP_ACK,
  SWAP_FAILED,
  // Typically, the Viz thread should decide whether to skip a swap based off
  // the damage. In rare cases, however, the GPU main thread might skip the
  // swap after the Viz thread requests it (e.g. the Viz thread might not know
  // that the buffers are not fully initialized yet). For the purposes of
  // metrics bookkeeping, we label this scenario as SWAP_SKIPPED and treat it
  // much like we do a SWAP_FAILED (e.g. failed PresentationFeedback).
  // TODO(https://crbug.com/1226090): Consider more explicit handling of
  // SWAP_SKIPPED.
  SWAP_SKIPPED,
  SWAP_NAK_RECREATE_BUFFERS,
  // This swap result identifies cases when flipping non-simple overlay planes
  // fails.
  SWAP_NON_SIMPLE_OVERLAYS_FAILED,
  SWAP_RESULT_LAST = SWAP_NON_SIMPLE_OVERLAYS_FAILED,
};

struct SwapTimings {
  // When the GPU service first started processing the SwapBuffers request.
  base::TimeTicks swap_start;

  // On most platforms, this is when the GPU service finished processing the
  // SwapBuffers request. On ChromeOS, this corresponds to the present time.
  // TODO(brianderson): Differentiate the concepts without introducing
  // dicontinuities in associated UMA data.
  base::TimeTicks swap_end;

  // When Display Compositor thread scheduled work to GPU Thread. For
  // SkiaRenderer it's PostTask time for FinishPaintRenderPass or SwapBuffers
  // whichever comes first.
  base::TimeTicks viz_scheduled_draw;

  // When GPU thread started draw submitted by Display Compositor thread. For
  // SkiaRenderer it's FinishPaintRenderPass/SwapBuffers.
  base::TimeTicks gpu_started_draw;

  // When GPU scheduler removed the last required dependency.
  base::TimeTicks gpu_task_ready;

  bool is_null() const { return swap_start.is_null() && swap_end.is_null(); }
};

// Sent by ImageTransportSurfaces to their clients in response to a SwapBuffers.
struct SwapResponse {
  // The swap's sequence id which helps clients determine which SwapBuffers
  // this corresponds to. We may receive responses out of order on platforms
  // that allow multiple swaps pending if a failed swap returns immediately
  // while a successful swap is still outstanding.
  uint64_t swap_id;

  // Indicates whether the swap succeeded or not.
  // TODO(crbug.com/40597949): It may be more reasonable to add
  // a full SwapCompletionResult as a member.
  SwapResult result;

  // Timing information about the given swap.
  SwapTimings timings;
};

// Sent as part of finishing a swap.
struct COMPONENT_EXPORT(GFX) SwapCompletionResult {
  explicit SwapCompletionResult(gfx::SwapResult swap_result);
  SwapCompletionResult(gfx::SwapResult swap_result,
                       gfx::GpuFenceHandle release_fence);
  SwapCompletionResult(gfx::SwapResult swap_result,
                       std::unique_ptr<gfx::CALayerParams> ca_layer_params);
  SwapCompletionResult(SwapCompletionResult&& other);
  ~SwapCompletionResult();

  SwapCompletionResult(const SwapCompletionResult& other) = delete;
  SwapCompletionResult& operator=(const SwapCompletionResult other) = delete;

  gfx::SwapResult swap_result = SwapResult::SWAP_FAILED;
  gfx::GpuFenceHandle release_fence;
  std::unique_ptr<CALayerParams> ca_layer_params;
};

}  // namespace gfx

#endif  // UI_GFX_SWAP_RESULT_H_