John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (c) 2002-2011 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 | // 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 | |
| 11 | #ifndef INCLUDE_DISPLAY_H_ |
| 12 | #define INCLUDE_DISPLAY_H_ |
| 13 | |
| 14 | #include "Config.h" |
| 15 | #include "Surface.h" |
| 16 | #include "libGLESv2/Context.h" |
| 17 | #include "libGLESv2/Device.hpp" |
| 18 | |
| 19 | #ifndef WIN32_LEAN_AND_MEAN |
| 20 | #define WIN32_LEAN_AND_MEAN |
| 21 | #endif |
| 22 | #include <windows.h> |
| 23 | #include <set> |
| 24 | |
| 25 | namespace sw |
| 26 | { |
| 27 | class Context; |
| 28 | } |
| 29 | |
| 30 | namespace egl |
| 31 | { |
| 32 | class Display |
| 33 | { |
| 34 | public: |
| 35 | ~Display(); |
| 36 | |
| 37 | static egl::Display *getDisplay(EGLNativeDisplayType displayId); |
| 38 | |
| 39 | bool initialize(); |
| 40 | void terminate(); |
| 41 | |
| 42 | virtual void startScene() {}; // FIXME: Remove when Chrome no longer calls getDevice() directly |
| 43 | virtual void endScene() {}; // FIXME: Remove when Chrome no longer calls getDevice() directly |
| 44 | |
| 45 | bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); |
| 46 | bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value); |
| 47 | |
| 48 | EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList); |
| 49 | EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList); |
| 50 | EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext); |
| 51 | |
| 52 | void destroySurface(egl::Surface *surface); |
| 53 | void destroyContext(gl::Context *context); |
| 54 | |
| 55 | bool isInitialized() const; |
| 56 | bool isValidConfig(EGLConfig config); |
| 57 | bool isValidContext(gl::Context *context); |
| 58 | bool isValidSurface(egl::Surface *surface); |
| 59 | bool hasExistingWindowSurface(HWND window); |
| 60 | |
| 61 | EGLint getMinSwapInterval(); |
| 62 | EGLint getMaxSwapInterval(); |
| 63 | |
| 64 | virtual gl::Device *getDeviceChrome() {return 0;}; // FIXME: Remove when Chrome no longer calls getDevice() directly |
| 65 | virtual gl::Device *getDevice(); |
| 66 | |
| 67 | const char *getExtensionString() const; |
| 68 | |
| 69 | private: |
| 70 | Display(EGLNativeDisplayType displayId); |
| 71 | |
| 72 | const EGLNativeDisplayType displayId; |
| 73 | gl::Device *mDevice; |
| 74 | |
| 75 | EGLint mMaxSwapInterval; |
| 76 | EGLint mMinSwapInterval; |
| 77 | |
| 78 | typedef std::set<Surface*> SurfaceSet; |
| 79 | SurfaceSet mSurfaceSet; |
| 80 | |
| 81 | ConfigSet mConfigSet; |
| 82 | |
| 83 | typedef std::set<gl::Context*> ContextSet; |
| 84 | ContextSet mContextSet; |
| 85 | |
| 86 | bool createDevice(); |
| 87 | |
| 88 | void initExtensionString(); |
| 89 | std::string mExtensionString; |
| 90 | }; |
| 91 | } |
| 92 | |
| 93 | #endif // INCLUDE_DISPLAY_H_ |