GCC Code Coverage Report


Directory: ./
File: submodules/raylib/src/external/glfw/src/null_monitor.c
Date: 2023-09-29 04:53:15
Exec Total Coverage
Lines: 0 53 0.0%
Branches: 0 22 0.0%

Line Branch Exec Source
1 //========================================================================
2 // GLFW 3.4 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2016 Google Inc.
5 // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 // claim that you wrote the original software. If you use this software
17 // in a product, an acknowledgment in the product documentation would
18 // be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 // be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 // distribution.
25 //
26 //========================================================================
27 // It is fine to use C99 in this file because it will not be built with VS
28 //========================================================================
29
30 #include "internal.h"
31
32 #include <stdlib.h>
33 #include <string.h>
34 #include <math.h>
35
36 // The the sole (fake) video mode of our (sole) fake monitor
37 //
38 static GLFWvidmode getVideoMode(void)
39 {
40 GLFWvidmode mode;
41 mode.width = 1920;
42 mode.height = 1080;
43 mode.redBits = 8;
44 mode.greenBits = 8;
45 mode.blueBits = 8;
46 mode.refreshRate = 60;
47 return mode;
48 }
49
50 //////////////////////////////////////////////////////////////////////////
51 ////// GLFW internal API //////
52 //////////////////////////////////////////////////////////////////////////
53
54 ✗ void _glfwPollMonitorsNull(void)
55 {
56 const float dpi = 141.f;
57 const GLFWvidmode mode = getVideoMode();
58 ✗ _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
59 (int) (mode.width * 25.4f / dpi),
60 (int) (mode.height * 25.4f / dpi));
61 ✗ _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
62 }
63
64 //////////////////////////////////////////////////////////////////////////
65 ////// GLFW platform API //////
66 //////////////////////////////////////////////////////////////////////////
67
68 ✗ void _glfwFreeMonitorNull(_GLFWmonitor* monitor)
69 {
70 ✗ _glfwFreeGammaArrays(&monitor->null.ramp);
71 }
72
73 ✗ void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos)
74 {
75 ✗ if (xpos)
76 ✗ *xpos = 0;
77 ✗ if (ypos)
78 ✗ *ypos = 0;
79 }
80
81 ✗ void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor,
82 float* xscale, float* yscale)
83 {
84 ✗ if (xscale)
85 ✗ *xscale = 1.f;
86 ✗ if (yscale)
87 ✗ *yscale = 1.f;
88 }
89
90 ✗ void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor,
91 int* xpos, int* ypos,
92 int* width, int* height)
93 {
94 const GLFWvidmode mode = getVideoMode();
95
96 ✗ if (xpos)
97 ✗ *xpos = 0;
98 ✗ if (ypos)
99 ✗ *ypos = 10;
100 ✗ if (width)
101 ✗ *width = mode.width;
102 ✗ if (height)
103 ✗ *height = mode.height - 10;
104 }
105
106 ✗ GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found)
107 {
108 ✗ GLFWvidmode* mode = _glfw_calloc(1, sizeof(GLFWvidmode));
109 ✗ *mode = getVideoMode();
110 ✗ *found = 1;
111 ✗ return mode;
112 }
113
114 ✗ void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode)
115 {
116 ✗ *mode = getVideoMode();
117 }
118
119 ✗ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
120 {
121 ✗ if (!monitor->null.ramp.size)
122 {
123 unsigned int i;
124
125 ✗ _glfwAllocGammaArrays(&monitor->null.ramp, 256);
126
127 ✗ for (i = 0; i < monitor->null.ramp.size; i++)
128 {
129 const float gamma = 2.2f;
130 float value;
131 ✗ value = i / (float) (monitor->null.ramp.size - 1);
132 ✗ value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
133 ✗ value = _glfw_fminf(value, 65535.f);
134
135 ✗ monitor->null.ramp.red[i] = (unsigned short) value;
136 ✗ monitor->null.ramp.green[i] = (unsigned short) value;
137 ✗ monitor->null.ramp.blue[i] = (unsigned short) value;
138 }
139 }
140
141 ✗ _glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
142 ✗ memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size);
143 ✗ memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
144 ✗ memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size);
145 ✗ return GLFW_TRUE;
146 }
147
148 ✗ void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
149 {
150 ✗ if (monitor->null.ramp.size != ramp->size)
151 {
152 ✗ _glfwInputError(GLFW_PLATFORM_ERROR,
153 "Null: Gamma ramp size must match current ramp size");
154 ✗ return;
155 }
156
157 ✗ memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size);
158 ✗ memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
159 ✗ memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size);
160 }
161
162