Home | History | Annotate | Download | only in libEGL
      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 #include <EGL/egl.h>
     15 
     16 #include <set>
     17 
     18 #include "libGLESv2/renderer/Renderer.h"
     19 #include "common/angleutils.h"
     20 
     21 namespace egl
     22 {
     23 class Display;
     24 
     25 class Config
     26 {
     27   public:
     28     Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
     29 
     30     EGLConfig getHandle() const;
     31 
     32     const GLenum mRenderTargetFormat;
     33     const GLenum mDepthStencilFormat;
     34     const GLint mMultiSample;
     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:
     75     explicit SortConfig(const EGLint *attribList);
     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 {
     93     friend Display;
     94 
     95   public:
     96     ConfigSet();
     97 
     98     void add(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
     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 
    103   private:
    104     DISALLOW_COPY_AND_ASSIGN(ConfigSet);
    105 
    106     typedef std::set<Config, SortConfig> Set;
    107     typedef Set::iterator Iterator;
    108     Set mSet;
    109 
    110     static const EGLint mSortAttribs[];
    111 };
    112 }
    113 
    114 #endif   // INCLUDE_CONFIG_H_
    115