File: hardware_display_plane.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 (113 lines) | stat: -rw-r--r-- 3,218 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright 2014 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_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_H_
#define UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_H_

#include <stddef.h>
#include <stdint.h>

#include <xf86drmMode.h>

#include <cstdint>
#include <vector>

#include "base/containers/flat_set.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#include "ui/ozone/platform/drm/common/drm_wrapper.h"

namespace ui {

class DrmDevice;

class HardwareDisplayPlane {
 public:
  explicit HardwareDisplayPlane(uint32_t id);

  HardwareDisplayPlane(const HardwareDisplayPlane&) = delete;
  HardwareDisplayPlane& operator=(const HardwareDisplayPlane&) = delete;

  virtual ~HardwareDisplayPlane();

  virtual bool Initialize(DrmDevice* drm);

  bool IsSupportedFormat(uint32_t format);

  std::vector<uint64_t> ModifiersForFormat(uint32_t format) const;

  const base::flat_set<uint32_t>& GetCompatibleCrtcIds() const {
    return possible_crtc_ids_;
  }
  bool CanUseForCrtcId(uint32_t crtc_id) const;

  // Adds trace records to |context|.
  void WriteIntoTrace(perfetto::TracedValue context) const;

  std::ostream& DumpProperties(std::ostream& out) const;

  bool in_use() const { return in_use_; }
  void set_in_use(bool in_use) { in_use_ = in_use; }

  uint32_t id() const { return id_; }

  uint32_t type() const { return type_; }

  void set_owning_crtc(uint32_t crtc) { owning_crtc_ = crtc; }
  uint32_t owning_crtc() const { return owning_crtc_; }

  const std::vector<uint32_t>& supported_formats() const;
  const std::vector<gfx::Size>& supported_cursor_sizes() const;

 protected:
  struct Properties {
    Properties();
    ~Properties();
    // These properties are mandatory on DRM atomic. On legacy they may or may
    // not be present.
    DrmWrapper::Property crtc_id;
    DrmWrapper::Property crtc_x;
    DrmWrapper::Property crtc_y;
    DrmWrapper::Property crtc_w;
    DrmWrapper::Property crtc_h;
    DrmWrapper::Property fb_id;
    DrmWrapper::Property src_x;
    DrmWrapper::Property src_y;
    DrmWrapper::Property src_w;
    DrmWrapper::Property src_h;
    DrmWrapper::Property type;

    // Optional properties.
    DrmWrapper::Property rotation;
    DrmWrapper::Property in_formats;
    DrmWrapper::Property in_fence_fd;
    DrmWrapper::Property plane_color_encoding;
    DrmWrapper::Property plane_color_range;
    DrmWrapper::Property plane_fb_damage_clips;
    DrmWrapper::Property size_hints;
  };

  const uint32_t id_;

  Properties properties_ = {};

  base::flat_set<uint32_t> possible_crtc_ids_;
  uint32_t owning_crtc_ = 0;
  uint32_t last_used_format_ = 0;
  bool in_use_ = false;
  uint32_t type_ = DRM_PLANE_TYPE_PRIMARY;
  std::vector<uint32_t> supported_formats_;
  std::vector<gfx::Size> supported_cursor_sizes_;
  std::vector<drm_format_modifier> supported_format_modifiers_;

  uint64_t color_encoding_bt601_ = 0u;
  uint64_t color_encoding_bt709_ = 0u;
  uint64_t color_range_limited_ = 0u;

 private:
  void InitializeProperties(DrmDevice* drm);
};

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_DRM_GPU_HARDWARE_DISPLAY_PLANE_H_