Commit c223dc6b by Geoff Lang

Change Config to a struct and rename it's members.

BUG=angle:658 Change-Id: I18dab915730fc28815db8080b3614da821f9c8b1 Reviewed-on: https://chromium-review.googlesource.com/239901Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6812a55c
...@@ -22,51 +22,49 @@ ...@@ -22,51 +22,49 @@
namespace egl namespace egl
{ {
class Display;
class Config struct Config
{ {
public:
Config(); Config();
Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight); Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
GLenum mRenderTargetFormat; GLenum renderTargetFormat; // TODO(geofflang): remove this
GLenum mDepthStencilFormat; GLenum depthStencilFormat; // TODO(geofflang): remove this
GLint mMultiSample; GLint multiSample; // TODO(geofflang): remove this
EGLint mBufferSize; // Depth of the color buffer EGLint bufferSize; // Depth of the color buffer
EGLint mRedSize; // Bits of Red in the color buffer EGLint redSize; // Bits of Red in the color buffer
EGLint mGreenSize; // Bits of Green in the color buffer EGLint greenSize; // Bits of Green in the color buffer
EGLint mBlueSize; // Bits of Blue in the color buffer EGLint blueSize; // Bits of Blue in the color buffer
EGLint mLuminanceSize; // Bits of Luminance in the color buffer EGLint luminanceSize; // Bits of Luminance in the color buffer
EGLint mAlphaSize; // Bits of Alpha in the color buffer EGLint alphaSize; // Bits of Alpha in the color buffer
EGLint mAlphaMaskSize; // Bits of Alpha Mask in the mask buffer EGLint alphaMaskSize; // Bits of Alpha Mask in the mask buffer
EGLBoolean mBindToTextureRGB; // True if bindable to RGB textures. EGLBoolean bindToTextureRGB; // True if bindable to RGB textures.
EGLBoolean mBindToTextureRGBA; // True if bindable to RGBA textures. EGLBoolean bindToTextureRGBA; // True if bindable to RGBA textures.
EGLenum mColorBufferType; // Color buffer type EGLenum colorBufferType; // Color buffer type
EGLenum mConfigCaveat; // Any caveats for the configuration EGLenum configCaveat; // Any caveats for the configuration
EGLint mConfigID; // Unique EGLConfig identifier EGLint configID; // Unique EGLConfig identifier
EGLint mConformant; // Whether contexts created with this config are conformant EGLint conformant; // Whether contexts created with this config are conformant
EGLint mDepthSize; // Bits of Z in the depth buffer EGLint depthSize; // Bits of Z in the depth buffer
EGLint mLevel; // Frame buffer level EGLint level; // Frame buffer level
EGLBoolean mMatchNativePixmap; // Match the native pixmap format EGLBoolean matchNativePixmap; // Match the native pixmap format
EGLint mMaxPBufferWidth; // Maximum width of pbuffer EGLint maxPBufferWidth; // Maximum width of pbuffer
EGLint mMaxPBufferHeight; // Maximum height of pbuffer EGLint maxPBufferHeight; // Maximum height of pbuffer
EGLint mMaxPBufferPixels; // Maximum size of pbuffer EGLint maxPBufferPixels; // Maximum size of pbuffer
EGLint mMaxSwapInterval; // Maximum swap interval EGLint maxSwapInterval; // Maximum swap interval
EGLint mMinSwapInterval; // Minimum swap interval EGLint minSwapInterval; // Minimum swap interval
EGLBoolean mNativeRenderable; // EGL_TRUE if native rendering APIs can render to surface EGLBoolean nativeRenderable; // EGL_TRUE if native rendering APIs can render to surface
EGLint mNativeVisualID; // Handle of corresponding native visual EGLint nativeVisualID; // Handle of corresponding native visual
EGLint mNativeVisualType; // Native visual type of the associated visual EGLint nativeVisualType; // Native visual type of the associated visual
EGLint mRenderableType; // Which client rendering APIs are supported. EGLint renderableType; // Which client rendering APIs are supported.
EGLint mSampleBuffers; // Number of multisample buffers EGLint sampleBuffers; // Number of multisample buffers
EGLint mSamples; // Number of samples per pixel EGLint samples; // Number of samples per pixel
EGLint mStencilSize; // Bits of Stencil in the stencil buffer EGLint stencilSize; // Bits of Stencil in the stencil buffer
EGLint mSurfaceType; // Which types of EGL surfaces are supported. EGLint surfaceType; // Which types of EGL surfaces are supported.
EGLenum mTransparentType; // Type of transparency supported EGLenum transparentType; // Type of transparency supported
EGLint mTransparentRedValue; // Transparent red value EGLint transparentRedValue; // Transparent red value
EGLint mTransparentGreenValue; // Transparent green value EGLint transparentGreenValue; // Transparent green value
EGLint mTransparentBlueValue; // Transparent blue value EGLint transparentBlueValue; // Transparent blue value
}; };
class ConfigSet class ConfigSet
......
...@@ -183,38 +183,38 @@ bool Display::getConfigAttrib(const Config *configuration, EGLint attribute, EGL ...@@ -183,38 +183,38 @@ bool Display::getConfigAttrib(const Config *configuration, EGLint attribute, EGL
{ {
switch (attribute) switch (attribute)
{ {
case EGL_BUFFER_SIZE: *value = configuration->mBufferSize; break; case EGL_BUFFER_SIZE: *value = configuration->bufferSize; break;
case EGL_ALPHA_SIZE: *value = configuration->mAlphaSize; break; case EGL_ALPHA_SIZE: *value = configuration->alphaSize; break;
case EGL_BLUE_SIZE: *value = configuration->mBlueSize; break; case EGL_BLUE_SIZE: *value = configuration->blueSize; break;
case EGL_GREEN_SIZE: *value = configuration->mGreenSize; break; case EGL_GREEN_SIZE: *value = configuration->greenSize; break;
case EGL_RED_SIZE: *value = configuration->mRedSize; break; case EGL_RED_SIZE: *value = configuration->redSize; break;
case EGL_DEPTH_SIZE: *value = configuration->mDepthSize; break; case EGL_DEPTH_SIZE: *value = configuration->depthSize; break;
case EGL_STENCIL_SIZE: *value = configuration->mStencilSize; break; case EGL_STENCIL_SIZE: *value = configuration->stencilSize; break;
case EGL_CONFIG_CAVEAT: *value = configuration->mConfigCaveat; break; case EGL_CONFIG_CAVEAT: *value = configuration->configCaveat; break;
case EGL_CONFIG_ID: *value = configuration->mConfigID; break; case EGL_CONFIG_ID: *value = configuration->configID; break;
case EGL_LEVEL: *value = configuration->mLevel; break; case EGL_LEVEL: *value = configuration->level; break;
case EGL_NATIVE_RENDERABLE: *value = configuration->mNativeRenderable; break; case EGL_NATIVE_RENDERABLE: *value = configuration->nativeRenderable; break;
case EGL_NATIVE_VISUAL_TYPE: *value = configuration->mNativeVisualType; break; case EGL_NATIVE_VISUAL_TYPE: *value = configuration->nativeVisualType; break;
case EGL_SAMPLES: *value = configuration->mSamples; break; case EGL_SAMPLES: *value = configuration->samples; break;
case EGL_SAMPLE_BUFFERS: *value = configuration->mSampleBuffers; break; case EGL_SAMPLE_BUFFERS: *value = configuration->sampleBuffers; break;
case EGL_SURFACE_TYPE: *value = configuration->mSurfaceType; break; case EGL_SURFACE_TYPE: *value = configuration->surfaceType; break;
case EGL_TRANSPARENT_TYPE: *value = configuration->mTransparentType; break; case EGL_TRANSPARENT_TYPE: *value = configuration->transparentType; break;
case EGL_TRANSPARENT_BLUE_VALUE: *value = configuration->mTransparentBlueValue; break; case EGL_TRANSPARENT_BLUE_VALUE: *value = configuration->transparentBlueValue; break;
case EGL_TRANSPARENT_GREEN_VALUE: *value = configuration->mTransparentGreenValue; break; case EGL_TRANSPARENT_GREEN_VALUE: *value = configuration->transparentGreenValue; break;
case EGL_TRANSPARENT_RED_VALUE: *value = configuration->mTransparentRedValue; break; case EGL_TRANSPARENT_RED_VALUE: *value = configuration->transparentRedValue; break;
case EGL_BIND_TO_TEXTURE_RGB: *value = configuration->mBindToTextureRGB; break; case EGL_BIND_TO_TEXTURE_RGB: *value = configuration->bindToTextureRGB; break;
case EGL_BIND_TO_TEXTURE_RGBA: *value = configuration->mBindToTextureRGBA; break; case EGL_BIND_TO_TEXTURE_RGBA: *value = configuration->bindToTextureRGBA; break;
case EGL_MIN_SWAP_INTERVAL: *value = configuration->mMinSwapInterval; break; case EGL_MIN_SWAP_INTERVAL: *value = configuration->minSwapInterval; break;
case EGL_MAX_SWAP_INTERVAL: *value = configuration->mMaxSwapInterval; break; case EGL_MAX_SWAP_INTERVAL: *value = configuration->maxSwapInterval; break;
case EGL_LUMINANCE_SIZE: *value = configuration->mLuminanceSize; break; case EGL_LUMINANCE_SIZE: *value = configuration->luminanceSize; break;
case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break; case EGL_ALPHA_MASK_SIZE: *value = configuration->alphaMaskSize; break;
case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break; case EGL_COLOR_BUFFER_TYPE: *value = configuration->colorBufferType; break;
case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break; case EGL_RENDERABLE_TYPE: *value = configuration->renderableType; break;
case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break; case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break;
case EGL_CONFORMANT: *value = configuration->mConformant; break; case EGL_CONFORMANT: *value = configuration->conformant; break;
case EGL_MAX_PBUFFER_WIDTH: *value = configuration->mMaxPBufferWidth; break; case EGL_MAX_PBUFFER_WIDTH: *value = configuration->maxPBufferWidth; break;
case EGL_MAX_PBUFFER_HEIGHT: *value = configuration->mMaxPBufferHeight; break; case EGL_MAX_PBUFFER_HEIGHT: *value = configuration->maxPBufferHeight; break;
case EGL_MAX_PBUFFER_PIXELS: *value = configuration->mMaxPBufferPixels; break; case EGL_MAX_PBUFFER_PIXELS: *value = configuration->maxPBufferPixels; break;
default: default:
return false; return false;
} }
...@@ -397,13 +397,13 @@ Error Display::createOffscreenSurface(const Config *configuration, EGLClientBuff ...@@ -397,13 +397,13 @@ Error Display::createOffscreenSurface(const Config *configuration, EGLClientBuff
return Error(EGL_BAD_MATCH); return Error(EGL_BAD_MATCH);
} }
if (!(configuration->mSurfaceType & EGL_PBUFFER_BIT)) if (!(configuration->surfaceType & EGL_PBUFFER_BIT))
{ {
return Error(EGL_BAD_MATCH); return Error(EGL_BAD_MATCH);
} }
if ((textureFormat == EGL_TEXTURE_RGB && configuration->mBindToTextureRGB != EGL_TRUE) || if ((textureFormat == EGL_TEXTURE_RGB && configuration->bindToTextureRGB != EGL_TRUE) ||
(textureFormat == EGL_TEXTURE_RGBA && configuration->mBindToTextureRGBA != EGL_TRUE)) (textureFormat == EGL_TEXTURE_RGBA && configuration->bindToTextureRGBA != EGL_TRUE))
{ {
return Error(EGL_BAD_ATTRIBUTE); return Error(EGL_BAD_ATTRIBUTE);
} }
...@@ -448,7 +448,7 @@ Error Display::createContext(const Config *configuration, EGLContext shareContex ...@@ -448,7 +448,7 @@ Error Display::createContext(const Config *configuration, EGLContext shareContex
} }
} }
if (attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1) == 3 && !(configuration->mConformant & EGL_OPENGL_ES3_BIT_KHR)) if (attribs.get(EGL_CONTEXT_CLIENT_VERSION, 1) == 3 && !(configuration->conformant & EGL_OPENGL_ES3_BIT_KHR))
{ {
return Error(EGL_BAD_CONFIG); return Error(EGL_BAD_CONFIG);
} }
......
...@@ -80,7 +80,7 @@ void Surface::setSwapInterval(EGLint interval) ...@@ -80,7 +80,7 @@ void Surface::setSwapInterval(EGLint interval)
EGLint Surface::getConfigID() const EGLint Surface::getConfigID() const
{ {
return mImplementation->getConfig()->mConfigID; return mImplementation->getConfig()->configID;
} }
const Config *Surface::getConfig() const const Config *Surface::getConfig() const
......
...@@ -29,7 +29,7 @@ class SurfaceImpl; ...@@ -29,7 +29,7 @@ class SurfaceImpl;
namespace egl namespace egl
{ {
class Display; class Display;
class Config; struct Config;
class Surface final class Surface final
{ {
......
...@@ -416,7 +416,7 @@ void Texture::bindTexImage(egl::Surface *surface) ...@@ -416,7 +416,7 @@ void Texture::bindTexImage(egl::Surface *surface)
// Set the image info to the size and format of the surface // Set the image info to the size and format of the surface
ASSERT(mTarget == GL_TEXTURE_2D); ASSERT(mTarget == GL_TEXTURE_2D);
Extents size(surface->getWidth(), surface->getHeight(), 1); Extents size(surface->getWidth(), surface->getHeight(), 1);
ImageDesc desc(size, surface->getConfig()->mRenderTargetFormat); ImageDesc desc(size, surface->getConfig()->renderTargetFormat);
setImageDesc(ImageIndex::MakeGeneric(mTarget, 0), desc); setImageDesc(ImageIndex::MakeGeneric(mTarget, 0), desc);
} }
......
...@@ -20,7 +20,7 @@ namespace egl ...@@ -20,7 +20,7 @@ namespace egl
{ {
class AttributeMap; class AttributeMap;
class Display; class Display;
class Config; struct Config;
class ConfigSet; class ConfigSet;
class Surface; class Surface;
} }
......
...@@ -35,7 +35,7 @@ SurfaceImpl::~SurfaceImpl() ...@@ -35,7 +35,7 @@ SurfaceImpl::~SurfaceImpl()
EGLenum SurfaceImpl::getFormat() const EGLenum SurfaceImpl::getFormat() const
{ {
return mConfig->mRenderTargetFormat; return mConfig->renderTargetFormat;
} }
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace egl namespace egl
{ {
class Display; class Display;
class Config; struct Config;
} }
namespace rx namespace rx
......
...@@ -114,8 +114,8 @@ egl::Error SurfaceD3D::resetSwapChain() ...@@ -114,8 +114,8 @@ egl::Error SurfaceD3D::resetSwapChain()
} }
mSwapChain = mRenderer->createSwapChain(mNativeWindow, static_cast<HANDLE>(mShareHandle), mSwapChain = mRenderer->createSwapChain(mNativeWindow, static_cast<HANDLE>(mShareHandle),
mConfig->mRenderTargetFormat, mConfig->renderTargetFormat,
mConfig->mDepthStencilFormat); mConfig->depthStencilFormat);
if (!mSwapChain) if (!mSwapChain)
{ {
return egl::Error(EGL_BAD_ALLOC); return egl::Error(EGL_BAD_ALLOC);
......
...@@ -15,39 +15,39 @@ static egl::Config GenerateGenericConfig() ...@@ -15,39 +15,39 @@ static egl::Config GenerateGenericConfig()
{ {
egl::Config config; egl::Config config;
config.mBufferSize = 24; config.bufferSize = 24;
config.mRedSize = 8; config.redSize = 8;
config.mGreenSize = 8; config.greenSize = 8;
config.mBlueSize = 8; config.blueSize = 8;
config.mLuminanceSize = 0; config.luminanceSize = 0;
config.mAlphaSize = 8; config.alphaSize = 8;
config.mAlphaMaskSize = 0; config.alphaMaskSize = 0;
config.mBindToTextureRGB = EGL_TRUE; config.bindToTextureRGB = EGL_TRUE;
config.mBindToTextureRGBA = EGL_TRUE; config.bindToTextureRGBA = EGL_TRUE;
config.mColorBufferType = EGL_RGB_BUFFER; config.colorBufferType = EGL_RGB_BUFFER;
config.mConfigCaveat = EGL_NONE; config.configCaveat = EGL_NONE;
config.mConfigID = 0; config.configID = 0;
config.mConformant = EGL_OPENGL_ES2_BIT; config.conformant = EGL_OPENGL_ES2_BIT;
config.mDepthSize = 24; config.depthSize = 24;
config.mLevel = 0; config.level = 0;
config.mMatchNativePixmap = EGL_NONE; config.matchNativePixmap = EGL_NONE;
config.mMaxPBufferWidth = 1024; config.maxPBufferWidth = 1024;
config.mMaxPBufferHeight = 1024; config.maxPBufferHeight = 1024;
config.mMaxPBufferPixels = config.mMaxPBufferWidth * config.mMaxPBufferWidth; config.maxPBufferPixels = config.maxPBufferWidth * config.maxPBufferWidth;
config.mMaxSwapInterval = 0; config.maxSwapInterval = 0;
config.mMinSwapInterval = 4; config.minSwapInterval = 4;
config.mNativeRenderable = EGL_OPENGL_ES2_BIT; config.nativeRenderable = EGL_OPENGL_ES2_BIT;
config.mNativeVisualID = 0; config.nativeVisualID = 0;
config.mNativeVisualType = 0; config.nativeVisualType = 0;
config.mRenderableType = EGL_FALSE; config.renderableType = EGL_FALSE;
config.mSampleBuffers = 0; config.sampleBuffers = 0;
config.mSamples = 0; config.samples = 0;
config.mStencilSize = 8; config.stencilSize = 8;
config.mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; config.surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
config.mTransparentType = EGL_NONE; config.transparentType = EGL_NONE;
config.mTransparentRedValue = 0; config.transparentRedValue = 0;
config.mTransparentGreenValue = 0; config.transparentGreenValue = 0;
config.mTransparentBlueValue = 0; config.transparentBlueValue = 0;
return config; return config;
} }
...@@ -59,7 +59,7 @@ static std::vector<egl::Config> GenerateUniqueConfigs(size_t count) ...@@ -59,7 +59,7 @@ static std::vector<egl::Config> GenerateUniqueConfigs(size_t count)
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
egl::Config config = GenerateGenericConfig(); egl::Config config = GenerateGenericConfig();
config.mSamples = i; config.samples = i;
configs.push_back(config); configs.push_back(config);
} }
...@@ -98,7 +98,7 @@ TEST(ConfigSetTest, IDs) ...@@ -98,7 +98,7 @@ TEST(ConfigSetTest, IDs)
// Check that the config that was inserted has the ID that was returned // Check that the config that was inserted has the ID that was returned
// by ConfigSet::add // by ConfigSet::add
EXPECT_EQ(id, set.get(id).mConfigID); EXPECT_EQ(id, set.get(id).configID);
ids.insert(id); ids.insert(id);
} }
...@@ -123,12 +123,12 @@ TEST(ConfigSetTest, Filtering_BitSizes) ...@@ -123,12 +123,12 @@ TEST(ConfigSetTest, Filtering_BitSizes)
VariableConfigBitSize testMembers[] = VariableConfigBitSize testMembers[] =
{ {
{ EGL_RED_SIZE, &egl::Config::mRedSize }, { EGL_RED_SIZE, &egl::Config::redSize },
{ EGL_GREEN_SIZE, &egl::Config::mGreenSize }, { EGL_GREEN_SIZE, &egl::Config::greenSize },
{ EGL_BLUE_SIZE, &egl::Config::mBlueSize }, { EGL_BLUE_SIZE, &egl::Config::blueSize },
{ EGL_ALPHA_SIZE, &egl::Config::mAlphaSize }, { EGL_ALPHA_SIZE, &egl::Config::alphaSize },
{ EGL_DEPTH_SIZE, &egl::Config::mDepthSize }, { EGL_DEPTH_SIZE, &egl::Config::depthSize },
{ EGL_STENCIL_SIZE, &egl::Config::mStencilSize }, { EGL_STENCIL_SIZE, &egl::Config::stencilSize },
}; };
// Generate configsPerType configs with varying bit sizes of each type // Generate configsPerType configs with varying bit sizes of each type
...@@ -186,10 +186,10 @@ TEST(ConfigSetTest, Sorting_BitSizes) ...@@ -186,10 +186,10 @@ TEST(ConfigSetTest, Sorting_BitSizes)
egl::Config config = GenerateGenericConfig(); egl::Config config = GenerateGenericConfig();
// Give random-ish bit sizes to the config // Give random-ish bit sizes to the config
config.mRedSize = (i * 2) % 3; config.redSize = (i * 2) % 3;
config.mGreenSize = (i + 5) % 7; config.greenSize = (i + 5) % 7;
config.mBlueSize = (i + 7) % 11; config.blueSize = (i + 7) % 11;
config.mAlphaSize = (i + 13) % 17; config.alphaSize = (i + 13) % 17;
set.add(config); set.add(config);
} }
...@@ -204,16 +204,16 @@ TEST(ConfigSetTest, Sorting_BitSizes) ...@@ -204,16 +204,16 @@ TEST(ConfigSetTest, Sorting_BitSizes)
for (size_t i = 1; i < filteredConfigs.size(); i++) for (size_t i = 1; i < filteredConfigs.size(); i++)
{ {
const egl::Config &prevConfig = *filteredConfigs[i - 1]; const egl::Config &prevConfig = *filteredConfigs[i - 1];
size_t prevBitCount = prevConfig.mRedSize + size_t prevBitCount = prevConfig.redSize +
prevConfig.mGreenSize + prevConfig.greenSize +
prevConfig.mBlueSize + prevConfig.blueSize +
prevConfig.mAlphaSize; prevConfig.alphaSize;
const egl::Config &curConfig = *filteredConfigs[i]; const egl::Config &curConfig = *filteredConfigs[i];
size_t curBitCount = curConfig.mRedSize + size_t curBitCount = curConfig.redSize +
curConfig.mGreenSize + curConfig.greenSize +
curConfig.mBlueSize + curConfig.blueSize +
curConfig.mAlphaSize; curConfig.alphaSize;
EXPECT_GE(prevBitCount, curBitCount); EXPECT_GE(prevBitCount, curBitCount);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment