initial import
[vuplus_webkit] / Source / ThirdParty / ANGLE / src / libEGL / Display.h
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 #ifndef WIN32_LEAN_AND_MEAN
15 #define WIN32_LEAN_AND_MEAN
16 #endif
17 #include <windows.h>
18 #include <d3d9.h>
19
20 #include <set>
21
22 #include "libGLESv2/Context.h"
23
24 #include "libEGL/Config.h"
25 #include "libEGL/Surface.h"
26
27 namespace egl
28 {
29 class Display
30 {
31   public:
32     Display(HDC deviceContext);
33
34     ~Display();
35
36     bool initialize();
37     void terminate();
38
39     virtual void startScene();
40     virtual void endScene();
41
42     bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
43     bool getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value);
44
45     EGLSurface createWindowSurface(HWND window, EGLConfig config, const EGLint *attribList);
46     EGLSurface createOffscreenSurface(EGLConfig config, HANDLE shareHandle, const EGLint *attribList);
47     EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext);
48
49     void destroySurface(egl::Surface *surface);
50     void destroyContext(gl::Context *context);
51
52     bool isInitialized() const;
53     bool isValidConfig(EGLConfig config);
54     bool isValidContext(gl::Context *context);
55     bool isValidSurface(egl::Surface *surface);
56     bool hasExistingWindowSurface(HWND window);
57
58     EGLint getMinSwapInterval();
59     EGLint getMaxSwapInterval();
60
61     virtual IDirect3DDevice9 *getDevice();
62     virtual D3DCAPS9 getDeviceCaps();
63     virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier();
64     bool isDeviceLost();
65     virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
66     virtual bool getCompressedTextureSupport();
67     virtual bool getEventQuerySupport();
68     virtual bool getFloatTextureSupport(bool *filtering, bool *renderable);
69     virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable);
70     virtual bool getLuminanceTextureSupport();
71     virtual bool getLuminanceAlphaTextureSupport();
72     virtual bool getVertexTextureSupport() const;
73     virtual bool getNonPower2TextureSupport() const;
74     virtual D3DPOOL getBufferPool(DWORD usage) const;
75
76     bool isD3d9ExDevice() { return mD3d9Ex != NULL; }
77     const char *getExtensionString() const;
78
79   private:
80     DISALLOW_COPY_AND_ASSIGN(Display);
81
82     D3DPRESENT_PARAMETERS getDefaultPresentParameters();
83
84     const HDC mDc;
85
86     HMODULE mD3d9Module;
87     
88     UINT mAdapter;
89     D3DDEVTYPE mDeviceType;
90     IDirect3D9 *mD3d9;  // Always valid after successful initialization.
91     IDirect3D9Ex *mD3d9Ex;  // Might be null if D3D9Ex is not supported.
92     IDirect3DDevice9 *mDevice;
93     IDirect3DDevice9Ex *mDeviceEx;  // Might be null if D3D9Ex is not supported.
94     D3DCAPS9 mDeviceCaps;
95     D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
96     HWND mDeviceWindow;
97
98     bool mSceneStarted;
99     EGLint mMaxSwapInterval;
100     EGLint mMinSwapInterval;
101     
102     typedef std::set<Surface*> SurfaceSet;
103     SurfaceSet mSurfaceSet;
104
105     ConfigSet mConfigSet;
106
107     typedef std::set<gl::Context*> ContextSet;
108     ContextSet mContextSet;
109
110     bool createDevice();
111     bool resetDevice();
112
113     void initExtensionString();
114     std::string mExtensionString;
115 };
116 }
117
118 #endif   // INCLUDE_DISPLAY_H_