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