blob: 8fa34e30d2142c09213d0458175a39b6fa4bdcde [file] [log] [blame]
Jamie Madill1cfaaf82014-08-21 10:04:04 -04001//
2// Copyright (c) 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
Corentin Wallez178e5972015-09-14 11:52:44 -070010#include <list>
11#include <memory>
12#include <stdint.h>
13#include <string>
14
Yuly Novikove3352f92016-08-12 20:40:14 -040015#include <export.h>
Jamie Madill1cfaaf82014-08-21 10:04:04 -040016#include <GLES2/gl2.h>
17#include <GLES2/gl2ext.h>
Corentin Wallez178e5972015-09-14 11:52:44 -070018#include <GLES3/gl3.h>
Jamie Madill1cfaaf82014-08-21 10:04:04 -040019#include <EGL/egl.h>
20#include <EGL/eglext.h>
21
Jamie Madill2d1eea02015-03-27 09:46:41 -040022#include "common/angleutils.h"
Jamie Madill0448ec82016-12-23 13:41:47 -050023#include "common/Optional.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040024
25class OSWindow;
26
Jamie Madill19a43db2015-03-20 16:14:04 -040027// A hidden define used in some renderers (currently D3D-only)
28// to init a no-op renderer. Useful for performance testing.
29#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
30#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
31#endif
32
Yuly Novikove3352f92016-08-12 20:40:14 -040033struct ANGLE_EXPORT EGLPlatformParameters
Geoff Lang0d3683c2014-10-23 11:08:16 -040034{
35 EGLint renderer;
36 EGLint majorVersion;
37 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050038 EGLint deviceType;
Austin Kinross2a63b3f2016-02-08 12:29:08 -080039 EGLint presentPath;
Geoff Lang0d3683c2014-10-23 11:08:16 -040040
41 EGLPlatformParameters();
42 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050043 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Austin Kinross2a63b3f2016-02-08 12:29:08 -080044 EGLPlatformParameters(EGLint renderer,
45 EGLint majorVersion,
46 EGLint minorVersion,
47 EGLint deviceType,
48 EGLint presentPath);
Geoff Lang0d3683c2014-10-23 11:08:16 -040049};
50
Yuly Novikove3352f92016-08-12 20:40:14 -040051ANGLE_EXPORT bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
52ANGLE_EXPORT bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040053
Yuly Novikove3352f92016-08-12 20:40:14 -040054class ANGLE_EXPORT EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040055{
56 public:
Geoff Lang5ade8452015-09-02 11:00:30 -040057 EGLWindow(EGLint glesMajorVersion,
58 EGLint glesMinorVersion,
59 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040060
61 ~EGLWindow();
62
Jamie Madill3757a5a2014-08-26 13:16:36 -040063 void setConfigRedBits(int bits) { mRedBits = bits; }
64 void setConfigGreenBits(int bits) { mGreenBits = bits; }
65 void setConfigBlueBits(int bits) { mBlueBits = bits; }
66 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
67 void setConfigDepthBits(int bits) { mDepthBits = bits; }
68 void setConfigStencilBits(int bits) { mStencilBits = bits; }
Geoff Langc5a2a172017-01-13 15:55:07 -050069 void setConfigComponentType(EGLenum componentType) { mComponentType = componentType; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040070 void setMultisample(bool multisample) { mMultisample = multisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050071 void setDebugEnabled(bool debug) { mDebug = debug; }
Jamie Madill60ec6ea2016-01-22 15:27:19 -050072 void setNoErrorEnabled(bool noError) { mNoError = noError; }
Geoff Langc287ea62016-09-16 14:46:51 -040073 void setWebGLCompatibilityEnabled(bool webglCompatibility)
74 {
75 mWebGLCompatibility = webglCompatibility;
76 }
Geoff Langf41a7152016-09-19 15:11:17 -040077 void setBindGeneratesResource(bool bindGeneratesResource)
78 {
79 mBindGeneratesResource = bindGeneratesResource;
80 }
Jamie Madill0448ec82016-12-23 13:41:47 -050081 void setVulkanLayersEnabled(bool enabled) { mVulkanLayersEnabled = enabled; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040082 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
83
Cooper Partin1bd7dd42015-06-11 08:58:53 -070084 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
85
Jamie Madill1cfaaf82014-08-21 10:04:04 -040086 void swap();
87
Geoff Lang5ade8452015-09-02 11:00:30 -040088 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
89 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040090 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040091 EGLConfig getConfig() const;
92 EGLDisplay getDisplay() const;
93 EGLSurface getSurface() const;
94 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040095 int getConfigRedBits() const { return mRedBits; }
96 int getConfigGreenBits() const { return mGreenBits; }
97 int getConfigBlueBits() const { return mBlueBits; }
98 int getConfigAlphaBits() const { return mAlphaBits; }
99 int getConfigDepthBits() const { return mDepthBits; }
100 int getConfigStencilBits() const { return mStencilBits; }
101 bool isMultisample() const { return mMultisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -0500102 bool isDebugEnabled() const { return mDebug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -0400103 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400104
Austin Kinross18b931d2014-09-29 12:58:31 -0700105 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400106 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -0400107 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400108
109 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400110 EGLConfig mConfig;
111 EGLDisplay mDisplay;
112 EGLSurface mSurface;
113 EGLContext mContext;
114
Geoff Lang5ade8452015-09-02 11:00:30 -0400115 EGLint mClientMajorVersion;
116 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400117 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400118 int mRedBits;
119 int mGreenBits;
120 int mBlueBits;
121 int mAlphaBits;
122 int mDepthBits;
123 int mStencilBits;
Geoff Langc5a2a172017-01-13 15:55:07 -0500124 EGLenum mComponentType;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400125 bool mMultisample;
Geoff Lang70d0f492015-12-10 17:45:46 -0500126 bool mDebug;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500127 bool mNoError;
Geoff Langc287ea62016-09-16 14:46:51 -0400128 bool mWebGLCompatibility;
Geoff Langf41a7152016-09-19 15:11:17 -0400129 bool mBindGeneratesResource;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400130 EGLint mSwapInterval;
Jamie Madill0448ec82016-12-23 13:41:47 -0500131 Optional<bool> mVulkanLayersEnabled;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400132};
133
134#endif // UTIL_EGLWINDOW_H_