blob: 98441142f4e6b4eaee37ebaa45038bda490848a5 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
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.com4f39fd92010-03-08 20:26:45 +000014#include <EGL/egl.h>
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000015
16#include <set>
17
daniel@transgaming.com3281f972012-10-31 18:38:51 +000018#include "libGLESv2/renderer/Renderer.h"
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000019#include "common/angleutils.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000020
21namespace egl
22{
daniel@transgaming.com178adff2010-05-18 18:52:04 +000023class Display;
24
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000025class Config
26{
27 public:
daniel@transgaming.com76d3e6e2012-10-31 19:55:33 +000028 Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000029
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000030 EGLConfig getHandle() const;
31
daniel@transgaming.com3281f972012-10-31 18:38:51 +000032 const GLenum mRenderTargetFormat;
33 const GLenum mDepthStencilFormat;
34 const GLint mMultiSample;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000035
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.
72class SortConfig
73{
74 public:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +000075 explicit SortConfig(const EGLint *attribList);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000076
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
91class ConfigSet
92{
daniel@transgaming.com178adff2010-05-18 18:52:04 +000093 friend Display;
94
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000095 public:
96 ConfigSet();
97
daniel@transgaming.com76d3e6e2012-10-31 19:55:33 +000098 void add(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000099 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.com178adff2010-05-18 18:52:04 +0000103 private:
104 DISALLOW_COPY_AND_ASSIGN(ConfigSet);
105
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000106 typedef std::set<Config, SortConfig> Set;
107 typedef Set::iterator Iterator;
108 Set mSet;
109
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000110 static const EGLint mSortAttribs[];
111};
112}
113
114#endif // INCLUDE_CONFIG_H_