|
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 // Config.h: Defines the egl::Config class, describing the format, type |
|
8 // and size for an egl::Surface. Implements EGLConfig and related functionality. |
|
9 // [EGL 1.4] section 3.4 page 15. |
|
10 |
|
11 #ifndef INCLUDE_CONFIG_H_ |
|
12 #define INCLUDE_CONFIG_H_ |
|
13 |
|
14 #define EGLAPI |
|
15 #include <EGL/egl.h> |
|
16 |
|
17 #include <set> |
|
18 |
|
19 #include "libGLESv2/renderer/Renderer.h" |
|
20 #include "common/angleutils.h" |
|
21 |
|
22 namespace egl |
|
23 { |
|
24 class Display; |
|
25 |
|
26 class Config |
|
27 { |
|
28 public: |
|
29 Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight); |
|
30 |
|
31 EGLConfig getHandle() const; |
|
32 |
|
33 const GLenum mRenderTargetFormat; |
|
34 const GLenum mDepthStencilFormat; |
|
35 const GLint mMultiSample; |
|
36 |
|
37 EGLint mBufferSize; // Depth of the color buffer |
|
38 EGLint mRedSize; // Bits of Red in the color buffer |
|
39 EGLint mGreenSize; // Bits of Green in the color buffer |
|
40 EGLint mBlueSize; // Bits of Blue in the color buffer |
|
41 EGLint mLuminanceSize; // Bits of Luminance in the color buffer |
|
42 EGLint mAlphaSize; // Bits of Alpha in the color buffer |
|
43 EGLint mAlphaMaskSize; // Bits of Alpha Mask in the mask buffer |
|
44 EGLBoolean mBindToTextureRGB; // True if bindable to RGB textures. |
|
45 EGLBoolean mBindToTextureRGBA; // True if bindable to RGBA textures. |
|
46 EGLenum mColorBufferType; // Color buffer type |
|
47 EGLenum mConfigCaveat; // Any caveats for the configuration |
|
48 EGLint mConfigID; // Unique EGLConfig identifier |
|
49 EGLint mConformant; // Whether contexts created with this config are conformant |
|
50 EGLint mDepthSize; // Bits of Z in the depth buffer |
|
51 EGLint mLevel; // Frame buffer level |
|
52 EGLBoolean mMatchNativePixmap; // Match the native pixmap format |
|
53 EGLint mMaxPBufferWidth; // Maximum width of pbuffer |
|
54 EGLint mMaxPBufferHeight; // Maximum height of pbuffer |
|
55 EGLint mMaxPBufferPixels; // Maximum size of pbuffer |
|
56 EGLint mMaxSwapInterval; // Maximum swap interval |
|
57 EGLint mMinSwapInterval; // Minimum swap interval |
|
58 EGLBoolean mNativeRenderable; // EGL_TRUE if native rendering APIs can render to surface |
|
59 EGLint mNativeVisualID; // Handle of corresponding native visual |
|
60 EGLint mNativeVisualType; // Native visual type of the associated visual |
|
61 EGLint mRenderableType; // Which client rendering APIs are supported. |
|
62 EGLint mSampleBuffers; // Number of multisample buffers |
|
63 EGLint mSamples; // Number of samples per pixel |
|
64 EGLint mStencilSize; // Bits of Stencil in the stencil buffer |
|
65 EGLint mSurfaceType; // Which types of EGL surfaces are supported. |
|
66 EGLenum mTransparentType; // Type of transparency supported |
|
67 EGLint mTransparentRedValue; // Transparent red value |
|
68 EGLint mTransparentGreenValue; // Transparent green value |
|
69 EGLint mTransparentBlueValue; // Transparent blue value |
|
70 }; |
|
71 |
|
72 // Function object used by STL sorting routines for ordering Configs according to [EGL] section 3.4.1 page 24. |
|
73 class SortConfig |
|
74 { |
|
75 public: |
|
76 explicit SortConfig(const EGLint *attribList); |
|
77 |
|
78 bool operator()(const Config *x, const Config *y) const; |
|
79 bool operator()(const Config &x, const Config &y) const; |
|
80 |
|
81 private: |
|
82 void scanForWantedComponents(const EGLint *attribList); |
|
83 EGLint wantedComponentsSize(const Config &config) const; |
|
84 |
|
85 bool mWantRed; |
|
86 bool mWantGreen; |
|
87 bool mWantBlue; |
|
88 bool mWantAlpha; |
|
89 bool mWantLuminance; |
|
90 }; |
|
91 |
|
92 class ConfigSet |
|
93 { |
|
94 friend Display; |
|
95 |
|
96 public: |
|
97 ConfigSet(); |
|
98 |
|
99 void add(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight); |
|
100 size_t size() const; |
|
101 bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); |
|
102 const egl::Config *get(EGLConfig configHandle); |
|
103 |
|
104 private: |
|
105 DISALLOW_COPY_AND_ASSIGN(ConfigSet); |
|
106 |
|
107 typedef std::set<Config, SortConfig> Set; |
|
108 typedef Set::iterator Iterator; |
|
109 Set mSet; |
|
110 |
|
111 static const EGLint mSortAttribs[]; |
|
112 }; |
|
113 } |
|
114 |
|
115 #endif // INCLUDE_CONFIG_H_ |