mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Factor out back color
This commit is contained in:
@@ -828,7 +828,7 @@ void DrawSurface::FillRect(const Rect &rect)
|
||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const uint8_t *pattern)
|
||||
void DrawSurface::FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern)
|
||||
{
|
||||
if (!rect.IsValid())
|
||||
return;
|
||||
@@ -866,9 +866,6 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
|
||||
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
||||
uint8_t backColor = 0;
|
||||
|
||||
if (!isMask)
|
||||
backColor = qdState->ResolveBackColor8(nullptr, 0);
|
||||
|
||||
size_t scanlineIndex = 0;
|
||||
for (size_t ln = 0; ln < numLines; ln++)
|
||||
{
|
||||
@@ -880,8 +877,6 @@ void DrawSurface::FillRectWithPattern8x8(const Rect &rect, bool isMask, const ui
|
||||
const int patternCol = static_cast<int>((patternFirstCol + col) & 7);
|
||||
if ((pattern[patternRow] >> patternCol) & 1)
|
||||
pixData[firstLineIndex + col] = color;
|
||||
else if (!isMask)
|
||||
pixData[firstLineIndex + col] = backColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -939,21 +934,21 @@ void DrawSurface::FillEllipse(const Rect &rect)
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSurface::FillEllipseWithPattern(const Rect &rect, bool isMask, const uint8_t *pattern)
|
||||
void DrawSurface::FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern)
|
||||
{
|
||||
if (!rect.IsValid() || rect.Width() < 1 || rect.Height() < 1)
|
||||
return;
|
||||
|
||||
if (rect.Width() <= 2 || rect.Height() <= 2)
|
||||
{
|
||||
FillRectWithPattern8x8(rect, isMask, pattern);
|
||||
FillRectWithMaskPattern8x8(rect, pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
PortabilityLayer::ScanlineMask *mask = PortabilityLayer::ScanlineMaskConverter::CompileEllipse(PortabilityLayer::Rect2i(rect.top, rect.left, rect.bottom, rect.right));
|
||||
if (mask)
|
||||
{
|
||||
FillScanlineMaskWithPattern(mask, isMask, pattern);
|
||||
FillScanlineMaskWithMaskPattern(mask, pattern);
|
||||
mask->Destroy();
|
||||
}
|
||||
}
|
||||
@@ -1025,7 +1020,7 @@ void DrawSurface::FrameEllipse(const Rect &rect)
|
||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||
}
|
||||
|
||||
static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol, uint8_t patternByte, uint8_t foreColor, uint8_t bgColor, bool mask)
|
||||
static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol, uint8_t patternByte, uint8_t foreColor)
|
||||
{
|
||||
if (patternByte == 0xff)
|
||||
{
|
||||
@@ -1034,33 +1029,20 @@ static void FillScanlineSpan(uint8_t *rowStart, size_t startCol, size_t endCol,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mask)
|
||||
for (size_t col = startCol; col < endCol; col++)
|
||||
{
|
||||
for (size_t col = startCol; col < endCol; col++)
|
||||
{
|
||||
if (patternByte & (0x80 >> (col & 7)))
|
||||
rowStart[col] = foreColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t col = startCol; col < endCol; col++)
|
||||
{
|
||||
if (patternByte & (0x80 >> (col & 7)))
|
||||
rowStart[col] = foreColor;
|
||||
else
|
||||
rowStart[col] = bgColor;
|
||||
}
|
||||
if (patternByte & (0x80 >> (col & 7)))
|
||||
rowStart[col] = foreColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask)
|
||||
{
|
||||
FillScanlineMaskWithPattern(scanlineMask, false, nullptr);
|
||||
FillScanlineMaskWithMaskPattern(scanlineMask, nullptr);
|
||||
}
|
||||
|
||||
void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMask *scanlineMask, bool isMask, const uint8_t *pattern)
|
||||
void DrawSurface::FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern)
|
||||
{
|
||||
if (!scanlineMask)
|
||||
return;
|
||||
@@ -1093,7 +1075,6 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
|
||||
}
|
||||
|
||||
uint8_t foreColor8 = 0;
|
||||
uint8_t backColor8 = 0;
|
||||
|
||||
const GpPixelFormat_t pixelFormat = pixMap->m_pixelFormat;
|
||||
|
||||
@@ -1102,7 +1083,6 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
|
||||
{
|
||||
case GpPixelFormats::k8BitStandard:
|
||||
foreColor8 = qdState->ResolveForeColor8(nullptr, 256);
|
||||
backColor8 = qdState->ResolveBackColor8(nullptr, 256);
|
||||
break;
|
||||
default:
|
||||
PL_NotYetImplemented();
|
||||
@@ -1172,7 +1152,7 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
|
||||
{
|
||||
const size_t spanEndCol = spanStartCol + currentSpan;
|
||||
if (spanState)
|
||||
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8, backColor8, isMask);
|
||||
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8);
|
||||
|
||||
spanStartCol = spanEndCol;
|
||||
paintColsRemaining -= currentSpan;
|
||||
@@ -1185,7 +1165,7 @@ void DrawSurface::FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMa
|
||||
if (spanState)
|
||||
{
|
||||
const size_t spanEndCol = firstPortCol + constrainedRectWidth;
|
||||
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8, backColor8, isMask);
|
||||
FillScanlineSpan(thisRowStart, spanStartCol, spanEndCol, thisRowPatternRow, foreColor8);
|
||||
}
|
||||
|
||||
if (row != numRows - 1)
|
||||
@@ -1360,16 +1340,6 @@ const PortabilityLayer::RGBAColor &DrawSurface::GetForeColor() const
|
||||
return m_port.GetState()->GetForeColor();
|
||||
}
|
||||
|
||||
void DrawSurface::SetBackColor(const PortabilityLayer::RGBAColor &color)
|
||||
{
|
||||
m_port.GetState()->SetBackColor(color);
|
||||
}
|
||||
|
||||
const PortabilityLayer::RGBAColor &DrawSurface::GetBackColor() const
|
||||
{
|
||||
return m_port.GetState()->GetBackColor();
|
||||
}
|
||||
|
||||
void PenSize(int w, int h)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
|
||||
@@ -229,6 +229,7 @@
|
||||
<ClInclude Include="PLScrollBarWidget.h" />
|
||||
<ClInclude Include="PLUnalignedPtr.h" />
|
||||
<ClInclude Include="PLWidgets.h" />
|
||||
<ClInclude Include="ResolveCachingColor.h" />
|
||||
<ClInclude Include="TextPlacer.h" />
|
||||
<ClInclude Include="UTF16.h" />
|
||||
<ClInclude Include="UTF8.h" />
|
||||
|
||||
@@ -483,6 +483,9 @@
|
||||
<ClInclude Include="PLRegions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ResolveCachingColor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CFileStream.cpp">
|
||||
|
||||
@@ -60,27 +60,24 @@ struct DrawSurface
|
||||
void PushToDDSurface(IGpDisplayDriver *displayDriver);
|
||||
|
||||
void FillRect(const Rect &rect);
|
||||
void FillRectWithPattern8x8(const Rect &rect, bool isMask, const uint8_t *pattern);
|
||||
void FillRectWithMaskPattern8x8(const Rect &rect, const uint8_t *pattern);
|
||||
void FrameRect(const Rect &rect);
|
||||
void FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight);
|
||||
void InvertFrameRect(const Rect &rect, const uint8_t *pattern);
|
||||
void InvertFillRect(const Rect &rect, const uint8_t *pattern);
|
||||
|
||||
void FillEllipse(const Rect &rect);
|
||||
void FillEllipseWithPattern(const Rect &rect, bool isMask, const uint8_t *pattern);
|
||||
void FillEllipseWithMaskPattern(const Rect &rect, const uint8_t *pattern);
|
||||
void FrameEllipse(const Rect &rect);
|
||||
|
||||
void FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlineMask);
|
||||
void FillScanlineMaskWithPattern(const PortabilityLayer::ScanlineMask *scanlineMask, bool isMask, const uint8_t *pattern);
|
||||
void FillScanlineMaskWithMaskPattern(const PortabilityLayer::ScanlineMask *scanlineMask, const uint8_t *pattern);
|
||||
|
||||
void DrawLine(const Point &a, const Point &b);
|
||||
|
||||
void SetForeColor(const PortabilityLayer::RGBAColor &color);
|
||||
const PortabilityLayer::RGBAColor &GetForeColor() const;
|
||||
|
||||
void SetBackColor(const PortabilityLayer::RGBAColor &color);
|
||||
const PortabilityLayer::RGBAColor &GetBackColor() const;
|
||||
|
||||
void SetApplicationFont(int size, int variationFlags);
|
||||
void SetSystemFont(int size, int variationFlags);
|
||||
void DrawString(const Point &point, const PLPasStr &str, bool aa);
|
||||
|
||||
@@ -32,33 +32,16 @@ namespace PortabilityLayer
|
||||
m_isForeResolved8 = false;
|
||||
}
|
||||
|
||||
void QDState::SetBackColor(const RGBAColor &color)
|
||||
{
|
||||
m_backUnresolvedColor = color;
|
||||
m_isBackResolved16 = false;
|
||||
m_isBackResolved8 = false;
|
||||
}
|
||||
|
||||
const RGBAColor &QDState::GetForeColor() const
|
||||
{
|
||||
return m_foreUnresolvedColor;
|
||||
}
|
||||
|
||||
const RGBAColor &QDState::GetBackColor() const
|
||||
{
|
||||
return m_backUnresolvedColor;
|
||||
}
|
||||
|
||||
uint8_t QDState::ResolveForeColor8(const RGBAColor *palette, unsigned int numColors)
|
||||
{
|
||||
return ResolveColor8(m_foreUnresolvedColor, m_foreResolvedColor8, m_isForeResolved8, palette, numColors);
|
||||
}
|
||||
|
||||
uint8_t QDState::ResolveBackColor8(const RGBAColor *palette, unsigned int numColors)
|
||||
{
|
||||
return ResolveColor8(m_backUnresolvedColor, m_backResolvedColor8, m_isBackResolved8, palette, numColors);
|
||||
}
|
||||
|
||||
uint8_t QDState::ResolveColor8(const RGBAColor &color, uint8_t &cached, bool &isCached, const RGBAColor *palette, unsigned int numColors)
|
||||
{
|
||||
if (isCached)
|
||||
|
||||
@@ -18,13 +18,10 @@ namespace PortabilityLayer
|
||||
Point m_penPos;
|
||||
|
||||
void SetForeColor(const RGBAColor &color);
|
||||
void SetBackColor(const RGBAColor &color);
|
||||
|
||||
const RGBAColor &GetForeColor() const;
|
||||
const RGBAColor &GetBackColor() const;
|
||||
|
||||
uint8_t ResolveForeColor8(const RGBAColor *palette, unsigned int numColors);
|
||||
uint8_t ResolveBackColor8(const RGBAColor *palette, unsigned int numColors);
|
||||
|
||||
private:
|
||||
static uint8_t ResolveColor8(const RGBAColor &color, uint8_t &cached, bool &isCached, const RGBAColor *palette, unsigned int numColors);
|
||||
|
||||
24
PortabilityLayer/ResolveCachingColor.h
Normal file
24
PortabilityLayer/ResolveCachingColor.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "RGBAColor.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class ResolveCachingColor
|
||||
{
|
||||
public:
|
||||
ResolveCachingColor(const RGBAColor &color);
|
||||
ResolveCachingColor(const ResolveCachingColor &color);
|
||||
|
||||
uint8_t Resolve8(const RGBAColor *palette, unsigned int numColors);
|
||||
|
||||
private:
|
||||
RGBAColor m_rgbaColor;
|
||||
|
||||
uint16_t m_resolved16;
|
||||
uint8_t m_resolved8;
|
||||
|
||||
bool m_isResolved16;
|
||||
bool m_isResolved8;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user