blob: c77b2d501d4e960e020cd73867e4140b59f34dc4 [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 Lang5ade8452015-09-02 11:00:30 -040053 EGLWindow(EGLint glesMajorVersion,
54 EGLint glesMinorVersion,
55 const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040056
57 ~EGLWindow();
58
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
Geoff Lang5ade8452015-09-02 11:00:30 -040072 EGLint getClientMajorVersion() const { return mClientMajorVersion; }
73 EGLint getClientMinorVersion() const { return mClientMinorVersion; }
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;
Jamie Madill3757a5a2014-08-26 13:16:36 -040079 int getConfigRedBits() const { return mRedBits; }
80 int getConfigGreenBits() const { return mGreenBits; }
81 int getConfigBlueBits() const { return mBlueBits; }
82 int getConfigAlphaBits() const { return mAlphaBits; }
83 int getConfigDepthBits() const { return mDepthBits; }
84 int getConfigStencilBits() const { return mStencilBits; }
85 bool isMultisample() const { return mMultisample; }
86 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040087
Austin Kinross18b931d2014-09-29 12:58:31 -070088 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040089 void destroyGL();
Jamie Madill77a72f62015-04-14 11:18:32 -040090 bool isGLInitialized() const;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040091
92 private:
Jamie Madill1cfaaf82014-08-21 10:04:04 -040093 EGLConfig mConfig;
94 EGLDisplay mDisplay;
95 EGLSurface mSurface;
96 EGLContext mContext;
97
Geoff Lang5ade8452015-09-02 11:00:30 -040098 EGLint mClientMajorVersion;
99 EGLint mClientMinorVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -0400100 EGLPlatformParameters mPlatform;
Jamie Madill3757a5a2014-08-26 13:16:36 -0400101 int mRedBits;
102 int mGreenBits;
103 int mBlueBits;
104 int mAlphaBits;
105 int mDepthBits;
106 int mStencilBits;
107 bool mMultisample;
108 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400109};
110
111#endif // UTIL_EGLWINDOW_H_