blob: 250878f0ef439e870f23d78d1651a8405197dbc8 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
shannonwoods@chromium.orgeff3a122013-05-30 00:10:04 +00002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Display.h: Defines the egl::Display class, representing the abstract
8// display on which graphics are drawn. Implements EGLDisplay.
9// [EGL 1.4] section 2.1.2 page 3.
10
apatrick@chromium.org3cfd7222012-07-13 22:36:58 +000011#ifndef LIBEGL_DISPLAY_H_
12#define LIBEGL_DISPLAY_H_
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000013
daniel@transgaming.come6842292010-04-20 18:52:50 +000014#include <set>
apatrick@chromium.orgf289ee82012-01-11 20:03:29 +000015#include <vector>
daniel@transgaming.come6842292010-04-20 18:52:50 +000016
daniel@transgaming.come6842292010-04-20 18:52:50 +000017#include "libEGL/Config.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018
19namespace gl
20{
21class Context;
22}
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000023
24namespace egl
25{
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000026class Surface;
27
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000028class Display
29{
30 public:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000031 ~Display();
32
33 bool initialize();
34 void terminate();
35
Geoff Lang591e6af2014-06-18 18:08:57 -040036 static egl::Display *getDisplay(EGLNativeDisplayType displayId, EGLint displayType);
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000037
Geoff Lang2b5f3b32014-06-18 18:07:49 -040038 static const char *getExtensionString(egl::Display *display);
39
Geoff Lang591e6af2014-06-18 18:08:57 -040040 static bool supportsPlatformD3D();
41 static bool supportsPlatformOpenGL();
42
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000043 bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
44 bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
45
jbauman@chromium.org06d7a752011-04-30 01:02:52 +000046 EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
jbauman@chromium.org4e297702011-05-12 23:04:07 +000047 EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
shannon.woods%transgaming.com@gtempaccount.comdaea4b42013-04-13 03:28:54 +000048 EGLContext createContext(EGLConfig configHandle, EGLint clientVersion, const gl::Context *shareContext, bool notifyResets, bool robustAccess);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049
50 void destroySurface(egl::Surface *surface);
51 void destroyContext(gl::Context *context);
52
daniel@transgaming.com3b1703f2011-05-11 15:36:26 +000053 bool isInitialized() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000054 bool isValidConfig(EGLConfig config);
55 bool isValidContext(gl::Context *context);
56 bool isValidSurface(egl::Surface *surface);
57 bool hasExistingWindowSurface(HWND window);
58
daniel@transgaming.com76d3e6e2012-10-31 19:55:33 +000059 rx::Renderer *getRenderer() { return mRenderer; };
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000060
shannon.woods%transgaming.com@gtempaccount.com8bce3f52013-04-13 03:35:32 +000061 // exported methods must be virtual
daniel@transgaming.com09fcc9f2011-11-09 17:46:47 +000062 virtual void notifyDeviceLost();
shannon.woods%transgaming.com@gtempaccount.com8bce3f52013-04-13 03:35:32 +000063 virtual void recreateSwapChains();
daniel@transgaming.com09fcc9f2011-11-09 17:46:47 +000064
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +000065 const char *getExtensionString() const;
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +000066 const char *getVendorString() const;
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +000067
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 private:
69 DISALLOW_COPY_AND_ASSIGN(Display);
daniel@transgaming.comd36c6a02010-08-31 12:15:09 +000070
Geoff Lang591e6af2014-06-18 18:08:57 -040071 Display(EGLNativeDisplayType displayId, EGLint displayType);
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000072
vangelis@google.com8c9c4522011-09-09 18:22:28 +000073 bool restoreLostDevice();
74
jbauman@chromium.org84d7cbc2011-07-14 22:53:19 +000075 EGLNativeDisplayType mDisplayId;
Geoff Lang591e6af2014-06-18 18:08:57 -040076 EGLint mRequestedDisplayType;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000078 typedef std::set<Surface*> SurfaceSet;
79 SurfaceSet mSurfaceSet;
80
81 ConfigSet mConfigSet;
82
83 typedef std::set<gl::Context*> ContextSet;
84 ContextSet mContextSet;
daniel@transgaming.comda6e2632010-07-28 19:21:18 +000085
daniel@transgaming.com76d3e6e2012-10-31 19:55:33 +000086 rx::Renderer *mRenderer;
vladimirv@gmail.com721b7f22011-02-11 00:54:47 +000087
Geoff Lang2b5f3b32014-06-18 18:07:49 -040088 static std::string generateClientExtensionString();
89
90 void initDisplayExtensionString();
91 std::string mDisplayExtensionString;
92
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +000093 void initVendorString();
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +000094 std::string mVendorString;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000095};
96}
97
apatrick@chromium.org3cfd7222012-07-13 22:36:58 +000098#endif // LIBEGL_DISPLAY_H_