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