• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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.5] section 3.4 page 19.
10 
11 #ifndef INCLUDE_CONFIG_H_
12 #define INCLUDE_CONFIG_H_
13 
14 #include "libANGLE/AttributeMap.h"
15 
16 #include "common/angleutils.h"
17 
18 #include <EGL/egl.h>
19 #include <GLES2/gl2.h>
20 
21 #include <map>
22 #include <vector>
23 
24 namespace egl
25 {
26 
27 struct Config
28 {
29     Config();
30     ~Config();
31     Config(const Config &other);
32     Config &operator=(const Config &other);
33 
34     GLenum renderTargetFormat;  // TODO(geofflang): remove this
35     GLenum depthStencilFormat;  // TODO(geofflang): remove this
36 
37     EGLint bufferSize;             // Depth of the color buffer
38     EGLint redSize;                // Bits of Red in the color buffer
39     EGLint greenSize;              // Bits of Green in the color buffer
40     EGLint blueSize;               // Bits of Blue in the color buffer
41     EGLint luminanceSize;          // Bits of Luminance in the color buffer
42     EGLint alphaSize;              // Bits of Alpha in the color buffer
43     EGLint alphaMaskSize;          // Bits of Alpha Mask in the mask buffer
44     EGLBoolean bindToTextureRGB;   // True if bindable to RGB textures.
45     EGLBoolean bindToTextureRGBA;  // True if bindable to RGBA textures.
46     EGLenum bindToTextureTarget;   // Which texture target should be used for pbuffers
47     EGLenum colorBufferType;       // Color buffer type
48     EGLenum configCaveat;          // Any caveats for the configuration
49     EGLint configID;               // Unique EGLConfig identifier
50     EGLint conformant;             // Whether contexts created with this config are conformant
51     EGLint depthSize;              // Bits of Z in the depth buffer
52     EGLint level;                  // Frame buffer level
53     EGLBoolean matchNativePixmap;  // Match the native pixmap format
54     EGLint maxPBufferWidth;        // Maximum width of pbuffer
55     EGLint maxPBufferHeight;       // Maximum height of pbuffer
56     EGLint maxPBufferPixels;       // Maximum size of pbuffer
57     EGLint maxSwapInterval;        // Maximum swap interval
58     EGLint minSwapInterval;        // Minimum swap interval
59     EGLBoolean nativeRenderable;   // EGL_TRUE if native rendering APIs can render to surface
60     EGLint nativeVisualID;         // Handle of corresponding native visual
61     EGLint nativeVisualType;       // Native visual type of the associated visual
62     EGLint renderableType;         // Which client rendering APIs are supported.
63     EGLint sampleBuffers;          // Number of multisample buffers
64     EGLint samples;                // Number of samples per pixel
65     EGLint stencilSize;            // Bits of Stencil in the stencil buffer
66     EGLint surfaceType;            // Which types of EGL surfaces are supported.
67     EGLenum transparentType;       // Type of transparency supported
68     EGLint transparentRedValue;    // Transparent red value
69     EGLint transparentGreenValue;  // Transparent green value
70     EGLint transparentBlueValue;   // Transparent blue value
71     EGLint optimalOrientation;     // Optimal window surface orientation
72     EGLenum colorComponentType;    // Color component type
73     EGLBoolean recordable;         // EGL_TRUE if a surface can support recording on Android
74     EGLBoolean framebufferTarget;  // EGL_TRUE if the config supports rendering to a ANativeWindow
75                                    // for which the buffers are passed to the HWComposer HAL as a
76                                    // framebuffer target layer.
77     EGLBoolean yInverted;  // True if the drawable's framebuffer is y-inverted.  This can be used to
78                            // determine if y-inverted texture coordinates need to be used when
79                            // texturing from this drawable when it is bound to a texture target.
80 };
81 
82 class ConfigSet
83 {
84   private:
85     typedef std::map<EGLint, Config> ConfigMap;
86 
87   public:
88     ConfigSet();
89     ConfigSet(const ConfigSet &other);
90     ~ConfigSet();
91     ConfigSet &operator=(const ConfigSet &other);
92 
93     EGLint add(const Config &config);
94     const Config &get(EGLint id) const;
95 
96     void clear();
97 
98     size_t size() const;
99 
100     bool contains(const Config *config) const;
101 
102     // Filter configurations based on the table in [EGL 1.5] section 3.4.1.2 page 29
103     std::vector<const Config *> filter(const AttributeMap &attributeMap) const;
104 
105     ConfigMap::iterator begin();
106     ConfigMap::iterator end();
107 
108   private:
109     ConfigMap mConfigs;
110 };
111 
112 }  // namespace egl
113 
114 #endif  // INCLUDE_CONFIG_H_
115