blob: 6a5fc5fb9e61cc735f8d77aaa2a488895e0a3008 [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
11
12#include <GLES3/gl3.h>
13#include <GLES3/gl3ext.h>
14#include <GLES2/gl2.h>
15#include <GLES2/gl2ext.h>
16#include <EGL/egl.h>
17#include <EGL/eglext.h>
18
19#include <string>
20#include <list>
21#include <cstdint>
22#include <memory>
23
Jamie Madill2d1eea02015-03-27 09:46:41 -040024#include "common/angleutils.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040025
26class OSWindow;
27
Jamie Madill19a43db2015-03-20 16:14:04 -040028// A hidden define used in some renderers (currently D3D-only)
29// to init a no-op renderer. Useful for performance testing.
30#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
31#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
32#endif
33
Geoff Lang0d3683c2014-10-23 11:08:16 -040034struct EGLPlatformParameters
35{
36 EGLint renderer;
37 EGLint majorVersion;
38 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050039 EGLint deviceType;
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);
Geoff Lang0d3683c2014-10-23 11:08:16 -040044};
45
Geoff Langdd323e92015-06-09 15:16:31 -040046bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Jamie Madill8e695ed2015-06-15 17:00:44 -040047bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040048
Jamie Madill2d1eea02015-03-27 09:46:41 -040049class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040050{
51 public:
Geoff Lang0d3683c2014-10-23 11:08:16 -040052 EGLWindow(size_t width, size_t height, EGLint glesMajorVersion, const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040053
54 ~EGLWindow();
55
Jamie Madill62af5462014-08-26 13:16:37 -040056 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
57 void setWidth(size_t width) { mWidth = width; }
58 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040059 void setConfigRedBits(int bits) { mRedBits = bits; }
60 void setConfigGreenBits(int bits) { mGreenBits = bits; }
61 void setConfigBlueBits(int bits) { mBlueBits = bits; }
62 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
63 void setConfigDepthBits(int bits) { mDepthBits = bits; }
64 void setConfigStencilBits(int bits) { mStencilBits = bits; }
65 void setMultisample(bool multisample) { mMultisample = multisample; }
66 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
67
Cooper Partin1bd7dd42015-06-11 08:58:53 -070068 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
69
Jamie Madill1cfaaf82014-08-21 10:04:04 -040070 void swap();
71
Corentin Wallezfc692932015-05-04 12:53:10 -040072 EGLint getClientVersion() const { return mClientVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040073 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040074 EGLConfig getConfig() const;
75 EGLDisplay getDisplay() const;
76 EGLSurface getSurface() const;
77 EGLContext getContext() const;
78 size_t getWidth() const { return mWidth; }
79 size_t getHeight() const { return mHeight; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040080 int getConfigRedBits() const { return mRedBits; }
81 int getConfigGreenBits() const { return mGreenBits; }
82 int getConfigBlueBits() const { return mBlueBits; }
83 int getConfigAlphaBits() const { return mAlphaBits; }
84 int getConfigDepthBits() const { return mDepthBits; }
85 int getConfigStencilBits() const { return mStencilBits; }
86 bool isMultisample() const { return mMultisample; }
87 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040088
Austin Kinross18b931d2014-09-29 12:58:31 -070089 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040090 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -040091 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040092
93 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040094 EGLConfig mConfig;
95 EGLDisplay mDisplay;
96 EGLSurface mSurface;
97 EGLContext mContext;
98
Corentin Wallezfc692932015-05-04 12:53:10 -040099 EGLint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400100 EGLPlatformParameters mPlatform;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400101 size_t mWidth;
102 size_t mHeight;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400103 int mRedBits;
104 int mGreenBits;
105 int mBlueBits;
106 int mAlphaBits;
107 int mDepthBits;
108 int mStencilBits;
109 bool mMultisample;
110 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400111};
112
113#endif // UTIL_EGLWINDOW_H_