blob: 30d0ecafc782190020af3011c5f174d41b31576f [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
10#define GL_GLEXT_PROTOTYPES
Geoff Lang63046e22015-07-21 12:43:50 -040011#define EGL_EGLEXT_PROTOTYPES
Jamie Madill1cfaaf82014-08-21 10:04:04 -040012
13#include <GLES3/gl3.h>
14#include <GLES3/gl3ext.h>
15#include <GLES2/gl2.h>
16#include <GLES2/gl2ext.h>
17#include <EGL/egl.h>
18#include <EGL/eglext.h>
19
20#include <string>
21#include <list>
22#include <cstdint>
23#include <memory>
24
Jamie Madill2d1eea02015-03-27 09:46:41 -040025#include "common/angleutils.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040026
27class OSWindow;
28
Jamie Madill19a43db2015-03-20 16:14:04 -040029// A hidden define used in some renderers (currently D3D-only)
30// to init a no-op renderer. Useful for performance testing.
31#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
32#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
33#endif
34
Geoff Lang0d3683c2014-10-23 11:08:16 -040035struct EGLPlatformParameters
36{
37 EGLint renderer;
38 EGLint majorVersion;
39 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050040 EGLint deviceType;
Geoff Lang0d3683c2014-10-23 11:08:16 -040041
42 EGLPlatformParameters();
43 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050044 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Geoff Lang0d3683c2014-10-23 11:08:16 -040045};
46
Geoff Langdd323e92015-06-09 15:16:31 -040047bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Jamie Madill8e695ed2015-06-15 17:00:44 -040048bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040049
Jamie Madill2d1eea02015-03-27 09:46:41 -040050class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040051{
52 public:
Corentin Wallezf3357ee2015-07-22 14:10:19 -040053 EGLWindow(EGLint glesMajorVersion, const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040054
55 ~EGLWindow();
56
Jamie Madill62af5462014-08-26 13:16:37 -040057 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040058 void setConfigRedBits(int bits) { mRedBits = bits; }
59 void setConfigGreenBits(int bits) { mGreenBits = bits; }
60 void setConfigBlueBits(int bits) { mBlueBits = bits; }
61 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
62 void setConfigDepthBits(int bits) { mDepthBits = bits; }
63 void setConfigStencilBits(int bits) { mStencilBits = bits; }
64 void setMultisample(bool multisample) { mMultisample = multisample; }
65 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
66
Cooper Partin1bd7dd42015-06-11 08:58:53 -070067 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
68
Jamie Madill1cfaaf82014-08-21 10:04:04 -040069 void swap();
70
Corentin Wallezfc692932015-05-04 12:53:10 -040071 EGLint getClientVersion() const { return mClientVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040072 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040073 EGLConfig getConfig() const;
74 EGLDisplay getDisplay() const;
75 EGLSurface getSurface() const;
76 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040077 int getConfigRedBits() const { return mRedBits; }
78 int getConfigGreenBits() const { return mGreenBits; }
79 int getConfigBlueBits() const { return mBlueBits; }
80 int getConfigAlphaBits() const { return mAlphaBits; }
81 int getConfigDepthBits() const { return mDepthBits; }
82 int getConfigStencilBits() const { return mStencilBits; }
83 bool isMultisample() const { return mMultisample; }
84 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040085
Austin Kinross18b931d2014-09-29 12:58:31 -070086 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040087 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -040088 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040089
90 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040091 EGLConfig mConfig;
92 EGLDisplay mDisplay;
93 EGLSurface mSurface;
94 EGLContext mContext;
95
Corentin Wallezfc692932015-05-04 12:53:10 -040096 EGLint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -040097 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -040098 int mRedBits;
99 int mGreenBits;
100 int mBlueBits;
101 int mAlphaBits;
102 int mDepthBits;
103 int mStencilBits;
104 bool mMultisample;
105 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400106};
107
108#endif // UTIL_EGLWINDOW_H_