Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/angle
Path: blob/main_old/util/EGLWindow.h
1693 views
1
//
2
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
5
//
6
7
#ifndef UTIL_EGLWINDOW_H_
8
#define UTIL_EGLWINDOW_H_
9
10
#include <stdint.h>
11
#include <list>
12
#include <memory>
13
#include <string>
14
15
#include "common/Optional.h"
16
#include "common/angleutils.h"
17
#include "util/EGLPlatformParameters.h"
18
#include "util/util_export.h"
19
#include "util/util_gl.h"
20
21
class OSWindow;
22
23
namespace angle
24
{
25
class Library;
26
struct PlatformMethods;
27
using GenericProc = void (*)();
28
} // namespace angle
29
30
struct ANGLE_UTIL_EXPORT ConfigParameters
31
{
32
ConfigParameters();
33
~ConfigParameters();
34
35
void reset();
36
37
// Surface and Context parameters.
38
int redBits;
39
int greenBits;
40
int blueBits;
41
int alphaBits;
42
int depthBits;
43
int stencilBits;
44
45
Optional<bool> webGLCompatibility;
46
Optional<bool> robustResourceInit;
47
48
// EGLWindow-specific.
49
EGLenum componentType;
50
bool multisample;
51
bool debug;
52
bool noError;
53
Optional<bool> extensionsEnabled;
54
bool bindGeneratesResource;
55
bool clientArraysEnabled;
56
bool robustAccess;
57
EGLint samples;
58
Optional<bool> contextProgramCacheEnabled;
59
EGLenum resetStrategy;
60
EGLenum colorSpace;
61
EGLint swapInterval;
62
};
63
64
using GLWindowContext = struct GLWindowHandleContext_T *;
65
66
class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
67
{
68
public:
69
static void Delete(GLWindowBase **window);
70
71
// It should also be possible to set multisample and floating point framebuffers.
72
EGLint getClientMajorVersion() const { return mClientMajorVersion; }
73
EGLint getClientMinorVersion() const { return mClientMinorVersion; }
74
75
virtual bool initializeGL(OSWindow *osWindow,
76
angle::Library *glWindowingLibrary,
77
angle::GLESDriverType driverType,
78
const EGLPlatformParameters &platformParams,
79
const ConfigParameters &configParams) = 0;
80
virtual bool isGLInitialized() const = 0;
81
virtual void swap() = 0;
82
virtual void destroyGL() = 0;
83
virtual bool makeCurrent() = 0;
84
virtual bool hasError() const = 0;
85
virtual bool setSwapInterval(EGLint swapInterval) = 0;
86
virtual angle::GenericProc getProcAddress(const char *name) = 0;
87
// EGLContext and HGLRC (WGL) are both "handles", which are implemented as pointers.
88
// Use void* here and let the underlying implementation handle interpreting the type correctly.
89
virtual GLWindowContext getCurrentContextGeneric() = 0;
90
virtual GLWindowContext createContextGeneric(GLWindowContext share) = 0;
91
virtual bool makeCurrentGeneric(GLWindowContext context) = 0;
92
93
bool isMultisample() const { return mConfigParams.multisample; }
94
bool isDebugEnabled() const { return mConfigParams.debug; }
95
96
const angle::PlatformMethods *getPlatformMethods() const { return mPlatform.platformMethods; }
97
98
const EGLPlatformParameters &getPlatform() const { return mPlatform; }
99
const ConfigParameters &getConfigParams() const { return mConfigParams; }
100
101
protected:
102
GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion);
103
virtual ~GLWindowBase();
104
105
EGLint mClientMajorVersion;
106
EGLint mClientMinorVersion;
107
EGLPlatformParameters mPlatform;
108
ConfigParameters mConfigParams;
109
};
110
111
class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
112
{
113
public:
114
static EGLWindow *New(EGLint glesMajorVersion, EGLint glesMinorVersion);
115
static void Delete(EGLWindow **window);
116
117
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
118
119
EGLConfig getConfig() const;
120
EGLDisplay getDisplay() const;
121
EGLSurface getSurface() const;
122
EGLContext getContext() const;
123
124
bool isContextVersion(EGLint glesMajorVersion, EGLint glesMinorVersion) const;
125
126
// Internally initializes the Display, Surface and Context.
127
bool initializeGL(OSWindow *osWindow,
128
angle::Library *glWindowingLibrary,
129
angle::GLESDriverType driverType,
130
const EGLPlatformParameters &platformParams,
131
const ConfigParameters &configParams) override;
132
133
bool isGLInitialized() const override;
134
void swap() override;
135
void destroyGL() override;
136
bool makeCurrent() override;
137
bool hasError() const override;
138
bool setSwapInterval(EGLint swapInterval) override;
139
angle::GenericProc getProcAddress(const char *name) override;
140
// Initializes EGL resources.
141
GLWindowContext getCurrentContextGeneric() override;
142
GLWindowContext createContextGeneric(GLWindowContext share) override;
143
bool makeCurrentGeneric(GLWindowContext context) override;
144
145
// Only initializes the Display.
146
bool initializeDisplay(OSWindow *osWindow,
147
angle::Library *glWindowingLibrary,
148
angle::GLESDriverType driverType,
149
const EGLPlatformParameters &params);
150
151
// Only initializes the Surface.
152
bool initializeSurface(OSWindow *osWindow,
153
angle::Library *glWindowingLibrary,
154
const ConfigParameters &params);
155
156
// Create an EGL context with this window's configuration
157
EGLContext createContext(EGLContext share);
158
// Make the EGL context current
159
bool makeCurrent(EGLContext context);
160
161
// Only initializes the Context.
162
bool initializeContext();
163
164
void destroySurface();
165
void destroyContext();
166
167
bool isDisplayInitialized() const { return mDisplay != EGL_NO_DISPLAY; }
168
169
private:
170
EGLWindow(EGLint glesMajorVersion, EGLint glesMinorVersion);
171
~EGLWindow() override;
172
173
EGLConfig mConfig;
174
EGLDisplay mDisplay;
175
EGLSurface mSurface;
176
EGLContext mContext;
177
178
EGLint mEGLMajorVersion;
179
EGLint mEGLMinorVersion;
180
};
181
182
#endif // UTIL_EGLWINDOW_H_
183
184