blob: 11b647038845c1950e7e48ccb39012b88dd1caf8 [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 Madill1cfaaf82014-08-21 10:04:04 -040023
24class OSWindow;
25
Jamie Madill19a43db2015-03-20 16:14:04 -040026// 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 Novikove3352f92016-08-12 20:40:14 -040032struct ANGLE_EXPORT EGLPlatformParameters
Geoff Lang0d3683c2014-10-23 11:08:16 -040033{
34 EGLint renderer;
35 EGLint majorVersion;
36 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050037 EGLint deviceType;
Austin Kinross2a63b3f2016-02-08 12:29:08 -080038 EGLint presentPath;
Geoff Lang0d3683c2014-10-23 11:08:16 -040039
40 EGLPlatformParameters();
41 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050042 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Austin Kinross2a63b3f2016-02-08 12:29:08 -080043 EGLPlatformParameters(EGLint renderer,
44 EGLint majorVersion,
45 EGLint minorVersion,
46 EGLint deviceType,
47 EGLint presentPath);
Geoff Lang0d3683c2014-10-23 11:08:16 -040048};
49
Yuly Novikove3352f92016-08-12 20:40:14 -040050ANGLE_EXPORT bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
51ANGLE_EXPORT bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040052
Yuly Novikove3352f92016-08-12 20:40:14 -040053class ANGLE_EXPORT EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040054{
55 public:
Geoff Lang5ade8452015-09-02 11:00:30 -040056 EGLWindow(EGLint glesMajorVersion,
57 EGLint glesMinorVersion,
58 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040059
60 ~EGLWindow();
61
Jamie Madill3757a5a2014-08-26 13:16:36 -040062 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 Lang70d0f492015-12-10 17:45:46 -050069 void setDebugEnabled(bool debug) { mDebug = debug; }
Jamie Madill60ec6ea2016-01-22 15:27:19 -050070 void setNoErrorEnabled(bool noError) { mNoError = noError; }
Geoff Langc287ea62016-09-16 14:46:51 -040071 void setWebGLCompatibilityEnabled(bool webglCompatibility)
72 {
73 mWebGLCompatibility = webglCompatibility;
74 }
Jamie Madill3757a5a2014-08-26 13:16:36 -040075 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
76
Cooper Partin1bd7dd42015-06-11 08:58:53 -070077 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
78
Jamie Madill1cfaaf82014-08-21 10:04:04 -040079 void swap();
80
Geoff Lang5ade8452015-09-02 11:00:30 -040081 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
82 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040083 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040084 EGLConfig getConfig() const;
85 EGLDisplay getDisplay() const;
86 EGLSurface getSurface() const;
87 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040088 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 Lang70d0f492015-12-10 17:45:46 -050095 bool isDebugEnabled() const { return mDebug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040096 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040097
Austin Kinross18b931d2014-09-29 12:58:31 -070098 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040099 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -0400100 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400101
102 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400103 EGLConfig mConfig;
104 EGLDisplay mDisplay;
105 EGLSurface mSurface;
106 EGLContext mContext;
107
Geoff Lang5ade8452015-09-02 11:00:30 -0400108 EGLint mClientMajorVersion;
109 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400110 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400111 int mRedBits;
112 int mGreenBits;
113 int mBlueBits;
114 int mAlphaBits;
115 int mDepthBits;
116 int mStencilBits;
117 bool mMultisample;
Geoff Lang70d0f492015-12-10 17:45:46 -0500118 bool mDebug;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500119 bool mNoError;
Geoff Langc287ea62016-09-16 14:46:51 -0400120 bool mWebGLCompatibility;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400121 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400122};
123
124#endif // UTIL_EGLWINDOW_H_