Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 1 | // |
| 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 Wallez | 178e597 | 2015-09-14 11:52:44 -0700 | [diff] [blame] | 10 | #include <list> |
| 11 | #include <memory> |
| 12 | #include <stdint.h> |
| 13 | #include <string> |
| 14 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 15 | #include <export.h> |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 16 | #include <GLES2/gl2.h> |
| 17 | #include <GLES2/gl2ext.h> |
Corentin Wallez | 178e597 | 2015-09-14 11:52:44 -0700 | [diff] [blame] | 18 | #include <GLES3/gl3.h> |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 19 | #include <EGL/egl.h> |
| 20 | #include <EGL/eglext.h> |
| 21 | |
Jamie Madill | 2d1eea0 | 2015-03-27 09:46:41 -0400 | [diff] [blame] | 22 | #include "common/angleutils.h" |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 23 | |
| 24 | class OSWindow; |
| 25 | |
Jamie Madill | 19a43db | 2015-03-20 16:14:04 -0400 | [diff] [blame] | 26 | // A hidden define used in some renderers (currently D3D-only) |
| 27 | // to init a no-op renderer. Useful for performance testing. |
| 28 | #ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE |
| 29 | #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0 |
| 30 | #endif |
| 31 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 32 | struct ANGLE_EXPORT EGLPlatformParameters |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 33 | { |
| 34 | EGLint renderer; |
| 35 | EGLint majorVersion; |
| 36 | EGLint minorVersion; |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 37 | EGLint deviceType; |
Austin Kinross | 2a63b3f | 2016-02-08 12:29:08 -0800 | [diff] [blame] | 38 | EGLint presentPath; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 39 | |
| 40 | EGLPlatformParameters(); |
| 41 | explicit EGLPlatformParameters(EGLint renderer); |
Geoff Lang | 7825f61 | 2014-11-26 16:19:41 -0500 | [diff] [blame] | 42 | EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType); |
Austin Kinross | 2a63b3f | 2016-02-08 12:29:08 -0800 | [diff] [blame] | 43 | EGLPlatformParameters(EGLint renderer, |
| 44 | EGLint majorVersion, |
| 45 | EGLint minorVersion, |
| 46 | EGLint deviceType, |
| 47 | EGLint presentPath); |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 48 | }; |
| 49 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 50 | ANGLE_EXPORT bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b); |
| 51 | ANGLE_EXPORT bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b); |
Geoff Lang | dd323e9 | 2015-06-09 15:16:31 -0400 | [diff] [blame] | 52 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 53 | class ANGLE_EXPORT EGLWindow : angle::NonCopyable |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 54 | { |
| 55 | public: |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 56 | EGLWindow(EGLint glesMajorVersion, |
| 57 | EGLint glesMinorVersion, |
| 58 | const EGLPlatformParameters &platform); |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 59 | |
| 60 | ~EGLWindow(); |
| 61 | |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 62 | void setConfigRedBits(int bits) { mRedBits = bits; } |
| 63 | void setConfigGreenBits(int bits) { mGreenBits = bits; } |
| 64 | void setConfigBlueBits(int bits) { mBlueBits = bits; } |
| 65 | void setConfigAlphaBits(int bits) { mAlphaBits = bits; } |
| 66 | void setConfigDepthBits(int bits) { mDepthBits = bits; } |
| 67 | void setConfigStencilBits(int bits) { mStencilBits = bits; } |
| 68 | void setMultisample(bool multisample) { mMultisample = multisample; } |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 69 | void setDebugEnabled(bool debug) { mDebug = debug; } |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 70 | void setNoErrorEnabled(bool noError) { mNoError = noError; } |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame^] | 71 | void setWebGLCompatibilityEnabled(bool webglCompatibility) |
| 72 | { |
| 73 | mWebGLCompatibility = webglCompatibility; |
| 74 | } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 75 | void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } |
| 76 | |
Cooper Partin | 1bd7dd4 | 2015-06-11 08:58:53 -0700 | [diff] [blame] | 77 | static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); |
| 78 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 79 | void swap(); |
| 80 | |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 81 | EGLint getClientMajorVersion() const { return mClientMajorVersion; } |
| 82 | EGLint getClientMinorVersion() const { return mClientMinorVersion; } |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 83 | const EGLPlatformParameters &getPlatform() const { return mPlatform; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 84 | EGLConfig getConfig() const; |
| 85 | EGLDisplay getDisplay() const; |
| 86 | EGLSurface getSurface() const; |
| 87 | EGLContext getContext() const; |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 88 | int getConfigRedBits() const { return mRedBits; } |
| 89 | int getConfigGreenBits() const { return mGreenBits; } |
| 90 | int getConfigBlueBits() const { return mBlueBits; } |
| 91 | int getConfigAlphaBits() const { return mAlphaBits; } |
| 92 | int getConfigDepthBits() const { return mDepthBits; } |
| 93 | int getConfigStencilBits() const { return mStencilBits; } |
| 94 | bool isMultisample() const { return mMultisample; } |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 95 | bool isDebugEnabled() const { return mDebug; } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 96 | EGLint getSwapInterval() const { return mSwapInterval; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 97 | |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 98 | bool initializeGL(OSWindow *osWindow); |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 99 | void destroyGL(); |
Jamie Madill | 77a72f6 | 2015-04-14 11:18:32 -0400 | [diff] [blame] | 100 | bool isGLInitialized() const; |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 101 | |
| 102 | private: |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 103 | EGLConfig mConfig; |
| 104 | EGLDisplay mDisplay; |
| 105 | EGLSurface mSurface; |
| 106 | EGLContext mContext; |
| 107 | |
Geoff Lang | 5ade845 | 2015-09-02 11:00:30 -0400 | [diff] [blame] | 108 | EGLint mClientMajorVersion; |
| 109 | EGLint mClientMinorVersion; |
Geoff Lang | 0d3683c | 2014-10-23 11:08:16 -0400 | [diff] [blame] | 110 | EGLPlatformParameters mPlatform; |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 111 | int mRedBits; |
| 112 | int mGreenBits; |
| 113 | int mBlueBits; |
| 114 | int mAlphaBits; |
| 115 | int mDepthBits; |
| 116 | int mStencilBits; |
| 117 | bool mMultisample; |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 118 | bool mDebug; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 119 | bool mNoError; |
Geoff Lang | c287ea6 | 2016-09-16 14:46:51 -0400 | [diff] [blame^] | 120 | bool mWebGLCompatibility; |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 121 | EGLint mSwapInterval; |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | #endif // UTIL_EGLWINDOW_H_ |