GCC Code Coverage Report


Directory: src/gate/
File: src/gate/graphics/cxx_colors.cpp
Date: 2026-02-03 22:06:38
Exec Total Coverage
Lines: 34 37 91.9%
Functions: 11 12 91.7%
Branches: 2 6 33.3%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/graphics/colors.hpp"
30 #include "gate/exceptions.hpp"
31 #include "gate/results.hpp"
32
33 namespace gate
34 {
35 namespace graph
36 {
37
38 7 Color::Color(uint32_t rgba)
39 {
40 7 this->value.rgba = rgba;
41
42 7 }
43 49 Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
44 {
45 49 this->value.r = r;
46 49 this->value.g = g;
47 49 this->value.b = b;
48 49 this->value.a = a;
49 49 }
50 1 Color::Color(gate_color_t const& col)
51 1 : value(col)
52 {
53 1 }
54
55 5 gate_color_t* Color::c_impl()
56 {
57 5 return &this->value;
58 }
59 14 gate_color_t const* Color::c_impl() const
60 {
61 14 return &this->value;
62 }
63
64 3 gate_color_t* Color::operator->()
65 {
66 3 return &this->value;
67 }
68 gate_color_t const* Color::operator->() const
69 {
70 return &this->value;
71 }
72
73
74
75 1 void Color::setOpaque(Color const& color)
76 {
77 1 gate_color_set_opaque(&this->value, &color.value);
78 1 }
79 1 void Color::setOpaque(gate_color_t const& color)
80 {
81 1 gate_color_set_opaque(&this->value, &color);
82
83 1 }
84
85 1 void Color::setTransparent(Color const& color)
86 {
87 1 gate_color_set_transparent(&this->value, &color.value);
88 1 }
89 1 void Color::setTransparent(gate_color_t const& color)
90 {
91 1 gate_color_set_transparent(&this->value, &color);
92 1 }
93
94
95 4 Color Color::parseHex(String const& text)
96 {
97 4 Color ret;
98
2/4
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
4 if (0 == gate_color_parse_hex(text.c_str(), text.length(), &ret.value))
99 {
100 GATEXX_RAISE_EXCEPTION(results::InvalidData, "Failed to parse hex color", 0);
101 }
102 4 return ret;
103 }
104
105 Color const Color::Black = Color(0x00, 0x00, 0x00);
106 Color const Color::Blue = Color(0x00, 0x00, 0x99);
107 Color const Color::Green = Color(0x00, 0x99, 0x00);
108 Color const Color::Cyan = Color(0x00, 0x99, 0x99);
109 Color const Color::Red = Color(0x99, 0x00, 0x00);
110 Color const Color::Magenta = Color(0x99, 0x00, 0x99);
111 Color const Color::Brown = Color(0x99, 0x66, 0x33);
112 Color const Color::LightGray = Color(0x99, 0x99, 0x99);
113 Color const Color::DarkGray = Color(0x66, 0x66, 0x66);
114 Color const Color::BrightBlue = Color(0x66, 0x66, 0xff);
115 Color const Color::BrightGreen = Color(0x66, 0xff, 0x66);
116 Color const Color::BrightCyan = Color(0x66, 0xff, 0xff);
117 Color const Color::BrightRed = Color(0xff, 0x66, 0x66);
118 Color const Color::BrightMagenta = Color(0xff, 0x66, 0xff);
119 Color const Color::Yellow = Color(0xff, 0xff, 0x66);
120 Color const Color::White = Color(0xff, 0xff, 0xff);
121
122
123 } // end of namespace graph
124 } // end of namespace gate
125