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