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