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 mDisplayFormat; 40 const sw::Format mRenderTargetFormat; 41 const sw::Format mDepthStencilFormat; 42 const EGLint mMultiSample; 43 44 EGLint mBufferSize; // Depth of the color buffer 45 EGLint mRedSize; // Bits of Red in the color buffer 46 EGLint mGreenSize; // Bits of Green in the color buffer 47 EGLint mBlueSize; // Bits of Blue in the color buffer 48 EGLint mLuminanceSize; // Bits of Luminance in the color buffer 49 EGLint mAlphaSize; // Bits of Alpha in the color buffer 50 EGLint mAlphaMaskSize; // Bits of Alpha Mask in the mask buffer 51 EGLBoolean mBindToTextureRGB; // True if bindable to RGB textures. 52 EGLBoolean mBindToTextureRGBA; // True if bindable to RGBA textures. 53 EGLenum mColorBufferType; // Color buffer type 54 EGLenum mConfigCaveat; // Any caveats for the configuration 55 EGLint mConfigID; // Unique EGLConfig identifier 56 EGLint mConformant; // Whether contexts created with this config are conformant 57 EGLint mDepthSize; // Bits of Z in the depth buffer 58 EGLint mLevel; // Frame buffer level 59 EGLBoolean mMatchNativePixmap; // Match the native pixmap format 60 EGLint mMaxPBufferWidth; // Maximum width of pbuffer 61 EGLint mMaxPBufferHeight; // Maximum height of pbuffer 62 EGLint mMaxPBufferPixels; // Maximum size of pbuffer 63 EGLint mMaxSwapInterval; // Maximum swap interval 64 EGLint mMinSwapInterval; // Minimum swap interval 65 EGLBoolean mNativeRenderable; // EGL_TRUE if native rendering APIs can render to surface 66 EGLint mNativeVisualID; // Handle of corresponding native visual 67 EGLint mNativeVisualType; // Native visual type of the associated visual 68 EGLint mRenderableType; // Which client rendering APIs are supported. 69 EGLint mSampleBuffers; // Number of multisample buffers 70 EGLint mSamples; // Number of samples per pixel 71 EGLint mStencilSize; // Bits of Stencil in the stencil buffer 72 EGLint mSurfaceType; // Which types of EGL surfaces are supported. 73 EGLenum mTransparentType; // Type of transparency supported 74 EGLint mTransparentRedValue; // Transparent red value 75 EGLint mTransparentGreenValue; // Transparent green value 76 EGLint mTransparentBlueValue; // Transparent blue value 77 78 EGLBoolean mRecordableAndroid; // EGL_ANDROID_recordable 79 EGLBoolean mFramebufferTargetAndroid; // EGL_ANDROID_framebuffer_target 80 }; 81 82 struct CompareConfig 83 { 84 bool operator()(const Config &x, const Config &y) const; 85 }; 86 87 class ConfigSet 88 { 89 friend class Display; 90 91 public: 92 ConfigSet(); 93 94 void add(sw::Format displayFormat, EGLint minSwapInterval, EGLint maxSwapInterval, sw::Format renderTargetFormat, sw::Format depthStencilFormat, EGLint multiSample); 95 size_t size() const; 96 bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); 97 const egl::Config *get(EGLConfig configHandle); 98 99 private: 100 typedef std::set<Config, CompareConfig> Set; 101 typedef Set::iterator Iterator; 102 Set mSet; 103 }; 104 } 105 106 #endif // INCLUDE_CONFIG_H_ 107