GCC Code Coverage Report


Directory: src/gate/
File: src/gate/graphics/cxx_framebuffers.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 0 50 0.0%
Functions: 0 11 0.0%
Branches: 0 37 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, 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/framebuffers.hpp"
30
31 #include "gate/exceptions.hpp"
32
33
34 namespace gate
35 {
36 namespace graph
37 {
38
39 FrameBuffer::FrameBuffer(gate_framebuffer_t* ptr_fb)
40 : object_impl_t(ptr_fb)
41 {
42 if (this->impl_ptr == NULL)
43 {
44 GATEXX_RAISE_ERROR(results::NullPointer);
45 }
46 }
47 FrameBuffer::FrameBuffer(FrameBuffer const& src)
48 : object_impl_t(src)
49 {
50 }
51
52 FrameBuffer::Info FrameBuffer::getInfo()
53 {
54 Info info;
55 result_t result = gate_framebuffer_get_info(this->c_impl(), &info);
56 GATEXX_CHECK_ERROR(result);
57 return info;
58 }
59 Property FrameBuffer::getProperty(String const& name)
60 {
61 Property prop;
62 result_t result = gate_framebuffer_get_property(this->c_impl(), name.c_impl(), prop.c_impl());
63 GATEXX_CHECK_EXCEPTION(result);
64 return prop;
65 }
66 void FrameBuffer::setProperty(String const& name, Property const& prop)
67 {
68 result_t result = gate_framebuffer_set_property(this->c_impl(), name.c_impl(), prop.c_impl());
69 GATEXX_CHECK_EXCEPTION(result);
70 }
71
72 void FrameBuffer::update()
73 {
74 result_t result = gate_framebuffer_update(this->c_impl());
75 GATEXX_CHECK_EXCEPTION(result);
76 }
77
78 bool_t FrameBuffer::getPixel(uint32_t x, uint32_t y, Color& col) noexcept
79 {
80 result_t result = gate_framebuffer_get_pixel(this->c_impl(), x, y, &col.value);
81 return GATE_SUCCEEDED(result);
82 }
83 bool_t FrameBuffer::setPixel(uint32_t x, uint32_t y, Color const& col) noexcept
84 {
85 result_t result = gate_framebuffer_set_pixel(this->c_impl(), x, y, col.value);
86 return GATE_SUCCEEDED(result);
87 }
88
89 RasterImage FrameBuffer::getImage(uint32_t src_x, uint32_t src_y, uint32_t width, uint32_t height)
90 {
91 RasterImage raster;
92 result_t result = gate_framebuffer_get_image(this->c_impl(), src_x, src_y, width, height, raster.c_impl());
93 GATEXX_CHECK_EXCEPTION(result);
94 return raster;
95 }
96
97 void FrameBuffer::setImage(RasterImage const& image, uint32_t dest_x, uint32_t dest_y)
98 {
99 result_t result = gate_framebuffer_set_image(this->c_impl(), image.c_impl(), dest_x, dest_y);
100 GATEXX_CHECK_EXCEPTION(result);
101 }
102
103 bool_t FrameBuffer::awaitEvent(uint32_t timeout_ms, Event& evt)
104 {
105 result_t result = gate_framebuffer_await_event(this->c_impl(), timeout_ms, &evt);
106 switch (result)
107 {
108 case GATE_RESULT_OK:
109 {
110 return true;
111 }
112 case GATE_RESULT_TIMEOUT:
113 {
114 break;
115 }
116 default:
117 {
118 GATEXX_CHECK_ERROR(result);
119 }
120 }
121 return false;
122 }
123
124 } // end of namespace graph
125 } // end of namespace gate
126