blob: b3842e2bd2f676d43a09dbf154f343e68482e6d5 [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
Jamie Madill1cfaaf82014-08-21 10:04:04 -040015#include <GLES2/gl2.h>
16#include <GLES2/gl2ext.h>
Corentin Wallez178e5972015-09-14 11:52:44 -070017#include <GLES3/gl3.h>
Jamie Madill1cfaaf82014-08-21 10:04:04 -040018#include <EGL/egl.h>
19#include <EGL/eglext.h>
20
Jamie Madill2d1eea02015-03-27 09:46:41 -040021#include "common/angleutils.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040022
23class OSWindow;
24
Jamie Madill19a43db2015-03-20 16:14:04 -040025// A hidden define used in some renderers (currently D3D-only)
26// to init a no-op renderer. Useful for performance testing.
27#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
28#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
29#endif
30
Geoff Lang0d3683c2014-10-23 11:08:16 -040031struct EGLPlatformParameters
32{
33 EGLint renderer;
34 EGLint majorVersion;
35 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050036 EGLint deviceType;
Geoff Lang0d3683c2014-10-23 11:08:16 -040037
38 EGLPlatformParameters();
39 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050040 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Geoff Lang0d3683c2014-10-23 11:08:16 -040041};
42
Geoff Langdd323e92015-06-09 15:16:31 -040043bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Jamie Madill8e695ed2015-06-15 17:00:44 -040044bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040045
Jamie Madill2d1eea02015-03-27 09:46:41 -040046class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040047{
48 public:
Geoff Lang5ade8452015-09-02 11:00:30 -040049 EGLWindow(EGLint glesMajorVersion,
50 EGLint glesMinorVersion,
51 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040052
53 ~EGLWindow();
54
Jamie Madill3757a5a2014-08-26 13:16:36 -040055 void setConfigRedBits(int bits) { mRedBits = bits; }
56 void setConfigGreenBits(int bits) { mGreenBits = bits; }
57 void setConfigBlueBits(int bits) { mBlueBits = bits; }
58 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
59 void setConfigDepthBits(int bits) { mDepthBits = bits; }
60 void setConfigStencilBits(int bits) { mStencilBits = bits; }
61 void setMultisample(bool multisample) { mMultisample = multisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050062 void setDebugEnabled(bool debug) { mDebug = debug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040063 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
64
Cooper Partin1bd7dd42015-06-11 08:58:53 -070065 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
66
Jamie Madill1cfaaf82014-08-21 10:04:04 -040067 void swap();
68
Geoff Lang5ade8452015-09-02 11:00:30 -040069 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
70 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040071 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040072 EGLConfig getConfig() const;
73 EGLDisplay getDisplay() const;
74 EGLSurface getSurface() const;
75 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040076 int getConfigRedBits() const { return mRedBits; }
77 int getConfigGreenBits() const { return mGreenBits; }
78 int getConfigBlueBits() const { return mBlueBits; }
79 int getConfigAlphaBits() const { return mAlphaBits; }
80 int getConfigDepthBits() const { return mDepthBits; }
81 int getConfigStencilBits() const { return mStencilBits; }
82 bool isMultisample() const { return mMultisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050083 bool isDebugEnabled() const { return mDebug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040084 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
Geoff Lang5ade8452015-09-02 11:00:30 -040096 EGLint mClientMajorVersion;
97 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -040098 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -040099 int mRedBits;
100 int mGreenBits;
101 int mBlueBits;
102 int mAlphaBits;
103 int mDepthBits;
104 int mStencilBits;
105 bool mMultisample;
Geoff Lang70d0f492015-12-10 17:45:46 -0500106 bool mDebug;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400107 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400108};
109
110#endif // UTIL_EGLWINDOW_H_