Home | History | Annotate | Download | only in libEGL
      1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //    http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 // Config.h: Defines the egl::Config class, describing the format, type
     16 // and size for an egl::Surface. Implements EGLConfig and related functionality.
     17 // [EGL 1.4] section 3.4 page 15.
     18 
     19 #ifndef INCLUDE_CONFIG_H_
     20 #define INCLUDE_CONFIG_H_
     21 
     22 #include "Renderer/Surface.hpp"
     23 
     24 #include <EGL/egl.h>
     25 
     26 #include <set>
     27 
     28 namespace egl
     29 {
     30 class Display;
     31 
     32 class Config
     33 {
     34 public:
     35 	Config(sw::Format displayFormat, EGLint minSwapInterval, EGLint maxSwapInterval, sw::Format renderTargetFormat, sw::Format depthStencilFormat, EGLint multiSample);
     36 
     37 	EGLConfig getHandle() const;
     38 
     39 	const sw::Format mRenderTargetFormat;
     40 	const sw::Format mDepthStencilFormat;
     41 	const EGLint mMultiSample;
     42 
     43 	EGLint mBufferSize;              // Depth of the color buffer
     44 	EGLint mRedSize;                 // Bits of Red in the color buffer
     45 	EGLint mGreenSize;               // Bits of Green in the color buffer
     46 	EGLint mBlueSize;                // Bits of Blue in the color buffer
     47 	EGLint mLuminanceSize;           // Bits of Luminance in the color buffer
     48 	EGLint mAlphaSize;               // Bits of Alpha in the color buffer
     49 	EGLint mAlphaMaskSize;           // Bits of Alpha Mask in the mask buffer
     50 	EGLBoolean mBindToTextureRGB;    // True if bindable to RGB textures.
     51 	EGLBoolean mBindToTextureRGBA;   // True if bindable to RGBA textures.
     52 	EGLenum mColorBufferType;        // Color buffer type
     53 	EGLenum mConfigCaveat;           // Any caveats for the configuration
     54 	EGLint mConfigID;                // Unique EGLConfig identifier
     55 	EGLint mConformant;              // Whether contexts created with this config are conformant
     56 	EGLint mDepthSize;               // Bits of Z in the depth buffer
     57 	EGLint mLevel;                   // Frame buffer level
     58 	EGLBoolean mMatchNativePixmap;   // Match the native pixmap format
     59 	EGLint mMaxPBufferWidth;         // Maximum width of pbuffer
     60 	EGLint mMaxPBufferHeight;        // Maximum height of pbuffer
     61 	EGLint mMaxPBufferPixels;        // Maximum size of pbuffer
     62 	EGLint mMaxSwapInterval;         // Maximum swap interval
     63 	EGLint mMinSwapInterval;         // Minimum swap interval
     64 	EGLBoolean mNativeRenderable;    // EGL_TRUE if native rendering APIs can render to surface
     65 	EGLint mNativeVisualID;          // Handle of corresponding native visual
     66 	EGLint mNativeVisualType;        // Native visual type of the associated visual
     67 	EGLint mRenderableType;          // Which client rendering APIs are supported.
     68 	EGLint mSampleBuffers;           // Number of multisample buffers
     69 	EGLint mSamples;                 // Number of samples per pixel
     70 	EGLint mStencilSize;             // Bits of Stencil in the stencil buffer
     71 	EGLint mSurfaceType;             // Which types of EGL surfaces are supported.
     72 	EGLenum mTransparentType;        // Type of transparency supported
     73 	EGLint mTransparentRedValue;     // Transparent red value
     74 	EGLint mTransparentGreenValue;   // Transparent green value
     75 	EGLint mTransparentBlueValue;    // Transparent blue value
     76 
     77 	EGLBoolean mRecordableAndroid;          // EGL_ANDROID_recordable
     78 	EGLBoolean mFramebufferTargetAndroid;   // EGL_ANDROID_framebuffer_target
     79 };
     80 
     81 struct CompareConfig
     82 {
     83 	bool operator()(const Config &x, const Config &y) const;
     84 };
     85 
     86 class ConfigSet
     87 {
     88 	friend class Display;
     89 
     90 public:
     91 	ConfigSet();
     92 
     93 	void add(sw::Format displayFormat, EGLint minSwapInterval, EGLint maxSwapInterval, sw::Format renderTargetFormat, sw::Format depthStencilFormat, EGLint multiSample);
     94 	size_t size() const;
     95 	bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
     96 	const egl::Config *get(EGLConfig configHandle);
     97 
     98 private:
     99 	typedef std::set<Config, CompareConfig> Set;
    100 	typedef Set::iterator Iterator;
    101 	Set mSet;
    102 };
    103 }
    104 
    105 #endif   // INCLUDE_CONFIG_H_
    106