File: display_snapshot_mojom_traits.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (193 lines) | stat: -rw-r--r-- 6,467 bytes parent folder | download | duplicates (9)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Copyright 2017 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_DISPLAY_MOJOM_DISPLAY_SNAPSHOT_MOJOM_TRAITS_H_
#define UI_DISPLAY_MOJOM_DISPLAY_SNAPSHOT_MOJOM_TRAITS_H_

#include "ui/display/mojom/display_constants_mojom_traits.h"
#include "ui/display/mojom/display_mode_mojom_traits.h"
#include "ui/display/mojom/display_snapshot.mojom-shared.h"
#include "ui/display/types/display_mode.h"
#include "ui/display/types/display_snapshot.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#include "ui/gfx/ipc/color/gfx_param_traits.h"

namespace mojo {

template <>
struct StructTraits<display::mojom::DisplaySnapshotColorInfoDataView,
                    display::DisplaySnapshot::ColorInfo> {
  static const gfx::ColorSpace& color_space(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.color_space;
  }
  static const SkColorSpacePrimaries& edid_primaries(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.edid_primaries;
  }
  static float edid_gamma(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.edid_gamma;
  }
  static const std::optional<gfx::HDRStaticMetadata>& hdr_static_metadata(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.hdr_static_metadata;
  }
  static bool supports_color_temperature_adjustment(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.supports_color_temperature_adjustment;
  }
  static uint32_t bits_per_channel(
      const display::DisplaySnapshot::ColorInfo& color_info) {
    return color_info.bits_per_channel;
  }

  static bool Read(display::mojom::DisplaySnapshotColorInfoDataView data,
                   display::DisplaySnapshot::ColorInfo* out);
};

template <>
struct StructTraits<display::mojom::DisplaySnapshotDataView,
                    std::unique_ptr<display::DisplaySnapshot>> {
  static int64_t display_id(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->display_id();
  }

  static int64_t port_display_id(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->port_display_id();
  }

  static int64_t edid_display_id(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->edid_display_id();
  }

  static uint16_t connector_index(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->connector_index();
  }

  static const gfx::Point& origin(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->origin();
  }

  static const gfx::Size& physical_size(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->physical_size();
  }

  static display::DisplayConnectionType type(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->type();
  }

  static uint64_t base_connector_id(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->base_connector_id();
  }

  static const std::vector<uint64_t>& path_topology(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->path_topology();
  }

  static display::PanelOrientation panel_orientation(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->panel_orientation();
  }

  static bool is_aspect_preserving_scaling(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->is_aspect_preserving_scaling();
  }

  static bool has_overscan(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->has_overscan();
  }

  static display::PrivacyScreenState privacy_screen_state(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->privacy_screen_state();
  }

  static bool has_content_protection_key(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->has_content_protection_key();
  }

  static const display::DisplaySnapshot::ColorInfo& color_info(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->color_info();
  }

  static std::string display_name(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->display_name();
  }

  static const base::FilePath& sys_path(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->sys_path();
  }

  static std::vector<uint8_t> edid(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->edid();
  }

  static std::vector<std::unique_ptr<display::DisplayMode>> modes(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot);

  static uint64_t current_mode_index(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot);

  static bool has_current_mode(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->current_mode() != nullptr;
  }

  static uint64_t native_mode_index(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot);

  static bool has_native_mode(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->native_mode() != nullptr;
  }

  static int64_t product_code(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->product_code();
  }

  static int32_t year_of_manufacture(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->year_of_manufacture();
  }

  static const gfx::Size& maximum_cursor_size(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->maximum_cursor_size();
  }

  static display::VariableRefreshRateState variable_refresh_rate_state(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->variable_refresh_rate_state();
  }

  static const display::DrmFormatsAndModifiers& drm_formats_and_modifiers(
      const std::unique_ptr<display::DisplaySnapshot>& snapshot) {
    return snapshot->GetDRMFormatsAndModifiers();
  }

  static bool Read(display::mojom::DisplaySnapshotDataView data,
                   std::unique_ptr<display::DisplaySnapshot>* out);
};

}  // namespace mojo

#endif  // UI_DISPLAY_MOJOM_DISPLAY_SNAPSHOT_MOJOM_TRAITS_H_