blob: 2033ecadfa1f440e59f6a65d6e77d6bc3ee62363 [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 Madill0448ec82016-12-23 13:41:47 -050023#include "common/Optional.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040024
25class OSWindow;
26
Jamie Madill19a43db2015-03-20 16:14:04 -040027// A hidden define used in some renderers (currently D3D-only)
28// to init a no-op renderer. Useful for performance testing.
29#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
30#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
31#endif
32
Yuly Novikove3352f92016-08-12 20:40:14 -040033struct ANGLE_EXPORT EGLPlatformParameters
Geoff Lang0d3683c2014-10-23 11:08:16 -040034{
35 EGLint renderer;
36 EGLint majorVersion;
37 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050038 EGLint deviceType;
Austin Kinross2a63b3f2016-02-08 12:29:08 -080039 EGLint presentPath;
Geoff Lang0d3683c2014-10-23 11:08:16 -040040
41 EGLPlatformParameters();
42 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050043 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Austin Kinross2a63b3f2016-02-08 12:29:08 -080044 EGLPlatformParameters(EGLint renderer,
45 EGLint majorVersion,
46 EGLint minorVersion,
47 EGLint deviceType,
48 EGLint presentPath);
Geoff Lang0d3683c2014-10-23 11:08:16 -040049};
50
Yuly Novikove3352f92016-08-12 20:40:14 -040051ANGLE_EXPORT bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
52ANGLE_EXPORT bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040053
Yuly Novikove3352f92016-08-12 20:40:14 -040054class ANGLE_EXPORT EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040055{
56 public:
Geoff Lang5ade8452015-09-02 11:00:30 -040057 EGLWindow(EGLint glesMajorVersion,
58 EGLint glesMinorVersion,
59 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040060
61 ~EGLWindow();
62
Jamie Madill3757a5a2014-08-26 13:16:36 -040063 void setConfigRedBits(int bits) { mRedBits = bits; }
64 void setConfigGreenBits(int bits) { mGreenBits = bits; }
65 void setConfigBlueBits(int bits) { mBlueBits = bits; }
66 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
67 void setConfigDepthBits(int bits) { mDepthBits = bits; }
68 void setConfigStencilBits(int bits) { mStencilBits = bits; }
69 void setMultisample(bool multisample) { mMultisample = multisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050070 void setDebugEnabled(bool debug) { mDebug = debug; }
Jamie Madill60ec6ea2016-01-22 15:27:19 -050071 void setNoErrorEnabled(bool noError) { mNoError = noError; }
Geoff Langc287ea62016-09-16 14:46:51 -040072 void setWebGLCompatibilityEnabled(bool webglCompatibility)
73 {
74 mWebGLCompatibility = webglCompatibility;
75 }
Geoff Langf41a7152016-09-19 15:11:17 -040076 void setBindGeneratesResource(bool bindGeneratesResource)
77 {
78 mBindGeneratesResource = bindGeneratesResource;
79 }
Jamie Madill0448ec82016-12-23 13:41:47 -050080 void setVulkanLayersEnabled(bool enabled) { mVulkanLayersEnabled = enabled; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040081 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
82
Cooper Partin1bd7dd42015-06-11 08:58:53 -070083 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
84
Jamie Madill1cfaaf82014-08-21 10:04:04 -040085 void swap();
86
Geoff Lang5ade8452015-09-02 11:00:30 -040087 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
88 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040089 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040090 EGLConfig getConfig() const;
91 EGLDisplay getDisplay() const;
92 EGLSurface getSurface() const;
93 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040094 int getConfigRedBits() const { return mRedBits; }
95 int getConfigGreenBits() const { return mGreenBits; }
96 int getConfigBlueBits() const { return mBlueBits; }
97 int getConfigAlphaBits() const { return mAlphaBits; }
98 int getConfigDepthBits() const { return mDepthBits; }
99 int getConfigStencilBits() const { return mStencilBits; }
100 bool isMultisample() const { return mMultisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -0500101 bool isDebugEnabled() const { return mDebug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -0400102 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400103
Austin Kinross18b931d2014-09-29 12:58:31 -0700104 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400105 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -0400106 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400107
108 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400109 EGLConfig mConfig;
110 EGLDisplay mDisplay;
111 EGLSurface mSurface;
112 EGLContext mContext;
113
Geoff Lang5ade8452015-09-02 11:00:30 -0400114 EGLint mClientMajorVersion;
115 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400116 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400117 int mRedBits;
118 int mGreenBits;
119 int mBlueBits;
120 int mAlphaBits;
121 int mDepthBits;
122 int mStencilBits;
123 bool mMultisample;
Geoff Lang70d0f492015-12-10 17:45:46 -0500124 bool mDebug;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500125 bool mNoError;
Geoff Langc287ea62016-09-16 14:46:51 -0400126 bool mWebGLCompatibility;
Geoff Langf41a7152016-09-19 15:11:17 -0400127 bool mBindGeneratesResource;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400128 EGLint mSwapInterval;
Jamie Madill0448ec82016-12-23 13:41:47 -0500129 Optional<bool> mVulkanLayersEnabled;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400130};
131
132#endif // UTIL_EGLWINDOW_H_