blob: fa6c43a9c88a6ce1c13bcc5765412ffdd2f8ba3e [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
Jamie Madill2d1eea02015-03-27 09:46:41 -040046class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040047{
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:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040088 EGLConfig mConfig;
89 EGLDisplay mDisplay;
90 EGLSurface mSurface;
91 EGLContext mContext;
92
93 GLuint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -040094 EGLPlatformParameters mPlatform;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040095 size_t mWidth;
96 size_t mHeight;
Jamie Madill3757a5a2014-08-26 13:16:36 -040097 int mRedBits;
98 int mGreenBits;
99 int mBlueBits;
100 int mAlphaBits;
101 int mDepthBits;
102 int mStencilBits;
103 bool mMultisample;
104 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400105};
106
107#endif // UTIL_EGLWINDOW_H_