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 8780f83262
commit 25686ed4be
294 changed files with 3894 additions and 2813 deletions

View file

@ -42,9 +42,9 @@ class GuiClockHud : public GuiControl
bool mShowFill;
bool mTimeReversed;
ColorF mFillColor;
ColorF mFrameColor;
ColorF mTextColor;
LinearColorF mFillColor;
LinearColorF mFrameColor;
LinearColorF mTextColor;
S32 mTimeOffset;
@ -117,7 +117,7 @@ void GuiClockHud::onRender(Point2I offset, const RectI &updateRect)
// Background first
if (mShowFill)
drawUtil->drawRectFill(updateRect, mFillColor);
drawUtil->drawRectFill(updateRect, mFillColor.toColorI());
// Convert ms time into hours, minutes and seconds.
S32 time = S32(getTime());
@ -131,13 +131,13 @@ void GuiClockHud::onRender(Point2I offset, const RectI &updateRect)
// Center the text
offset.x += (getWidth() - mProfile->mFont->getStrWidth((const UTF8 *)buf)) / 2;
offset.y += (getHeight() - mProfile->mFont->getHeight()) / 2;
drawUtil->setBitmapModulation(mTextColor);
drawUtil->setBitmapModulation(mTextColor.toColorI());
drawUtil->drawText(mProfile->mFont, offset, buf);
drawUtil->clearBitmapModulation();
// Border last
if (mShowFrame)
drawUtil->drawRect(updateRect, mFrameColor);
drawUtil->drawRect(updateRect, mFrameColor.toColorI());
}

View file

@ -42,8 +42,8 @@ class GuiCrossHairHud : public GuiBitmapCtrl
{
typedef GuiBitmapCtrl Parent;
ColorF mDamageFillColor;
ColorF mDamageFrameColor;
LinearColorF mDamageFillColor;
LinearColorF mDamageFrameColor;
Point2I mDamageRectSize;
Point2I mDamageOffset;
@ -178,7 +178,7 @@ void GuiCrossHairHud::drawDamage(Point2I offset, F32 damage, F32 opacity)
rect.point.x -= mDamageRectSize.x / 2;
// Draw the border
GFX->getDrawUtil()->drawRect(rect, mDamageFrameColor);
GFX->getDrawUtil()->drawRect(rect, mDamageFrameColor.toColorI());
// Draw the damage % fill
rect.point += Point2I(1, 1);
@ -187,5 +187,5 @@ void GuiCrossHairHud::drawDamage(Point2I offset, F32 damage, F32 opacity)
if (rect.extent.x == 1)
rect.extent.x = 2;
if (rect.extent.x > 0)
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor);
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor.toColorI());
}

View file

@ -45,9 +45,9 @@ class GuiHealthBarHud : public GuiControl
bool mDisplayEnergy;
bool mFlip;
ColorF mFillColor;
ColorF mFrameColor;
ColorF mDamageFillColor;
LinearColorF mFillColor;
LinearColorF mFrameColor;
LinearColorF mDamageFillColor;
S32 mPulseRate;
F32 mPulseThreshold;
@ -163,7 +163,7 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
// Background first
if (mShowFill)
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor);
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor.toColorI());
// Pulse the damage fill if it's below the threshold
if (mPulseRate != 0)
@ -196,9 +196,9 @@ void GuiHealthBarHud::onRender(Point2I offset, const RectI &updateRect)
else
rect.point.y = bottomY - rect.extent.y;
}
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor);
GFX->getDrawUtil()->drawRectFill(rect, mDamageFillColor.toColorI());
// Border last
if (mShowFrame)
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor);
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor.toColorI());
}

View file

@ -41,10 +41,10 @@ class GuiHealthTextHud : public GuiControl
bool mShowEnergy;
bool mShowTrueHealth;
ColorF mFillColor;
ColorF mFrameColor;
ColorF mTextColor;
ColorF mWarnColor;
LinearColorF mFillColor;
LinearColorF mFrameColor;
LinearColorF mTextColor;
LinearColorF mWarnColor;
F32 mWarnLevel;
F32 mPulseThreshold;
@ -167,7 +167,7 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect)
// If enabled draw background first
if (mShowFill)
drawUtil->drawRectFill(updateRect, mFillColor);
drawUtil->drawRectFill(updateRect, mFillColor.toColorI());
// Prepare text and center it
S32 val = (S32)mValue;
@ -176,7 +176,7 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect)
offset.x += (getBounds().extent.x - mProfile->mFont->getStrWidth((const UTF8 *)buf)) / 2;
offset.y += (getBounds().extent.y - mProfile->mFont->getHeight()) / 2;
ColorF tColor = mTextColor;
LinearColorF tColor = mTextColor;
// If warning level is exceeded switch to warning color
if(mValue < mWarnLevel)
@ -192,11 +192,11 @@ void GuiHealthTextHud::onRender(Point2I offset, const RectI &updateRect)
}
}
drawUtil->setBitmapModulation(tColor);
drawUtil->setBitmapModulation(tColor.toColorI());
drawUtil->drawText(mProfile->mFont, offset, buf);
drawUtil->clearBitmapModulation();
// If enabled draw the border last
if (mShowFrame)
drawUtil->drawRect(updateRect, mFrameColor);
drawUtil->drawRect(updateRect, mFrameColor.toColorI());
}

View file

@ -47,11 +47,11 @@ class GuiShapeNameHud : public GuiControl {
typedef GuiControl Parent;
// field data
ColorF mFillColor;
ColorF mFrameColor;
ColorF mTextColor;
ColorF mLabelFillColor;
ColorF mLabelFrameColor;
LinearColorF mFillColor;
LinearColorF mFrameColor;
LinearColorF mTextColor;
LinearColorF mLabelFillColor;
LinearColorF mLabelFrameColor;
F32 mVerticalOffset;
F32 mDistanceFade;
@ -162,7 +162,7 @@ void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
{
// Background fill first
if (mShowFill)
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor);
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor.toColorI());
// Must be in a TS Control
GuiTSCtrl *parent = dynamic_cast<GuiTSCtrl*>(getParent());
@ -274,7 +274,7 @@ void GuiShapeNameHud::onRender( Point2I, const RectI &updateRect)
// Border last
if (mShowFrame)
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor);
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor.toColorI());
}
@ -302,16 +302,16 @@ void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity)
// Background fill first
if (mShowLabelFill)
drawUtil->drawRectFill(RectI(offset, extent), mLabelFillColor);
drawUtil->drawRectFill(RectI(offset, extent), mLabelFillColor.toColorI());
// Deal with opacity and draw.
mTextColor.alpha = opacity;
drawUtil->setBitmapModulation(mTextColor);
drawUtil->setBitmapModulation(mTextColor.toColorI());
drawUtil->drawText(mProfile->mFont, offset + mLabelPadding, name);
drawUtil->clearBitmapModulation();
// Border last
if (mShowLabelFrame)
drawUtil->drawRect(RectI(offset, extent), mLabelFrameColor);
drawUtil->drawRect(RectI(offset, extent), mLabelFrameColor.toColorI());
}