Implementation of sRGB image support. Overhauls the linearization setup to utilize the sRGB image types, as well as refactors the use of ColorF and ColorI to be properly internally consistent. ColorIs are used only for front-facing/editing/UI settings, and ColorFs, now renamed to LinearColorF to reduce confusion of purpose, are used for color info in the engine itself. This avoids confusing and expensive conversions back and forth between types and avoids botches with linearity. Majority work done by @rextimmy

This commit is contained in:
Areloch 2017-06-23 11:36:20 -05:00
parent 8943c673fb
commit 0801a3cca8
294 changed files with 3894 additions and 2813 deletions

View file

@ -307,22 +307,22 @@ void GuiBitmapButtonCtrl::setBitmap( const String& name )
if( mUseModifiers )
baseName += modifiers[ i ];
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXDefaultPersistentProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
if( mUseStates )
{
if( !mTextures[ i ].mTextureNormal )
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXDefaultPersistentProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXDefaultPersistentProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureHilight )
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXDefaultPersistentProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureDepressed )
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXDefaultPersistentProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureInactive )
mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
}

View file

@ -207,7 +207,7 @@ void GuiIconButtonCtrl::setBitmap(const char *name)
if (*mBitmapName)
{
mTextureNormal = GFXTexHandle( name, &GFXDefaultPersistentProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
mTextureNormal = GFXTexHandle( name, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
}
else
{

View file

@ -58,7 +58,7 @@ ConsoleDocClass( GuiSwatchButtonCtrl,
//-----------------------------------------------------------------------------
GuiSwatchButtonCtrl::GuiSwatchButtonCtrl()
: mSwatchColor(1, 1, 1, 1), mUseSRGB(false)
: mSwatchColor(1, 1, 1, 1)
{
mButtonText = StringTable->insert( "" );
setExtent(140, 30);
@ -72,8 +72,6 @@ GuiSwatchButtonCtrl::GuiSwatchButtonCtrl()
void GuiSwatchButtonCtrl::initPersistFields()
{
addField("color", TypeColorF, Offset(mSwatchColor, GuiSwatchButtonCtrl), "The foreground color of GuiSwatchButtonCtrl");
addField( "useSRGB", TypeBool, Offset( mUseSRGB, GuiSwatchButtonCtrl ), "Render using sRGB scale" );
addField( "gridBitmap", TypeString, Offset( mGridBitmap, GuiSwatchButtonCtrl ), "The bitmap used for the transparent grid" );
Parent::initPersistFields();
@ -108,10 +106,7 @@ void GuiSwatchButtonCtrl::onRender( Point2I offset, const RectI &updateRect )
drawer->drawBitmapStretch( mGrid, renderRect );
// Draw swatch color as fill...
if (!mUseSRGB)
drawer->drawRectFill( renderRect, mSwatchColor.toGamma() );
else
drawer->drawRectFill(renderRect, mSwatchColor);
drawer->drawRectFill(renderRect, mSwatchColor.toColorI());
// Draw any borders...
drawer->drawRect( renderRect, borderColor );

View file

@ -39,8 +39,7 @@ class GuiSwatchButtonCtrl : public GuiButtonBaseCtrl
protected:
/// The color to display on the button.
ColorF mSwatchColor;
bool mUseSRGB; ///< use sRGB color scale
LinearColorF mSwatchColor;
/// Bitmap used for mGrid
String mGridBitmap;
@ -52,10 +51,10 @@ class GuiSwatchButtonCtrl : public GuiButtonBaseCtrl
GuiSwatchButtonCtrl();
/// Return the color displayed in the swatch.
ColorF getColor() { return mSwatchColor; }
LinearColorF getColor() { return mSwatchColor; }
/// Set the color to display in the swatch.
void setColor( const ColorF &color ) { mSwatchColor = color; }
void setColor( const LinearColorF &color ) { mSwatchColor = color; }
// GuiButtonBaseCtrl
virtual bool onWake();

View file

@ -130,7 +130,7 @@ void GuiToolboxButtonCtrl::setNormalBitmap( StringTableEntry bitmapName )
return;
if ( *mNormalBitmapName )
mTextureNormal = GFXTexHandle( mNormalBitmapName, &GFXDefaultPersistentProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
mTextureNormal = GFXTexHandle( mNormalBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
else
mTextureNormal = NULL;
@ -145,7 +145,7 @@ void GuiToolboxButtonCtrl::setLoweredBitmap( StringTableEntry bitmapName )
return;
if ( *mLoweredBitmapName )
mTextureLowered = GFXTexHandle( mLoweredBitmapName, &GFXDefaultPersistentProfile, avar("%s() - mTextureLowered (line %d)", __FUNCTION__, __LINE__) );
mTextureLowered = GFXTexHandle( mLoweredBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureLowered (line %d)", __FUNCTION__, __LINE__) );
else
mTextureLowered = NULL;
@ -160,7 +160,7 @@ void GuiToolboxButtonCtrl::setHoverBitmap( StringTableEntry bitmapName )
return;
if ( *mHoverBitmapName )
mTextureHover = GFXTexHandle( mHoverBitmapName, &GFXDefaultPersistentProfile, avar("%s() - mTextureHover (line %d)", __FUNCTION__, __LINE__) );
mTextureHover = GFXTexHandle( mHoverBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureHover (line %d)", __FUNCTION__, __LINE__) );
else
mTextureHover = NULL;