blob: 5da5993ec2aafae4a6831cbe5f080300951d100a [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
Geoff Lang63046e22015-07-21 12:43:50 -040011#define EGL_EGLEXT_PROTOTYPES
Jamie Madill1cfaaf82014-08-21 10:04:04 -040012
13#include <GLES3/gl3.h>
14#include <GLES3/gl3ext.h>
15#include <GLES2/gl2.h>
16#include <GLES2/gl2ext.h>
17#include <EGL/egl.h>
18#include <EGL/eglext.h>
19
20#include <string>
21#include <list>
22#include <cstdint>
23#include <memory>
24
Jamie Madill2d1eea02015-03-27 09:46:41 -040025#include "common/angleutils.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040026
27class OSWindow;
28
Jamie Madill19a43db2015-03-20 16:14:04 -040029// A hidden define used in some renderers (currently D3D-only)
30// to init a no-op renderer. Useful for performance testing.
31#ifndef EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE
32#define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
33#endif
34
Geoff Lang0d3683c2014-10-23 11:08:16 -040035struct EGLPlatformParameters
36{
37 EGLint renderer;
38 EGLint majorVersion;
39 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050040 EGLint deviceType;
Geoff Lang0d3683c2014-10-23 11:08:16 -040041
42 EGLPlatformParameters();
43 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050044 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Geoff Lang0d3683c2014-10-23 11:08:16 -040045};
46
Geoff Langdd323e92015-06-09 15:16:31 -040047bool operator<(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Jamie Madill8e695ed2015-06-15 17:00:44 -040048bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b);
Geoff Langdd323e92015-06-09 15:16:31 -040049
Jamie Madill2d1eea02015-03-27 09:46:41 -040050class EGLWindow : angle::NonCopyable
Jamie Madill1cfaaf82014-08-21 10:04:04 -040051{
52 public:
Geoff Lang0d3683c2014-10-23 11:08:16 -040053 EGLWindow(size_t width, size_t height, EGLint glesMajorVersion, const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040054
55 ~EGLWindow();
56
Jamie Madill62af5462014-08-26 13:16:37 -040057 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
58 void setWidth(size_t width) { mWidth = width; }
59 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040060 void setConfigRedBits(int bits) { mRedBits = bits; }
61 void setConfigGreenBits(int bits) { mGreenBits = bits; }
62 void setConfigBlueBits(int bits) { mBlueBits = bits; }
63 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
64 void setConfigDepthBits(int bits) { mDepthBits = bits; }
65 void setConfigStencilBits(int bits) { mStencilBits = bits; }
66 void setMultisample(bool multisample) { mMultisample = multisample; }
67 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
68
Cooper Partin1bd7dd42015-06-11 08:58:53 -070069 static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
70
Jamie Madill1cfaaf82014-08-21 10:04:04 -040071 void swap();
72
Corentin Wallezfc692932015-05-04 12:53:10 -040073 EGLint getClientVersion() const { return mClientVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040074 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040075 EGLConfig getConfig() const;
76 EGLDisplay getDisplay() const;
77 EGLSurface getSurface() const;
78 EGLContext getContext() const;
79 size_t getWidth() const { return mWidth; }
80 size_t getHeight() const { return mHeight; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040081 int getConfigRedBits() const { return mRedBits; }
82 int getConfigGreenBits() const { return mGreenBits; }
83 int getConfigBlueBits() const { return mBlueBits; }
84 int getConfigAlphaBits() const { return mAlphaBits; }
85 int getConfigDepthBits() const { return mDepthBits; }
86 int getConfigStencilBits() const { return mStencilBits; }
87 bool isMultisample() const { return mMultisample; }
88 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040089
Austin Kinross18b931d2014-09-29 12:58:31 -070090 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040091 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -040092 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040093
94 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040095 EGLConfig mConfig;
96 EGLDisplay mDisplay;
97 EGLSurface mSurface;
98 EGLContext mContext;
99
Corentin Wallezfc692932015-05-04 12:53:10 -0400100 EGLint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400101 EGLPlatformParameters mPlatform;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400102 size_t mWidth;
103 size_t mHeight;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400104 int mRedBits;
105 int mGreenBits;
106 int mBlueBits;
107 int mAlphaBits;
108 int mDepthBits;
109 int mStencilBits;
110 bool mMultisample;
111 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400112};
113
114#endif // UTIL_EGLWINDOW_H_