blob: 9651c3c89f2a1563b5e00ca329048598c5862329 [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
Yuly Novikov55033e52016-08-25 17:32:12 +000031struct EGLPlatformParameters
Geoff Lang0d3683c2014-10-23 11:08:16 -040032{
33 EGLint renderer;
34 EGLint majorVersion;
35 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050036 EGLint deviceType;
Austin Kinross2a63b3f2016-02-08 12:29:08 -080037 EGLint presentPath;
Geoff Lang0d3683c2014-10-23 11:08:16 -040038
39 EGLPlatformParameters();
40 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050041 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Austin Kinross2a63b3f2016-02-08 12:29:08 -080042 EGLPlatformParameters(EGLint renderer,
43 EGLint majorVersion,
44 EGLint minorVersion,
45 EGLint deviceType,
46 EGLint presentPath);
Geoff Lang0d3683c2014-10-23 11:08:16 -040047};
48
Yuly Novikov55033e52016-08-25 17:32:12 +000049bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
50bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040051
Yuly Novikov55033e52016-08-25 17:32:12 +000052class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040053{
54 public:
Geoff Lang5ade8452015-09-02 11:00:30 -040055 EGLWindow(EGLint glesMajorVersion,
56 EGLint glesMinorVersion,
57 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040058
59 ~EGLWindow();
60
Jamie Madill3757a5a2014-08-26 13:16:36 -040061 void setConfigRedBits(int bits) { mRedBits = bits; }
62 void setConfigGreenBits(int bits) { mGreenBits = bits; }
63 void setConfigBlueBits(int bits) { mBlueBits = bits; }
64 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
65 void setConfigDepthBits(int bits) { mDepthBits = bits; }
66 void setConfigStencilBits(int bits) { mStencilBits = bits; }
67 void setMultisample(bool multisample) { mMultisample = multisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050068 void setDebugEnabled(bool debug) { mDebug = debug; }
Jamie Madill60ec6ea2016-01-22 15:27:19 -050069 void setNoErrorEnabled(bool noError) { mNoError = noError; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040070 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
71
Cooper Partin1bd7dd42015-06-11 08:58:53 -070072 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
73
Jamie Madill1cfaaf82014-08-21 10:04:04 -040074 void swap();
75
Geoff Lang5ade8452015-09-02 11:00:30 -040076 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
77 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040078 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040079 EGLConfig getConfig() const;
80 EGLDisplay getDisplay() const;
81 EGLSurface getSurface() const;
82 EGLContext getContext() const;
Jamie Madill3757a5a2014-08-26 13:16:36 -040083 int getConfigRedBits() const { return mRedBits; }
84 int getConfigGreenBits() const { return mGreenBits; }
85 int getConfigBlueBits() const { return mBlueBits; }
86 int getConfigAlphaBits() const { return mAlphaBits; }
87 int getConfigDepthBits() const { return mDepthBits; }
88 int getConfigStencilBits() const { return mStencilBits; }
89 bool isMultisample() const { return mMultisample; }
Geoff Lang70d0f492015-12-10 17:45:46 -050090 bool isDebugEnabled() const { return mDebug; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040091 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040092
Austin Kinross18b931d2014-09-29 12:58:31 -070093 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040094 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -040095 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040096
97 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040098 EGLConfig mConfig;
99 EGLDisplay mDisplay;
100 EGLSurface mSurface;
101 EGLContext mContext;
102
Geoff Lang5ade8452015-09-02 11:00:30 -0400103 EGLint mClientMajorVersion;
104 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400105 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400106 int mRedBits;
107 int mGreenBits;
108 int mBlueBits;
109 int mAlphaBits;
110 int mDepthBits;
111 int mStencilBits;
112 bool mMultisample;
Geoff Lang70d0f492015-12-10 17:45:46 -0500113 bool mDebug;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500114 bool mNoError;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400115 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400116};
117
118#endif // UTIL_EGLWINDOW_H_