File: hdr_metadata_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 (113 lines) | stat: -rw-r--r-- 3,762 bytes parent folder | download | duplicates (6)
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 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_GFX_MOJOM_HDR_METADATA_MOJOM_TRAITS_H_
#define UI_GFX_MOJOM_HDR_METADATA_MOJOM_TRAITS_H_

#include "third_party/skia/include/core/SkData.h"
#include "ui/gfx/hdr_metadata.h"
#include "ui/gfx/mojom/hdr_metadata.mojom.h"

namespace mojo {

template <>
struct StructTraits<gfx::mojom::HdrMetadataCta861_3DataView,
                    gfx::HdrMetadataCta861_3> {
  static unsigned max_content_light_level(
      const gfx::HdrMetadataCta861_3& input) {
    return input.max_content_light_level;
  }
  static unsigned max_frame_average_light_level(
      const gfx::HdrMetadataCta861_3& input) {
    return input.max_frame_average_light_level;
  }
  static bool Read(gfx::mojom::HdrMetadataCta861_3DataView data,
                   gfx::HdrMetadataCta861_3* output);
};

template <>
struct StructTraits<gfx::mojom::HdrMetadataSmpteSt2086DataView,
                    gfx::HdrMetadataSmpteSt2086> {
  static const SkColorSpacePrimaries& primaries(
      const gfx::HdrMetadataSmpteSt2086& input) {
    return input.primaries;
  }
  static float luminance_max(const gfx::HdrMetadataSmpteSt2086& input) {
    return input.luminance_max;
  }
  static float luminance_min(const gfx::HdrMetadataSmpteSt2086& input) {
    return input.luminance_min;
  }

  static bool Read(gfx::mojom::HdrMetadataSmpteSt2086DataView data,
                   gfx::HdrMetadataSmpteSt2086* output);
};

template <>
struct StructTraits<gfx::mojom::HdrMetadataNdwlDataView, gfx::HdrMetadataNdwl> {
  static float nits(const gfx::HdrMetadataNdwl& input) { return input.nits; }

  static bool Read(gfx::mojom::HdrMetadataNdwlDataView data,
                   gfx::HdrMetadataNdwl* output);
};

template <>
struct StructTraits<gfx::mojom::HdrMetadataExtendedRangeDataView,
                    gfx::HdrMetadataExtendedRange> {
  static float current_headroom(const gfx::HdrMetadataExtendedRange& input) {
    return input.current_headroom;
  }
  static float desired_headroom(const gfx::HdrMetadataExtendedRange& input) {
    return input.desired_headroom;
  }

  static bool Read(gfx::mojom::HdrMetadataExtendedRangeDataView data,
                   gfx::HdrMetadataExtendedRange* output);
};

template <>
struct StructTraits<gfx::mojom::HdrMetadataAgtmDataView, gfx::HdrMetadataAgtm> {
  static std::vector<uint8_t> payload(const gfx::HdrMetadataAgtm& input) {
    std::vector<uint8_t> result;
    if (input.payload) {
      result.assign(input.payload->bytes(),
                    std::next(input.payload->bytes(), input.payload->size()));
    }
    return result;
  }

  static bool Read(gfx::mojom::HdrMetadataAgtmDataView data,
                   gfx::HdrMetadataAgtm* output);
};

template <>
struct StructTraits<gfx::mojom::HDRMetadataDataView, gfx::HDRMetadata> {
  static const std::optional<gfx::HdrMetadataCta861_3>& cta_861_3(
      const gfx::HDRMetadata& input) {
    return input.cta_861_3;
  }
  static const std::optional<gfx::HdrMetadataSmpteSt2086>& smpte_st_2086(
      const gfx::HDRMetadata& input) {
    return input.smpte_st_2086;
  }
  static const std::optional<gfx::HdrMetadataNdwl>& ndwl(
      const gfx::HDRMetadata& input) {
    return input.ndwl;
  }
  static const std::optional<gfx::HdrMetadataExtendedRange>& extended_range(
      const gfx::HDRMetadata& input) {
    return input.extended_range;
  }
  static const std::optional<gfx::HdrMetadataAgtm>& agtm(
      const gfx::HDRMetadata& input) {
    return input.agtm;
  }

  static bool Read(gfx::mojom::HDRMetadataDataView data,
                   gfx::HDRMetadata* output);
};

}  // namespace mojo

#endif  // UI_GFX_MOJOM_HDR_METADATA_MOJOM_TRAITS_H_