blob: f7c7cbb363f2ef37f6fe101a284e97ab458059eb [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 Madill61a5b332015-03-31 15:35:09 +000024#include "shared_utils.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
Jamie Madill1cfaaf82014-08-21 10:04:04 -040046class EGLWindow
47{
48 public:
Geoff Lang0d3683c2014-10-23 11:08:16 -040049 EGLWindow(size_t width, size_t height, EGLint glesMajorVersion, const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040050
51 ~EGLWindow();
52
Jamie Madill62af5462014-08-26 13:16:37 -040053 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
54 void setWidth(size_t width) { mWidth = width; }
55 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040056 void setConfigRedBits(int bits) { mRedBits = bits; }
57 void setConfigGreenBits(int bits) { mGreenBits = bits; }
58 void setConfigBlueBits(int bits) { mBlueBits = bits; }
59 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
60 void setConfigDepthBits(int bits) { mDepthBits = bits; }
61 void setConfigStencilBits(int bits) { mStencilBits = bits; }
62 void setMultisample(bool multisample) { mMultisample = multisample; }
63 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
64
Jamie Madill1cfaaf82014-08-21 10:04:04 -040065 void swap();
66
Jamie Madill62af5462014-08-26 13:16:37 -040067 GLuint getClientVersion() const { return mClientVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040068 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040069 EGLConfig getConfig() const;
70 EGLDisplay getDisplay() const;
71 EGLSurface getSurface() const;
72 EGLContext getContext() const;
73 size_t getWidth() const { return mWidth; }
74 size_t getHeight() const { return mHeight; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040075 int getConfigRedBits() const { return mRedBits; }
76 int getConfigGreenBits() const { return mGreenBits; }
77 int getConfigBlueBits() const { return mBlueBits; }
78 int getConfigAlphaBits() const { return mAlphaBits; }
79 int getConfigDepthBits() const { return mDepthBits; }
80 int getConfigStencilBits() const { return mStencilBits; }
81 bool isMultisample() const { return mMultisample; }
82 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040083
Austin Kinross18b931d2014-09-29 12:58:31 -070084 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040085 void destroyGL();
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(EGLWindow);
89
90 EGLConfig mConfig;
91 EGLDisplay mDisplay;
92 EGLSurface mSurface;
93 EGLContext mContext;
94
95 GLuint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -040096 EGLPlatformParameters mPlatform;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040097 size_t mWidth;
98 size_t mHeight;
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;
106 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400107};
108
109#endif // UTIL_EGLWINDOW_H_