RAMSES Documentation  27.0.130
Information for RAMSES users and developers
Glyph.h
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // Copyright (C) 2018 BMW Car IT GmbH
3 // -------------------------------------------------------------------------
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 // -------------------------------------------------------------------------
8 
9 #ifndef RAMSES_GLYPH_H
10 #define RAMSES_GLYPH_H
11 
14 #include <vector>
15 #include <limits>
16 #include <functional>
17 
18 namespace ramses
19 {
23  using GlyphData = std::vector<uint8_t>;
24 
28  struct GlyphIdTag {};
29 
34 
38  struct GlyphKey
39  {
43  GlyphKey() = default;
44 
50  GlyphKey(GlyphId _identifier, FontInstanceId _fontInstanceId)
51  : identifier(_identifier)
52  , fontInstanceId(_fontInstanceId)
53  {
54  }
55 
61  bool operator==(const GlyphKey& rhs) const
62  {
63  return identifier == rhs.identifier && fontInstanceId == rhs.fontInstanceId;
64  }
65 
71  bool operator!=(const GlyphKey& rhs) const
72  {
73  return !(*this == rhs);
74  }
75 
80  };
81 
83  using GlyphKeyVector = std::vector<GlyphKey>;
84 }
85 
86 namespace std
87 {
89  template <>
90  struct hash<ramses::GlyphKey>
91  {
97  size_t operator()(const ramses::GlyphKey& k) const
98  {
99  static_assert(sizeof(ramses::GlyphKey::identifier) <= sizeof(uint32_t), "Adapt hashing function!");
100  static_assert(sizeof(ramses::GlyphKey::fontInstanceId) <= sizeof(uint32_t), "Adapt hashing function!");
101  const uint64_t val = (uint64_t(k.identifier.getValue()) << 32) | k.fontInstanceId.getValue();
102  return hash<uint64_t>()(val);
103  }
104  };
105 }
106 
107 #endif
constexpr BaseType getValue() const
Getter for retrieving the underlying value.
Definition: StronglyTypedValue.h:73
The RAMSES namespace contains all client side objects and functions used to implement RAMSES applicat...
Definition: AnimatedProperty.h:15
std::vector< uint8_t > GlyphData
Stores 2-dimensional glyph pixel data as a flat memory array.
Definition: Glyph.h:23
std::vector< GlyphKey > GlyphKeyVector
Vector of GlyphKey elements.
Definition: Glyph.h:83
Definition: Glyph.h:87
An empty struct to make GlyphId a strong type.
Definition: Glyph.h:28
GlyphKey identifies a glyph with a specific font instance.
Definition: Glyph.h:39
GlyphKey()=default
Constructor for GlyphKey that initializes members to default values.
bool operator==(const GlyphKey &rhs) const
Equal comparison operator.
Definition: Glyph.h:61
GlyphKey(GlyphId _identifier, FontInstanceId _fontInstanceId)
Constructor for GlyphKey that initializes members to passed values.
Definition: Glyph.h:50
FontInstanceId fontInstanceId
Font instance id.
Definition: Glyph.h:79
GlyphId identifier
Glyph id.
Definition: Glyph.h:77
bool operator!=(const GlyphKey &rhs) const
Unequal comparison operator.
Definition: Glyph.h:71
size_t operator()(const ramses::GlyphKey &k) const
Hasher implementation.
Definition: Glyph.h:97