• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2002-2010 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     egl::Surface *createWindowSurface(HWND window, EGLConfig config);
46     EGLContext createContext(EGLConfig configHandle, const gl::Context *shareContext);
47 
48     void destroySurface(egl::Surface *surface);
49     void destroyContext(gl::Context *context);
50 
51     bool isInitialized();
52     bool isValidConfig(EGLConfig config);
53     bool isValidContext(gl::Context *context);
54     bool isValidSurface(egl::Surface *surface);
55     bool hasExistingWindowSurface(HWND window);
56 
57     EGLint getMinSwapInterval();
58     EGLint getMaxSwapInterval();
59 
60     virtual IDirect3DDevice9 *getDevice();
61     virtual D3DCAPS9 getDeviceCaps();
62     virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
63     virtual bool getCompressedTextureSupport();
64     virtual bool getEventQuerySupport();
65     virtual bool getFloatTextureSupport(bool *filtering, bool *renderable);
66     virtual bool getHalfFloatTextureSupport(bool *filtering, bool *renderable);
67     virtual bool getLuminanceTextureSupport();
68     virtual bool getLuminanceAlphaTextureSupport();
69     virtual D3DPOOL getBufferPool(DWORD usage) const;
70 
71   private:
72     DISALLOW_COPY_AND_ASSIGN(Display);
73 
74     D3DPRESENT_PARAMETERS getDefaultPresentParameters();
75 
76     const HDC mDc;
77 
78     HMODULE mD3d9Module;
79 
80     UINT mAdapter;
81     D3DDEVTYPE mDeviceType;
82     IDirect3D9 *mD3d9;  // Always valid after successful initialization.
83     IDirect3D9Ex *mD3d9ex;  // Might be null if D3D9Ex is not supported.
84     IDirect3DDevice9 *mDevice;
85     D3DCAPS9 mDeviceCaps;
86     HWND mDeviceWindow;
87 
88     bool mSceneStarted;
89     EGLint mMaxSwapInterval;
90     EGLint mMinSwapInterval;
91 
92     typedef std::set<Surface*> SurfaceSet;
93     SurfaceSet mSurfaceSet;
94 
95     ConfigSet mConfigSet;
96 
97     typedef std::set<gl::Context*> ContextSet;
98     ContextSet mContextSet;
99 
100     bool createDevice();
101     bool resetDevice();
102 };
103 }
104 
105 #endif   // INCLUDE_DISPLAY_H_
106