mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Add text anti-aliasing, disable arcade mode
This commit is contained in:
@@ -39,7 +39,7 @@ class GpFont_FreeType2 final : public PortabilityLayer::HostFont
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Destroy() override;
|
void Destroy() override;
|
||||||
GpFontRenderedGlyph_FreeType2 *Render(uint32_t unicodeCodePoint, unsigned int size) override;
|
GpFontRenderedGlyph_FreeType2 *Render(uint32_t unicodeCodePoint, unsigned int size, bool aa) override;
|
||||||
bool GetLineSpacing(unsigned int size, int32_t &outSpacing) override;
|
bool GetLineSpacing(unsigned int size, int32_t &outSpacing) override;
|
||||||
|
|
||||||
static GpFont_FreeType2 *Create(const FT_StreamRec_ &streamRec, PortabilityLayer::IOStream *stream);
|
static GpFont_FreeType2 *Create(const FT_StreamRec_ &streamRec, PortabilityLayer::IOStream *stream);
|
||||||
@@ -106,7 +106,7 @@ void GpFont_FreeType2::Destroy()
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoint, unsigned int size)
|
GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoint, unsigned int size, bool aa)
|
||||||
{
|
{
|
||||||
if (m_currentSize != size)
|
if (m_currentSize != size)
|
||||||
{
|
{
|
||||||
@@ -120,16 +120,39 @@ GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoin
|
|||||||
if (!glyphIndex)
|
if (!glyphIndex)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (FT_Load_Glyph(m_face, glyphIndex, FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO) != 0)
|
FT_Int32 loadFlags = 0;
|
||||||
|
FT_Render_Mode renderMode = FT_RENDER_MODE_NORMAL;
|
||||||
|
|
||||||
|
if (aa)
|
||||||
|
{
|
||||||
|
renderMode = FT_RENDER_MODE_NORMAL;
|
||||||
|
loadFlags = FT_LOAD_TARGET_NORMAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loadFlags = FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO;
|
||||||
|
renderMode = FT_RENDER_MODE_MONO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FT_Load_Glyph(m_face, glyphIndex, loadFlags) != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (FT_Render_Glyph(m_face->glyph, FT_RENDER_MODE_MONO) != 0)
|
if (FT_Render_Glyph(m_face->glyph, renderMode) != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const FT_GlyphSlot glyph = m_face->glyph;
|
const FT_GlyphSlot glyph = m_face->glyph;
|
||||||
|
|
||||||
if (glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO)
|
if (aa == false && glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO)
|
||||||
return nullptr; // ????
|
return nullptr;
|
||||||
|
|
||||||
|
if (aa == true)
|
||||||
|
{
|
||||||
|
if (glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (glyph->bitmap.num_grays < 2)
|
||||||
|
return nullptr; // This should never happen
|
||||||
|
}
|
||||||
|
|
||||||
PortabilityLayer::RenderedGlyphMetrics metrics;
|
PortabilityLayer::RenderedGlyphMetrics metrics;
|
||||||
memset(&metrics, 0, sizeof(metrics));
|
memset(&metrics, 0, sizeof(metrics));
|
||||||
@@ -141,7 +164,13 @@ GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoin
|
|||||||
metrics.m_advanceX = glyph->metrics.horiAdvance / 64;
|
metrics.m_advanceX = glyph->metrics.horiAdvance / 64;
|
||||||
|
|
||||||
const size_t numRowsRequired = glyph->bitmap.rows;
|
const size_t numRowsRequired = glyph->bitmap.rows;
|
||||||
size_t pitchRequired = (glyph->bitmap.width + 7) / 8;
|
size_t pitchRequired = 0;
|
||||||
|
|
||||||
|
if (aa)
|
||||||
|
pitchRequired = (glyph->bitmap.width + 1) / 2;
|
||||||
|
else
|
||||||
|
pitchRequired = (glyph->bitmap.width + 7) / 8;
|
||||||
|
|
||||||
pitchRequired = pitchRequired + (GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
pitchRequired = pitchRequired + (GP_SYSTEM_MEMORY_ALIGNMENT - 1);
|
||||||
pitchRequired -= pitchRequired % GP_SYSTEM_MEMORY_ALIGNMENT;
|
pitchRequired -= pitchRequired % GP_SYSTEM_MEMORY_ALIGNMENT;
|
||||||
|
|
||||||
@@ -158,8 +187,8 @@ GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoin
|
|||||||
unsigned int bmWidth = glyph->bitmap.width;
|
unsigned int bmWidth = glyph->bitmap.width;
|
||||||
unsigned int bmHeight = glyph->bitmap.rows;
|
unsigned int bmHeight = glyph->bitmap.rows;
|
||||||
unsigned int bmPitch = glyph->bitmap.pitch;
|
unsigned int bmPitch = glyph->bitmap.pitch;
|
||||||
unsigned int copyableBytesPerRow = (bmWidth + 7) / 8;
|
|
||||||
const uint8_t *bmBytes = glyph->bitmap.buffer;
|
const uint8_t *bmBytes = glyph->bitmap.buffer;
|
||||||
|
const uint16_t numGrays = glyph->bitmap.num_grays;
|
||||||
|
|
||||||
size_t fillOffset = 0;
|
size_t fillOffset = 0;
|
||||||
for (unsigned int row = 0; row < bmHeight; row++)
|
for (unsigned int row = 0; row < bmHeight; row++)
|
||||||
@@ -167,15 +196,36 @@ GpFontRenderedGlyph_FreeType2 *GpFont_FreeType2::Render(uint32_t unicodeCodePoin
|
|||||||
const uint8_t *bmReadStart = bmBytes + bmPitch * row;
|
const uint8_t *bmReadStart = bmBytes + bmPitch * row;
|
||||||
uint8_t *bmWriteStart = fillData + pitchRequired * row;
|
uint8_t *bmWriteStart = fillData + pitchRequired * row;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < copyableBytesPerRow; i++)
|
if (aa)
|
||||||
{
|
{
|
||||||
const uint8_t b = bmReadStart[i];
|
for (size_t i = 0; i < pitchRequired; i++)
|
||||||
|
bmWriteStart[i] = 0;
|
||||||
|
|
||||||
uint8_t fillByte = 0;
|
for (size_t i = 0; i < bmWidth; i++)
|
||||||
for (int bit = 0; bit < 8; bit++)
|
{
|
||||||
fillByte |= ((b >> (7 - bit)) & 1) << bit;
|
const uint8_t b = bmReadStart[i];
|
||||||
|
const uint8_t normalizedGray = (b * 30 + (numGrays - 1)) / ((numGrays - 1) * 2);
|
||||||
|
|
||||||
bmWriteStart[i] = fillByte;
|
if (i & 1)
|
||||||
|
bmWriteStart[i / 2] |= (normalizedGray << 4);
|
||||||
|
else
|
||||||
|
bmWriteStart[i / 2] = normalizedGray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const size_t copyableBytesPerRow = (glyph->bitmap.width + 7) / 8;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < copyableBytesPerRow; i++)
|
||||||
|
{
|
||||||
|
const uint8_t b = bmReadStart[i];
|
||||||
|
|
||||||
|
uint8_t fillByte = 0;
|
||||||
|
for (int bit = 0; bit < 8; bit++)
|
||||||
|
fillByte |= ((b >> (7 - bit)) & 1) << bit;
|
||||||
|
|
||||||
|
bmWriteStart[i] = fillByte;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void DrawBannerMessage (Point topLeft)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetLineOfText(bannerStr, count, subStr);
|
GetLineOfText(bannerStr, count, subStr);
|
||||||
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr);
|
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 32 + (count * 20)), subStr, true);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
while (subStr[0] > 0);
|
while (subStr[0] > 0);
|
||||||
@@ -144,10 +144,10 @@ void DrawBannerMessage (Point topLeft)
|
|||||||
PasStringConcat(bannerStr, subStr);
|
PasStringConcat(bannerStr, subStr);
|
||||||
|
|
||||||
workSrcMap->SetForeColor(StdColors::Red());
|
workSrcMap->SetForeColor(StdColors::Red());
|
||||||
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr);
|
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 164), bannerStr, true);
|
||||||
|
|
||||||
GetLocalizedString(5, subStr);
|
GetLocalizedString(5, subStr);
|
||||||
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr);
|
workSrcMap->DrawString(Point::Create(topLeft.h + 16, topLeft.v + 180), subStr, true);
|
||||||
}
|
}
|
||||||
workSrcMap->SetForeColor(StdColors::Black());
|
workSrcMap->SetForeColor(StdColors::Black());
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void ColorText (DrawSurface *surface, const Point &point, StringPtr theStr, long
|
|||||||
|
|
||||||
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
|
const PortabilityLayer::RGBAColor wasColor = surface->GetForeColor();
|
||||||
surface->SetForeColor(rgbaColor);
|
surface->SetForeColor(rgbaColor);
|
||||||
surface->DrawString(point, theStr);
|
surface->DrawString(point, theStr, true);
|
||||||
surface->SetForeColor(wasColor);
|
surface->SetForeColor(wasColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void UpdateCoordWindow (void)
|
|||||||
else
|
else
|
||||||
PasStringConcat(tempStr, PSTR("-"));
|
PasStringConcat(tempStr, PSTR("-"));
|
||||||
|
|
||||||
surface->DrawString(Point::Create(5, 12), tempStr);
|
surface->DrawString(Point::Create(5, 12), tempStr, true);
|
||||||
|
|
||||||
PasStringCopy(PSTR("v: "), tempStr);
|
PasStringCopy(PSTR("v: "), tempStr);
|
||||||
if (coordV != -1)
|
if (coordV != -1)
|
||||||
@@ -97,7 +97,7 @@ void UpdateCoordWindow (void)
|
|||||||
else
|
else
|
||||||
PasStringConcat(tempStr, PSTR("-"));
|
PasStringConcat(tempStr, PSTR("-"));
|
||||||
|
|
||||||
surface->DrawString(Point::Create(4, 22), tempStr);
|
surface->DrawString(Point::Create(4, 22), tempStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(StdColors::Blue());
|
surface->SetForeColor(StdColors::Blue());
|
||||||
PasStringCopy(PSTR("d: "), tempStr);
|
PasStringCopy(PSTR("d: "), tempStr);
|
||||||
@@ -109,7 +109,7 @@ void UpdateCoordWindow (void)
|
|||||||
else
|
else
|
||||||
PasStringConcat(tempStr, PSTR("-"));
|
PasStringConcat(tempStr, PSTR("-"));
|
||||||
|
|
||||||
surface->DrawString(Point::Create(5, 32), tempStr);
|
surface->DrawString(Point::Create(5, 32), tempStr, true);
|
||||||
surface->SetForeColor(StdColors::Black());
|
surface->SetForeColor(StdColors::Black());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ void DrawDialogUserText (Dialog *dial, short item, StringPtr text, Boolean inver
|
|||||||
const int32_t ascender = surface->MeasureFontAscender();
|
const int32_t ascender = surface->MeasureFontAscender();
|
||||||
|
|
||||||
const Point centeredDrawPoint = Point::Create((iRect.left + iRect.right - strWidth) / 2, (iRect.top + iRect.bottom + ascender) / 2);
|
const Point centeredDrawPoint = Point::Create((iRect.left + iRect.right - strWidth) / 2, (iRect.top + iRect.bottom + ascender) / 2);
|
||||||
surface->DrawString(centeredDrawPoint, stringCopy);
|
surface->DrawString(centeredDrawPoint, stringCopy, true);
|
||||||
|
|
||||||
if (invert)
|
if (invert)
|
||||||
{
|
{
|
||||||
@@ -670,7 +670,7 @@ void DrawDialogUserText2 (Dialog *dial, short item, StringPtr text)
|
|||||||
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
|
CollapseStringToWidth(surface, stringCopy, iRect.right - iRect.left - 2);
|
||||||
|
|
||||||
surface->SetForeColor(StdColors::Black());
|
surface->SetForeColor(StdColors::Black());
|
||||||
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy);
|
surface->DrawString(Point::Create(iRect.left, iRect.bottom), stringCopy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- LoadDialogPICT
|
//-------------------------------------------------------------- LoadDialogPICT
|
||||||
|
|||||||
@@ -110,11 +110,11 @@ void SetUpFinalScreen (void)
|
|||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
||||||
const Point textShadowPos = Point::Create(offset + 1, textDown + 33 + (count * 20));
|
const Point textShadowPos = Point::Create(offset + 1, textDown + 33 + (count * 20));
|
||||||
|
|
||||||
surface->DrawString(textShadowPos, subStr);
|
surface->DrawString(textShadowPos, subStr, true);
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
|
|
||||||
const Point textPos = Point::Create(offset, textDown + 32 + (count * 20));
|
const Point textPos = Point::Create(offset, textDown + 32 + (count * 20));
|
||||||
surface->DrawString(textPos, subStr);
|
surface->DrawString(textPos, subStr, true);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
while (subStr[0] > 0);
|
while (subStr[0] > 0);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
//#define CAREFULDEBUG
|
//#define CAREFULDEBUG
|
||||||
#define COMPILENOCP
|
#define COMPILENOCP
|
||||||
#define COMPILEQT
|
#define COMPILEQT
|
||||||
#define BUILD_ARCADE_VERSION 1
|
#define BUILD_ARCADE_VERSION 0
|
||||||
|
|
||||||
#define kYellowUnaccounted 1
|
#define kYellowUnaccounted 1
|
||||||
#define kYellowFailedResOpen 2
|
#define kYellowFailedResOpen 2
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
|
|
||||||
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2) - 1, dropIt - 66);
|
const Point scoreShadowPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2) - 1, dropIt - 66);
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
surface->DrawString(scoreShadowPoint, tempStr);
|
surface->DrawString(scoreShadowPoint, tempStr, true);
|
||||||
|
|
||||||
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2), dropIt - 65);
|
const Point scoreTextPoint = Point::Create(scoreLeft + ((kScoreWide - surface->MeasureString(tempStr)) / 2), dropIt - 65);
|
||||||
surface->SetForeColor(cyanColor);
|
surface->SetForeColor(cyanColor);
|
||||||
surface->DrawString(scoreTextPoint, tempStr);
|
surface->DrawString(scoreTextPoint, tempStr, true);
|
||||||
|
|
||||||
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
surface->SetApplicationFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
||||||
|
|
||||||
@@ -157,11 +157,11 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
bannerWidth = surface->MeasureString(tempStr);
|
bannerWidth = surface->MeasureString(tempStr);
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
const Point topScoreShadowPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted);
|
const Point topScoreShadowPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted);
|
||||||
surface->DrawString(topScoreShadowPoint, tempStr);
|
surface->DrawString(topScoreShadowPoint, tempStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(yellowColor);
|
surface->SetForeColor(yellowColor);
|
||||||
const Point topScoreTextPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted - 1);
|
const Point topScoreTextPoint = Point::Create(scoreLeft + (kScoreWide - bannerWidth) / 2, dropIt - kKimsLifted - 1);
|
||||||
surface->DrawString(topScoreTextPoint, tempStr);
|
surface->DrawString(topScoreTextPoint, tempStr, true);
|
||||||
|
|
||||||
QSetRect(&tempRect, 0, 0, bannerWidth + 8, kScoreSpacing);
|
QSetRect(&tempRect, 0, 0, bannerWidth + 8, kScoreSpacing);
|
||||||
QOffsetRect(&tempRect, scoreLeft - 3 + (kScoreWide - bannerWidth) / 2,
|
QOffsetRect(&tempRect, scoreLeft - 3 + (kScoreWide - bannerWidth) / 2,
|
||||||
@@ -186,7 +186,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 1, dropIt - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 1, dropIt - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 1, dropIt + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 1, dropIt + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
if (i == lastHighScore)
|
if (i == lastHighScore)
|
||||||
surface->SetForeColor(whiteColor);
|
surface->SetForeColor(whiteColor);
|
||||||
else
|
else
|
||||||
@@ -195,7 +195,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 0, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 0, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 0, dropIt - 1 + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 0, dropIt - 1 + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
// draw high score name
|
// draw high score name
|
||||||
PasStringCopy(thisHousePtr->highScores.names[i], tempStr);
|
PasStringCopy(thisHousePtr->highScores.names[i], tempStr);
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
@@ -203,7 +203,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 31, dropIt - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 31, dropIt - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 31, dropIt + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 31, dropIt + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
if (i == lastHighScore)
|
if (i == lastHighScore)
|
||||||
surface->SetForeColor(whiteColor);
|
surface->SetForeColor(whiteColor);
|
||||||
else
|
else
|
||||||
@@ -212,7 +212,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 30, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 30, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 30, dropIt - 1 + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 30, dropIt - 1 + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
// draw level number
|
// draw level number
|
||||||
NumToString(thisHousePtr->highScores.levels[i], tempStr);
|
NumToString(thisHousePtr->highScores.levels[i], tempStr);
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
@@ -220,7 +220,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 161, dropIt - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 161, dropIt - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 161, dropIt + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 161, dropIt + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
if (i == lastHighScore)
|
if (i == lastHighScore)
|
||||||
surface->SetForeColor(whiteColor);
|
surface->SetForeColor(whiteColor);
|
||||||
else
|
else
|
||||||
@@ -229,7 +229,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 160, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 160, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 160, dropIt - 1 + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 160, dropIt - 1 + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
// draw word "rooms"
|
// draw word "rooms"
|
||||||
if (thisHousePtr->highScores.levels[i] == 1)
|
if (thisHousePtr->highScores.levels[i] == 1)
|
||||||
GetLocalizedString(6, tempStr);
|
GetLocalizedString(6, tempStr);
|
||||||
@@ -240,13 +240,13 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 193, dropIt - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 193, dropIt - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 193, dropIt + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 193, dropIt + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
surface->SetForeColor(cyanColor);
|
surface->SetForeColor(cyanColor);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
strPos = Point::Create(scoreLeft + 192, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 192, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 192, dropIt - 1 + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 192, dropIt - 1 + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
// draw high score points
|
// draw high score points
|
||||||
NumToString(thisHousePtr->highScores.scores[i], tempStr);
|
NumToString(thisHousePtr->highScores.scores[i], tempStr);
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
@@ -254,7 +254,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 291, dropIt - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 291, dropIt - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 291, dropIt + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 291, dropIt + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
if (i == lastHighScore)
|
if (i == lastHighScore)
|
||||||
surface->SetForeColor(whiteColor);
|
surface->SetForeColor(whiteColor);
|
||||||
else
|
else
|
||||||
@@ -263,7 +263,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
strPos = Point::Create(scoreLeft + 290, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
strPos = Point::Create(scoreLeft + 290, dropIt - 1 - kScoreSpacing - kKimsLifted);
|
||||||
else
|
else
|
||||||
strPos = Point::Create(scoreLeft + 290, dropIt - 1 + (i * kScoreSpacing));
|
strPos = Point::Create(scoreLeft + 290, dropIt - 1 + (i * kScoreSpacing));
|
||||||
surface->DrawString(strPos, tempStr);
|
surface->DrawString(strPos, tempStr, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ void DrawHighScores (DrawSurface *surface)
|
|||||||
|
|
||||||
const Point textPos = Point::Create(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
|
const Point textPos = Point::Create(scoreLeft + 80, dropIt - 1 + (10 * kScoreSpacing));
|
||||||
GetLocalizedString(8, tempStr);
|
GetLocalizedString(8, tempStr);
|
||||||
surface->DrawString(textPos, tempStr);
|
surface->DrawString(textPos, tempStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(blackColor);
|
surface->SetForeColor(blackColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void DoHeliumEngaged (gliderPtr thisGlider)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (theKeys->IsSet(kCommandKeyMap))
|
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)))
|
||||||
DoCommandKey();
|
DoCommandKey();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void DrawOnSplash(DrawSurface *surface)
|
|||||||
if (thisMac.isDepth == 4)
|
if (thisMac.isDepth == 4)
|
||||||
{
|
{
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
surface->DrawString(textPoint, houseLoadedStr);
|
surface->DrawString(textPoint, houseLoadedStr, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ PLError_t DumpMusicSounds (void);
|
|||||||
PLError_t OpenMusicChannel (void);
|
PLError_t OpenMusicChannel (void);
|
||||||
PLError_t CloseMusicChannel (void);
|
PLError_t CloseMusicChannel (void);
|
||||||
|
|
||||||
|
THandle<void> ParseAndConvertSound(const THandle<void> &handle);
|
||||||
|
|
||||||
|
|
||||||
PortabilityLayer::AudioChannel *musicChannel;
|
PortabilityLayer::AudioChannel *musicChannel;
|
||||||
Ptr theMusicData[kMaxMusic];
|
Ptr theMusicData[kMaxMusic];
|
||||||
@@ -210,17 +212,17 @@ PLError_t LoadMusicSounds (void)
|
|||||||
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
theSound = GetResource('snd ', i + kBaseBufferMusicID);
|
theSound = ParseAndConvertSound(GetResource('snd ', i + kBaseBufferMusicID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
return PLErrors::kOutOfMemory;
|
return PLErrors::kOutOfMemory;
|
||||||
|
|
||||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
soundDataSize = GetHandleSize(theSound);
|
||||||
|
|
||||||
theMusicData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
theMusicData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
||||||
if (theMusicData[i] == nil)
|
if (theMusicData[i] == nil)
|
||||||
return PLErrors::kOutOfMemory;
|
return PLErrors::kOutOfMemory;
|
||||||
|
|
||||||
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
|
BlockMove(static_cast<Byte*>(*theSound), theMusicData[i], soundDataSize);
|
||||||
theSound.Dispose();
|
theSound.Dispose();
|
||||||
}
|
}
|
||||||
return (theErr);
|
return (theErr);
|
||||||
|
|||||||
@@ -250,9 +250,9 @@ void ReadyBackground (short theID, short *theTiles)
|
|||||||
|
|
||||||
const Point textPoint = Point::Create(10, 20);
|
const Point textPoint = Point::Create(10, 20);
|
||||||
if (houseUnlocked)
|
if (houseUnlocked)
|
||||||
workSrcMap->DrawString(textPoint, PSTR("No rooms"));
|
workSrcMap->DrawString(textPoint, PSTR("No rooms"), true);
|
||||||
else
|
else
|
||||||
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"));
|
workSrcMap->DrawString(textPoint, PSTR("Nothing to show"), true);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
|
||||||
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
(BitMap *)*GetGWorldPixMap(backSrcMap),
|
||||||
|
|||||||
@@ -167,15 +167,15 @@ void RefreshRoomTitle (short mode)
|
|||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case kEscapedTitleMode:
|
case kEscapedTitleMode:
|
||||||
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"));
|
surface->DrawString(strShadowPoint, PSTR("Hit Delete key if unable to Follow"), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kSavingTitleMode:
|
case kSavingTitleMode:
|
||||||
surface->DrawString(strShadowPoint, PSTR("Saving Game<6D>"));
|
surface->DrawString(strShadowPoint, PSTR("Saving Game<6D>"), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
surface->DrawString(strShadowPoint, thisRoom->name);
|
surface->DrawString(strShadowPoint, thisRoom->name, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,15 +184,15 @@ void RefreshRoomTitle (short mode)
|
|||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case kEscapedTitleMode:
|
case kEscapedTitleMode:
|
||||||
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"));
|
surface->DrawString(strPoint, PSTR("Hit Delete key if unable to Follow"), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kSavingTitleMode:
|
case kSavingTitleMode:
|
||||||
surface->DrawString(strPoint, PSTR("Saving Game<6D>"));
|
surface->DrawString(strPoint, PSTR("Saving Game<6D>"), true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
surface->DrawString(strPoint, thisRoom->name);
|
surface->DrawString(strPoint, thisRoom->name, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,10 +225,10 @@ void RefreshNumGliders (void)
|
|||||||
const Point textPoint = Point::Create(0, 9);
|
const Point textPoint = Point::Create(0, 9);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
||||||
surface->DrawString(shadowPoint, nGlidersStr);
|
surface->DrawString(shadowPoint, nGlidersStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
surface->DrawString(textPoint, nGlidersStr);
|
surface->DrawString(textPoint, nGlidersStr, true);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
||||||
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||||
@@ -254,10 +254,10 @@ void RefreshPoints (void)
|
|||||||
const Point textPoint = Point::Create(0, 9);
|
const Point textPoint = Point::Create(0, 9);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
||||||
surface->DrawString(shadowPoint, scoreStr);
|
surface->DrawString(shadowPoint, scoreStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
surface->DrawString(textPoint, scoreStr);
|
surface->DrawString(textPoint, scoreStr, true);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
|
||||||
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
(BitMap *)*GetGWorldPixMap(boardSrcMap),
|
||||||
@@ -285,10 +285,10 @@ void QuickGlidersRefresh (void)
|
|||||||
const Point textPoint = Point::Create(0, 9);
|
const Point textPoint = Point::Create(0, 9);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
||||||
surface->DrawString(shadowPoint, nGlidersStr);
|
surface->DrawString(shadowPoint, nGlidersStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
surface->DrawString(textPoint, nGlidersStr);
|
surface->DrawString(textPoint, nGlidersStr, true);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
|
||||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||||
@@ -315,10 +315,10 @@ void QuickScoreRefresh (void)
|
|||||||
const Point textPoint = Point::Create(0, 9);
|
const Point textPoint = Point::Create(0, 9);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255));
|
||||||
surface->DrawString(shadowPoint, scoreStr);
|
surface->DrawString(shadowPoint, scoreStr, true);
|
||||||
|
|
||||||
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
surface->SetForeColor(PortabilityLayer::RGBAColor::Create(255, 255, 255, 255));
|
||||||
surface->DrawString(textPoint, scoreStr);
|
surface->DrawString(textPoint, scoreStr, true);
|
||||||
|
|
||||||
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
|
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
|
||||||
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
|
||||||
|
|||||||
158
GpApp/Sound.cpp
158
GpApp/Sound.cpp
@@ -12,6 +12,7 @@
|
|||||||
#include "MemoryManager.h"
|
#include "MemoryManager.h"
|
||||||
#include "SoundSync.h"
|
#include "SoundSync.h"
|
||||||
#include "VirtualDirectory.h"
|
#include "VirtualDirectory.h"
|
||||||
|
#include "WaveFormat.h"
|
||||||
|
|
||||||
|
|
||||||
#define kBaseBufferSoundID 1000
|
#define kBaseBufferSoundID 1000
|
||||||
@@ -25,7 +26,7 @@ PLError_t LoadBufferSounds (void);
|
|||||||
void DumpBufferSounds (void);
|
void DumpBufferSounds (void);
|
||||||
PLError_t OpenSoundChannels (void);
|
PLError_t OpenSoundChannels (void);
|
||||||
void CloseSoundChannels (void);
|
void CloseSoundChannels (void);
|
||||||
|
THandle<void> ParseAndConvertSound(const THandle<void> &handle);
|
||||||
|
|
||||||
PortabilityLayer::AudioChannel *channel0, *channel1, *channel2;
|
PortabilityLayer::AudioChannel *channel0, *channel1, *channel2;
|
||||||
Ptr theSoundData[kMaxSounds];
|
Ptr theSoundData[kMaxSounds];
|
||||||
@@ -167,6 +168,9 @@ void PlayExclusiveSoundChannel(short channelIndex, short soundID, short oldPrior
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------- ParseAndConvertSound
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------- LoadTriggerSound
|
//-------------------------------------------------------------- LoadTriggerSound
|
||||||
|
|
||||||
PLError_t LoadTriggerSound (short soundID)
|
PLError_t LoadTriggerSound (short soundID)
|
||||||
@@ -183,14 +187,14 @@ PLError_t LoadTriggerSound (short soundID)
|
|||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
theSound = GetResource('snd ', soundID);
|
theSound = ParseAndConvertSound(GetResource('snd ', soundID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
{
|
{
|
||||||
theErr = PLErrors::kFileNotFound;
|
theErr = PLErrors::kFileNotFound;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
soundDataSize = GetHandleSize(theSound);
|
||||||
theSoundData[kMaxSounds - 1] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
theSoundData[kMaxSounds - 1] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
||||||
if (theSoundData[kMaxSounds - 1] == nil)
|
if (theSoundData[kMaxSounds - 1] == nil)
|
||||||
{
|
{
|
||||||
@@ -199,7 +203,7 @@ PLError_t LoadTriggerSound (short soundID)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[kMaxSounds - 1], soundDataSize);
|
BlockMove((Byte*)(*theSound), theSoundData[kMaxSounds - 1], soundDataSize);
|
||||||
theSound.Dispose();
|
theSound.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,17 +234,17 @@ PLError_t LoadBufferSounds (void)
|
|||||||
|
|
||||||
for (i = 0; i < kMaxSounds - 1; i++)
|
for (i = 0; i < kMaxSounds - 1; i++)
|
||||||
{
|
{
|
||||||
theSound = GetResource('snd ', i + kBaseBufferSoundID);
|
theSound = ParseAndConvertSound(GetResource('snd ', i + kBaseBufferSoundID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
return (PLErrors::kOutOfMemory);
|
return (PLErrors::kOutOfMemory);
|
||||||
|
|
||||||
soundDataSize = GetHandleSize(theSound) - 20L;
|
soundDataSize = GetHandleSize(theSound);
|
||||||
|
|
||||||
theSoundData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
theSoundData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
||||||
if (theSoundData[i] == nil)
|
if (theSoundData[i] == nil)
|
||||||
return (PLErrors::kOutOfMemory);
|
return (PLErrors::kOutOfMemory);
|
||||||
|
|
||||||
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
|
BlockMove(*theSound, theSoundData[i], soundDataSize);
|
||||||
theSound.Dispose();
|
theSound.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,3 +412,143 @@ void BitchAboutSM3 (void)
|
|||||||
hitWhat = Alert(kNoSoundManager3Alert, nil);
|
hitWhat = Alert(kNoSoundManager3Alert, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------- ParseAndConvertSound
|
||||||
|
|
||||||
|
THandle<void> ParseAndConvertSoundChecked(const THandle<void> &handle)
|
||||||
|
{
|
||||||
|
const uint8_t *dataStart = static_cast<const uint8_t*>(*handle);
|
||||||
|
const size_t size = handle.MMBlock()->m_size;
|
||||||
|
|
||||||
|
if (size < sizeof(PortabilityLayer::RIFFTag))
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
PortabilityLayer::RIFFTag mainRiffTag;
|
||||||
|
memcpy(&mainRiffTag, dataStart, sizeof(PortabilityLayer::RIFFTag));
|
||||||
|
|
||||||
|
if (mainRiffTag.m_tag != PortabilityLayer::WaveConstants::kRiffChunkID)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
const uint32_t riffSize = mainRiffTag.m_chunkSize;
|
||||||
|
if (riffSize < 4 || riffSize - 4 > size - sizeof(PortabilityLayer::RIFFTag))
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
const uint8_t *riffStart = dataStart + sizeof(PortabilityLayer::RIFFTag);
|
||||||
|
const uint8_t *riffEnd = riffStart + riffSize;
|
||||||
|
|
||||||
|
const uint8_t *formatTagLoc = nullptr;
|
||||||
|
const uint8_t *dataTagLoc = nullptr;
|
||||||
|
|
||||||
|
LEUInt32_t waveMarker;
|
||||||
|
memcpy(&waveMarker, riffStart, 4);
|
||||||
|
|
||||||
|
if (waveMarker != PortabilityLayer::WaveConstants::kWaveChunkID)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
const uint8_t *tagSearchLoc = riffStart + 4;
|
||||||
|
|
||||||
|
// Find tags
|
||||||
|
while (tagSearchLoc != riffEnd)
|
||||||
|
{
|
||||||
|
if (riffEnd - tagSearchLoc < sizeof(PortabilityLayer::RIFFTag))
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
PortabilityLayer::RIFFTag riffTag;
|
||||||
|
memcpy(&riffTag, tagSearchLoc, sizeof(PortabilityLayer::RIFFTag));
|
||||||
|
|
||||||
|
if (riffTag.m_tag == PortabilityLayer::WaveConstants::kFormatChunkID)
|
||||||
|
formatTagLoc = tagSearchLoc;
|
||||||
|
else if (riffTag.m_tag == PortabilityLayer::WaveConstants::kDataChunkID)
|
||||||
|
dataTagLoc = tagSearchLoc;
|
||||||
|
|
||||||
|
const uint32_t riffTagSizeUnpadded = riffTag.m_chunkSize;
|
||||||
|
|
||||||
|
if (riffTagSizeUnpadded == 0xffffffffU)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
const uint32_t riffTagSizePadded = riffTagSizeUnpadded + (riffTagSizeUnpadded & 1);
|
||||||
|
|
||||||
|
tagSearchLoc += sizeof(PortabilityLayer::RIFFTag);
|
||||||
|
|
||||||
|
if (riffEnd - tagSearchLoc < riffTagSizePadded)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
tagSearchLoc += riffTagSizePadded;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formatTagLoc == nullptr || dataTagLoc == nullptr)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
PortabilityLayer::RIFFTag fmtTag;
|
||||||
|
memcpy(&fmtTag, formatTagLoc, sizeof(PortabilityLayer::RIFFTag));
|
||||||
|
|
||||||
|
const uint8_t *formatContents = formatTagLoc + sizeof(PortabilityLayer::RIFFTag);
|
||||||
|
|
||||||
|
PortabilityLayer::RIFFTag dataTag;
|
||||||
|
memcpy(&dataTag, dataTagLoc, sizeof(PortabilityLayer::RIFFTag));
|
||||||
|
|
||||||
|
const uint8_t *dataContents = dataTagLoc + sizeof(PortabilityLayer::RIFFTag);
|
||||||
|
|
||||||
|
PortabilityLayer::WaveFormatChunkV3 formatChunkV3;
|
||||||
|
|
||||||
|
memset(&formatChunkV3, 0, sizeof(formatChunkV3));
|
||||||
|
|
||||||
|
int formatChunkVersion = 0;
|
||||||
|
size_t copyableSize = 0;
|
||||||
|
if (fmtTag.m_chunkSize >= sizeof(PortabilityLayer::WaveFormatChunkV3))
|
||||||
|
{
|
||||||
|
formatChunkVersion = 3;
|
||||||
|
copyableSize = sizeof(PortabilityLayer::WaveFormatChunkV3);
|
||||||
|
}
|
||||||
|
else if (fmtTag.m_chunkSize >= sizeof(PortabilityLayer::WaveFormatChunkV2))
|
||||||
|
{
|
||||||
|
formatChunkVersion = 2;
|
||||||
|
copyableSize = sizeof(PortabilityLayer::WaveFormatChunkV2);
|
||||||
|
}
|
||||||
|
else if (fmtTag.m_chunkSize >= sizeof(PortabilityLayer::WaveFormatChunkV1))
|
||||||
|
{
|
||||||
|
formatChunkVersion = 1;
|
||||||
|
copyableSize = sizeof(PortabilityLayer::WaveFormatChunkV1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
memcpy(&formatChunkV3, formatContents, copyableSize);
|
||||||
|
|
||||||
|
const PortabilityLayer::WaveFormatChunkV2 formatChunkV2 = formatChunkV3.m_v2;
|
||||||
|
const PortabilityLayer::WaveFormatChunkV1 formatChunkV1 = formatChunkV2.m_v1;
|
||||||
|
|
||||||
|
if (formatChunkV1.m_bitsPerSample != 8)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
if (formatChunkV1.m_formatCode != PortabilityLayer::WaveConstants::kFormatPCM ||
|
||||||
|
formatChunkV1.m_numChannels != 1 ||
|
||||||
|
formatChunkV1.m_blockAlignmentBytes != 1 ||
|
||||||
|
formatChunkV1.m_bitsPerSample != 8)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
THandle<void> convertedHandle = THandle<void>(PortabilityLayer::MemoryManager::GetInstance()->AllocHandle(4 + dataTag.m_chunkSize));
|
||||||
|
if (!convertedHandle)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
uint8_t *handleData = static_cast<uint8_t*>(*convertedHandle);
|
||||||
|
|
||||||
|
uint32_t dataSize = dataTag.m_chunkSize;
|
||||||
|
memcpy(handleData, &dataSize, 4);
|
||||||
|
|
||||||
|
memcpy(handleData + 4, dataContents, dataSize);
|
||||||
|
|
||||||
|
return convertedHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
THandle<void> ParseAndConvertSound(const THandle<void> &handle)
|
||||||
|
{
|
||||||
|
if (!handle)
|
||||||
|
return THandle<void>();
|
||||||
|
|
||||||
|
THandle<void> converted = ParseAndConvertSoundChecked(handle);
|
||||||
|
handle.Dispose();
|
||||||
|
|
||||||
|
return converted;
|
||||||
|
}
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ void SetMessageWindowMessage (StringPtr message)
|
|||||||
|
|
||||||
const Point textPoint = Point::Create(mssgWindowRect.left, mssgWindowRect.bottom - 6);
|
const Point textPoint = Point::Create(mssgWindowRect.left, mssgWindowRect.bottom - 6);
|
||||||
surface->SetForeColor(StdColors::Black());
|
surface->SetForeColor(StdColors::Black());
|
||||||
surface->DrawString(textPoint, message);
|
surface->DrawString(textPoint, message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
56
PortabilityLayer/AntiAliasTable.cpp
Normal file
56
PortabilityLayer/AntiAliasTable.cpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#include "AntiAliasTable.h"
|
||||||
|
#include "RGBAColor.h"
|
||||||
|
|
||||||
|
// TODO: This is not gamma correct... do we care?
|
||||||
|
namespace PortabilityLayer
|
||||||
|
{
|
||||||
|
void AntiAliasTable::GenerateForPalette(const RGBAColor &baseColorRef, const RGBAColor *colors, size_t numColors)
|
||||||
|
{
|
||||||
|
const RGBAColor baseColor = baseColorRef;
|
||||||
|
|
||||||
|
if (numColors > 256)
|
||||||
|
numColors = 256;
|
||||||
|
|
||||||
|
unsigned int baseCh[3] = { baseColor.r, baseColor.g, baseColor.b };
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numColors; i++)
|
||||||
|
{
|
||||||
|
const RGBAColor existingColor = colors[i];
|
||||||
|
|
||||||
|
unsigned int existingCh[3] = { existingColor.r, existingColor.g, existingColor.b };
|
||||||
|
|
||||||
|
// 0 alpha is always the same color
|
||||||
|
m_aaTranslate[i][0] = static_cast<uint8_t>(i);
|
||||||
|
|
||||||
|
for (unsigned int b = 1; b < 16; b++)
|
||||||
|
{
|
||||||
|
unsigned int newCh[3];
|
||||||
|
|
||||||
|
for (unsigned int ch = 0; ch < 3; ch++)
|
||||||
|
newCh[ch] = (15 - b) * existingCh[ch] + b * baseCh[ch];
|
||||||
|
|
||||||
|
uint32_t bestError = 0xffffffffU;
|
||||||
|
size_t bestColor = 0;
|
||||||
|
for (size_t cmp = 0; cmp < numColors; cmp++)
|
||||||
|
{
|
||||||
|
int16_t existingChScaled[3] = { colors[cmp].r * 15, colors[cmp].g * 15, colors[cmp].b * 15 };
|
||||||
|
|
||||||
|
uint32_t error = 0;
|
||||||
|
for (unsigned int ch = 0; ch < 3; ch++)
|
||||||
|
{
|
||||||
|
int16_t delta = static_cast<int16_t>(newCh[ch]) - existingChScaled[ch];
|
||||||
|
error += static_cast<uint32_t>(delta * delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error < bestError)
|
||||||
|
{
|
||||||
|
bestError = error;
|
||||||
|
bestColor = cmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aaTranslate[i][b] = static_cast<uint8_t>(bestColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
PortabilityLayer/AntiAliasTable.h
Normal file
16
PortabilityLayer/AntiAliasTable.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace PortabilityLayer
|
||||||
|
{
|
||||||
|
struct RGBAColor;
|
||||||
|
|
||||||
|
struct AntiAliasTable
|
||||||
|
{
|
||||||
|
// Striped 256x16 because constant background color is more likely than constant sample
|
||||||
|
uint8_t m_aaTranslate[256][16];
|
||||||
|
|
||||||
|
void GenerateForPalette(const RGBAColor &baseColor, const RGBAColor *colors, size_t numColors);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -24,8 +24,8 @@ namespace PortabilityLayer
|
|||||||
FontFamily *GetSystemFont(int textSize, int variationFlags) const override;
|
FontFamily *GetSystemFont(int textSize, int variationFlags) const override;
|
||||||
FontFamily *GetApplicationFont(int textSize, int variationFlags) const override;
|
FontFamily *GetApplicationFont(int textSize, int variationFlags) const override;
|
||||||
|
|
||||||
RenderedFont *GetRenderedFont(HostFont *font, int size, FontHacks fontHacks) override;
|
RenderedFont *GetRenderedFont(HostFont *font, int size, bool aa, FontHacks fontHacks) override;
|
||||||
RenderedFont *GetRenderedFontFromFamily(FontFamily *font, int size, int flags) override;
|
RenderedFont *GetRenderedFontFromFamily(FontFamily *font, int size, bool aa, int flags) override;
|
||||||
|
|
||||||
static FontManagerImpl *GetInstance();
|
static FontManagerImpl *GetInstance();
|
||||||
|
|
||||||
@@ -38,6 +38,7 @@ namespace PortabilityLayer
|
|||||||
const HostFont *m_font;
|
const HostFont *m_font;
|
||||||
int m_size;
|
int m_size;
|
||||||
uint32_t m_lastUsage;
|
uint32_t m_lastUsage;
|
||||||
|
bool m_aa;
|
||||||
};
|
};
|
||||||
|
|
||||||
FontManagerImpl();
|
FontManagerImpl();
|
||||||
@@ -109,7 +110,7 @@ namespace PortabilityLayer
|
|||||||
return m_applicationFont;
|
return m_applicationFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFont *FontManagerImpl::GetRenderedFont(HostFont *font, int size, FontHacks fontHacks)
|
RenderedFont *FontManagerImpl::GetRenderedFont(HostFont *font, int size, bool aa, FontHacks fontHacks)
|
||||||
{
|
{
|
||||||
CachedRenderedFont *newCacheSlot = &m_cachedRenderedFonts[0];
|
CachedRenderedFont *newCacheSlot = &m_cachedRenderedFonts[0];
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ namespace PortabilityLayer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crf.m_font == font && crf.m_size == size)
|
if (crf.m_font == font && crf.m_size == size && crf.m_aa == aa)
|
||||||
{
|
{
|
||||||
crf.m_lastUsage = m_usageCounter;
|
crf.m_lastUsage = m_usageCounter;
|
||||||
RenderedFont *rf = crf.m_rfont;
|
RenderedFont *rf = crf.m_rfont;
|
||||||
@@ -138,7 +139,7 @@ namespace PortabilityLayer
|
|||||||
newCacheSlot = &crf;
|
newCacheSlot = &crf;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFont *rfont = FontRenderer::GetInstance()->RenderFont(font, size, fontHacks);
|
RenderedFont *rfont = FontRenderer::GetInstance()->RenderFont(font, size, aa, fontHacks);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -149,6 +150,7 @@ namespace PortabilityLayer
|
|||||||
newCacheSlot->m_lastUsage = m_usageCounter;
|
newCacheSlot->m_lastUsage = m_usageCounter;
|
||||||
newCacheSlot->m_size = size;
|
newCacheSlot->m_size = size;
|
||||||
newCacheSlot->m_rfont = rfont;
|
newCacheSlot->m_rfont = rfont;
|
||||||
|
newCacheSlot->m_aa = aa;
|
||||||
|
|
||||||
if (m_usageCounter == UINT32_MAX)
|
if (m_usageCounter == UINT32_MAX)
|
||||||
ResetUsageCounter();
|
ResetUsageCounter();
|
||||||
@@ -158,7 +160,7 @@ namespace PortabilityLayer
|
|||||||
return rfont;
|
return rfont;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFont *FontManagerImpl::GetRenderedFontFromFamily(FontFamily *fontFamily, int size, int flags)
|
RenderedFont *FontManagerImpl::GetRenderedFontFromFamily(FontFamily *fontFamily, int size, bool aa, int flags)
|
||||||
{
|
{
|
||||||
const int variation = fontFamily->GetVariationForFlags(flags);
|
const int variation = fontFamily->GetVariationForFlags(flags);
|
||||||
|
|
||||||
@@ -166,7 +168,7 @@ namespace PortabilityLayer
|
|||||||
if (!hostFont)
|
if (!hostFont)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFont(hostFont, size, fontFamily->GetHacksForVariation(variation));
|
return PortabilityLayer::FontManager::GetInstance()->GetRenderedFont(hostFont, size, aa, fontFamily->GetHacksForVariation(variation));
|
||||||
}
|
}
|
||||||
|
|
||||||
FontManagerImpl *FontManagerImpl::GetInstance()
|
FontManagerImpl *FontManagerImpl::GetInstance()
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ namespace PortabilityLayer
|
|||||||
virtual FontFamily *GetSystemFont(int fontSize, int variationFlags) const = 0;
|
virtual FontFamily *GetSystemFont(int fontSize, int variationFlags) const = 0;
|
||||||
virtual FontFamily *GetApplicationFont(int fontSize, int variationFlags) const = 0;
|
virtual FontFamily *GetApplicationFont(int fontSize, int variationFlags) const = 0;
|
||||||
|
|
||||||
virtual RenderedFont *GetRenderedFont(HostFont *font, int size, FontHacks fontHacks) = 0;
|
virtual RenderedFont *GetRenderedFont(HostFont *font, int size, bool aa, FontHacks fontHacks) = 0;
|
||||||
virtual RenderedFont *GetRenderedFontFromFamily(FontFamily *fontFamily, int fontSize, int flags) = 0;
|
virtual RenderedFont *GetRenderedFontFromFamily(FontFamily *fontFamily, int fontSize, bool aa, int flags) = 0;
|
||||||
|
|
||||||
static FontManager *GetInstance();
|
static FontManager *GetInstance();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,22 +23,24 @@ namespace PortabilityLayer
|
|||||||
bool GetGlyph(unsigned int character, const RenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const override;
|
bool GetGlyph(unsigned int character, const RenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const override;
|
||||||
const RenderedFontMetrics &GetMetrics() const override;
|
const RenderedFontMetrics &GetMetrics() const override;
|
||||||
size_t MeasureString(const uint8_t *chars, size_t len) const override;
|
size_t MeasureString(const uint8_t *chars, size_t len) const override;
|
||||||
|
bool IsAntiAliased() const override;
|
||||||
|
|
||||||
void Destroy() override;
|
void Destroy() override;
|
||||||
|
|
||||||
void SetCharData(unsigned int charID, const void *data, size_t dataOffset, const RenderedGlyphMetrics &metrics);
|
void SetCharData(unsigned int charID, const void *data, size_t dataOffset, const RenderedGlyphMetrics &metrics);
|
||||||
void SetFontMetrics(const RenderedFontMetrics &metrics);
|
void SetFontMetrics(const RenderedFontMetrics &metrics);
|
||||||
|
|
||||||
static RenderedFontImpl *Create(size_t glyphDataSize);
|
static RenderedFontImpl *Create(size_t glyphDataSize, bool aa);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit RenderedFontImpl(void *data);
|
RenderedFontImpl(void *data, bool aa);
|
||||||
~RenderedFontImpl();
|
~RenderedFontImpl();
|
||||||
|
|
||||||
size_t m_dataOffsets[256];
|
size_t m_dataOffsets[256];
|
||||||
RenderedGlyphMetrics m_glyphMetrics[256];
|
RenderedGlyphMetrics m_glyphMetrics[256];
|
||||||
|
|
||||||
RenderedFontMetrics m_fontMetrics;
|
RenderedFontMetrics m_fontMetrics;
|
||||||
|
bool m_isAntiAliased;
|
||||||
|
|
||||||
void *m_data;
|
void *m_data;
|
||||||
};
|
};
|
||||||
@@ -46,7 +48,7 @@ namespace PortabilityLayer
|
|||||||
class FontRendererImpl final : public FontRenderer
|
class FontRendererImpl final : public FontRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderedFont *RenderFont(HostFont *font, int size, FontHacks fontHacks) override;
|
RenderedFont *RenderFont(HostFont *font, int size, bool aa, FontHacks fontHacks) override;
|
||||||
|
|
||||||
static FontRendererImpl *GetInstance();
|
static FontRendererImpl *GetInstance();
|
||||||
|
|
||||||
@@ -71,7 +73,6 @@ namespace PortabilityLayer
|
|||||||
return m_fontMetrics;
|
return m_fontMetrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t RenderedFontImpl::MeasureString(const uint8_t *chars, size_t len) const
|
size_t RenderedFontImpl::MeasureString(const uint8_t *chars, size_t len) const
|
||||||
{
|
{
|
||||||
size_t measure = 0;
|
size_t measure = 0;
|
||||||
@@ -85,6 +86,11 @@ namespace PortabilityLayer
|
|||||||
return measure;
|
return measure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderedFontImpl::IsAntiAliased() const
|
||||||
|
{
|
||||||
|
return m_isAntiAliased;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderedFontImpl::Destroy()
|
void RenderedFontImpl::Destroy()
|
||||||
{
|
{
|
||||||
this->~RenderedFontImpl();
|
this->~RenderedFontImpl();
|
||||||
@@ -103,7 +109,7 @@ namespace PortabilityLayer
|
|||||||
m_fontMetrics = metrics;
|
m_fontMetrics = metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFontImpl *RenderedFontImpl::Create(size_t glyphDataSize)
|
RenderedFontImpl *RenderedFontImpl::Create(size_t glyphDataSize, bool aa)
|
||||||
{
|
{
|
||||||
size_t alignedPrefixSize = sizeof(RenderedFontImpl) + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
size_t alignedPrefixSize = sizeof(RenderedFontImpl) + GP_SYSTEM_MEMORY_ALIGNMENT - 1;
|
||||||
alignedPrefixSize -= alignedPrefixSize % GP_SYSTEM_MEMORY_ALIGNMENT;
|
alignedPrefixSize -= alignedPrefixSize % GP_SYSTEM_MEMORY_ALIGNMENT;
|
||||||
@@ -119,11 +125,12 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
memset(storage, 0, allocSize);
|
memset(storage, 0, allocSize);
|
||||||
|
|
||||||
return new (storage) RenderedFontImpl(static_cast<uint8_t*>(storage) + alignedPrefixSize);
|
return new (storage) RenderedFontImpl(static_cast<uint8_t*>(storage) + alignedPrefixSize, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFontImpl::RenderedFontImpl(void *data)
|
RenderedFontImpl::RenderedFontImpl(void *data, bool aa)
|
||||||
: m_data(data)
|
: m_data(data)
|
||||||
|
, m_isAntiAliased(aa)
|
||||||
{
|
{
|
||||||
memset(m_glyphMetrics, 0, sizeof(m_glyphMetrics));
|
memset(m_glyphMetrics, 0, sizeof(m_glyphMetrics));
|
||||||
memset(&m_fontMetrics, 0, sizeof(m_fontMetrics));
|
memset(&m_fontMetrics, 0, sizeof(m_fontMetrics));
|
||||||
@@ -134,7 +141,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFont *FontRendererImpl::RenderFont(HostFont *font, int size, FontHacks fontHacks)
|
RenderedFont *FontRendererImpl::RenderFont(HostFont *font, int size, bool aa, FontHacks fontHacks)
|
||||||
{
|
{
|
||||||
const unsigned int numCharacters = 256;
|
const unsigned int numCharacters = 256;
|
||||||
|
|
||||||
@@ -156,7 +163,7 @@ namespace PortabilityLayer
|
|||||||
if (unicodeCodePoint == 0xffff)
|
if (unicodeCodePoint == 0xffff)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
glyphs[i] = font->Render(unicodeCodePoint, size);
|
glyphs[i] = font->Render(unicodeCodePoint, size, aa);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t glyphDataSize = GP_SYSTEM_MEMORY_ALIGNMENT; // So we can use 0 to mean no data
|
size_t glyphDataSize = GP_SYSTEM_MEMORY_ALIGNMENT; // So we can use 0 to mean no data
|
||||||
@@ -170,7 +177,7 @@ namespace PortabilityLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderedFontImpl *rfont = RenderedFontImpl::Create(glyphDataSize);
|
RenderedFontImpl *rfont = RenderedFontImpl::Create(glyphDataSize, aa);
|
||||||
if (rfont)
|
if (rfont)
|
||||||
{
|
{
|
||||||
size_t fillOffset = GP_SYSTEM_MEMORY_ALIGNMENT;
|
size_t fillOffset = GP_SYSTEM_MEMORY_ALIGNMENT;
|
||||||
@@ -185,7 +192,7 @@ namespace PortabilityLayer
|
|||||||
RenderedGlyphMetrics metrics = glyph->GetMetrics();
|
RenderedGlyphMetrics metrics = glyph->GetMetrics();
|
||||||
const void *data = glyph->GetData();
|
const void *data = glyph->GetData();
|
||||||
|
|
||||||
if (fontHacks == FontHacks_Roboto)
|
if (fontHacks == FontHacks_Roboto && !aa)
|
||||||
{
|
{
|
||||||
if (size < 32)
|
if (size < 32)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace PortabilityLayer
|
|||||||
class FontRenderer
|
class FontRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual RenderedFont *RenderFont(HostFont *font, int size, FontHacks fontHacks) = 0;
|
virtual RenderedFont *RenderFont(HostFont *font, int size, bool aa, FontHacks fontHacks) = 0;
|
||||||
|
|
||||||
static FontRenderer *GetInstance();
|
static FontRenderer *GetInstance();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Destroy() = 0;
|
virtual void Destroy() = 0;
|
||||||
virtual HostFontRenderedGlyph *Render(uint32_t unicodeCodePoint, unsigned int size) = 0;
|
virtual HostFontRenderedGlyph *Render(uint32_t unicodeCodePoint, unsigned int size, bool aa) = 0;
|
||||||
virtual bool GetLineSpacing(unsigned int size, int32_t &outSpacing) = 0;
|
virtual bool GetLineSpacing(unsigned int size, int32_t &outSpacing) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ namespace PortabilityLayer
|
|||||||
if (menuHdl != selectedMenuHdl)
|
if (menuHdl != selectedMenuHdl)
|
||||||
{
|
{
|
||||||
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
|
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
|
||||||
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)));
|
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ namespace PortabilityLayer
|
|||||||
size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding;
|
size_t xCoordinate = menu->cumulativeOffset + (menu->menuIndex * 2) * kMenuBarItemPadding + kMenuBarInitialPadding;
|
||||||
|
|
||||||
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
|
const Point itemPos = Point::Create(static_cast<int16_t>(xCoordinate), kMenuBarTextYOffset);
|
||||||
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)));
|
graf->DrawString(itemPos, PLPasStr(static_cast<const uint8_t*>(menu->stringBlobHandle->m_contents)), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,7 +835,7 @@ namespace PortabilityLayer
|
|||||||
if (!fontFamily)
|
if (!fontFamily)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, kMenuFontSize, kMenuFontFlags);
|
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, kMenuFontSize, true, kMenuFontFlags);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ namespace PortabilityLayer
|
|||||||
if (!fontFamily)
|
if (!fontFamily)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, kMenuFontSize, kMenuFontFlags);
|
PortabilityLayer::RenderedFont *rfont = PortabilityLayer::FontManager::GetInstance()->GetRenderedFontFromFamily(fontFamily, kMenuFontSize, true, kMenuFontFlags);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1132,7 +1132,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
|
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
|
||||||
|
|
||||||
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob));
|
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_haveItem)
|
if (m_haveItem)
|
||||||
@@ -1148,7 +1148,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
|
itemPos.v = item.layoutYOffset + kMenuItemTextYOffset;
|
||||||
|
|
||||||
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob));
|
surface->DrawString(itemPos, PLPasStr(strBlob + item.nameOffsetInStringBlob), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_menuGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
|
m_menuGraf->m_port.SetDirty(QDPortDirtyFlag_Contents);
|
||||||
|
|||||||
@@ -62,6 +62,6 @@ namespace PortabilityLayer
|
|||||||
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
||||||
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(surface->MeasureString(m_text.ToShortStr()))) / 2;
|
int32_t x = (m_rect.left + m_rect.right - static_cast<int32_t>(surface->MeasureString(m_text.ToShortStr()))) / 2;
|
||||||
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(surface->MeasureFontAscender())) / 2;
|
int32_t y = (m_rect.top + m_rect.bottom + static_cast<int32_t>(surface->MeasureFontAscender())) / 2;
|
||||||
surface->DrawString(Point::Create(x, y), m_text.ToShortStr());
|
surface->DrawString(Point::Create(x, y), m_text.ToShortStr(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ namespace PortabilityLayer
|
|||||||
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
|
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
|
||||||
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
|
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
|
||||||
|
|
||||||
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr());
|
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -498,7 +498,8 @@ void GetForeColor(RGBColor *color)
|
|||||||
*color = RGBColor(foreColor.r, foreColor.g, foreColor.b);
|
*color = RGBColor(foreColor.r, foreColor.g, foreColor.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character)
|
static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const Rect &rect, Point &penPos, const PortabilityLayer::RenderedFont *rfont, unsigned int character,
|
||||||
|
PortabilityLayer::AntiAliasTable *&cachedAATable, PortabilityLayer::RGBAColor &cachedAATableColor)
|
||||||
{
|
{
|
||||||
assert(rect.IsValid());
|
assert(rect.IsValid());
|
||||||
|
|
||||||
@@ -537,12 +538,41 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
|
|||||||
const size_t outputPitch = pixMap->m_pitch;
|
const size_t outputPitch = pixMap->m_pitch;
|
||||||
const uint8_t *firstInputRowData = static_cast<const uint8_t*>(data) + firstInputRow * inputPitch;
|
const uint8_t *firstInputRowData = static_cast<const uint8_t*>(data) + firstInputRow * inputPitch;
|
||||||
|
|
||||||
|
const bool isAA = rfont->IsAntiAliased();
|
||||||
|
|
||||||
switch (pixMap->m_pixelFormat)
|
switch (pixMap->m_pixelFormat)
|
||||||
{
|
{
|
||||||
case GpPixelFormats::k8BitStandard:
|
case GpPixelFormats::k8BitStandard:
|
||||||
{
|
{
|
||||||
uint8_t *firstOutputRowData = static_cast<uint8_t*>(pixMap->m_data) + firstOutputRow * outputPitch;
|
uint8_t *firstOutputRowData = static_cast<uint8_t*>(pixMap->m_data) + firstOutputRow * outputPitch;
|
||||||
|
|
||||||
|
const PortabilityLayer::AntiAliasTable *aaTable = nullptr;
|
||||||
|
|
||||||
|
if (isAA)
|
||||||
|
{
|
||||||
|
const PortabilityLayer::RGBAColor foreColor = qdState->GetForeColor();
|
||||||
|
if (foreColor == PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||||
|
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetBlackAATable();
|
||||||
|
else if (foreColor == PortabilityLayer::RGBAColor::Create(255, 255, 255, 255))
|
||||||
|
aaTable = &PortabilityLayer::StandardPalette::GetInstance()->GetWhiteAATable();
|
||||||
|
else if (cachedAATable != nullptr && foreColor == cachedAATableColor)
|
||||||
|
aaTable = cachedAATable;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!cachedAATable)
|
||||||
|
{
|
||||||
|
cachedAATable = static_cast<PortabilityLayer::AntiAliasTable*>(PortabilityLayer::MemoryManager::GetInstance()->Alloc(sizeof(PortabilityLayer::AntiAliasTable)));
|
||||||
|
if (!cachedAATable)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cachedAATableColor = foreColor;
|
||||||
|
cachedAATable->GenerateForPalette(foreColor, PortabilityLayer::StandardPalette::GetInstance()->GetColors(), 256);
|
||||||
|
|
||||||
|
aaTable = cachedAATable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
const uint8_t color = qdState->ResolveForeColor8(nullptr, 0);
|
||||||
for (uint32_t row = 0; row < numRows; row++)
|
for (uint32_t row = 0; row < numRows; row++)
|
||||||
{
|
{
|
||||||
@@ -550,11 +580,26 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
|
|||||||
uint8_t *outputRowData = firstOutputRowData + row * outputPitch;
|
uint8_t *outputRowData = firstOutputRowData + row * outputPitch;
|
||||||
|
|
||||||
// It should be possible to speed this up, if needed. The input is guaranteed to be well-aligned and not mutable within this loop.
|
// It should be possible to speed this up, if needed. The input is guaranteed to be well-aligned and not mutable within this loop.
|
||||||
for (uint32_t col = 0; col < numCols; col++)
|
if (isAA)
|
||||||
{
|
{
|
||||||
const size_t inputOffset = firstInputCol + col;
|
for (uint32_t col = 0; col < numCols; col++)
|
||||||
if (inputRowData[inputOffset / 8] & (1 << (inputOffset & 0x7)))
|
{
|
||||||
outputRowData[firstOutputCol + col] = color;
|
const size_t inputOffset = firstInputCol + col;
|
||||||
|
|
||||||
|
const unsigned int grayLevel = (inputRowData[inputOffset / 2] >> ((inputOffset & 1) * 4)) & 0xf;
|
||||||
|
uint8_t &targetPixel = outputRowData[firstOutputCol + col];
|
||||||
|
|
||||||
|
targetPixel = aaTable->m_aaTranslate[targetPixel][grayLevel];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (uint32_t col = 0; col < numCols; col++)
|
||||||
|
{
|
||||||
|
const size_t inputOffset = firstInputCol + col;
|
||||||
|
if (inputRowData[inputOffset / 8] & (1 << (inputOffset & 0x7)))
|
||||||
|
outputRowData[firstOutputCol + col] = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -564,7 +609,7 @@ static void DrawGlyph(PortabilityLayer::QDState *qdState, PixMap *pixMap, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSurface::DrawString(const Point &point, const PLPasStr &str)
|
void DrawSurface::DrawString(const Point &point, const PLPasStr &str, bool aa)
|
||||||
{
|
{
|
||||||
PortabilityLayer::QDPort *port = &m_port;
|
PortabilityLayer::QDPort *port = &m_port;
|
||||||
|
|
||||||
@@ -576,7 +621,7 @@ void DrawSurface::DrawString(const Point &point, const PLPasStr &str)
|
|||||||
const int fontVariationFlags = qdState->m_fontVariationFlags;
|
const int fontVariationFlags = qdState->m_fontVariationFlags;
|
||||||
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
|
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, fontVariationFlags);
|
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
|
||||||
|
|
||||||
Point penPos = point;
|
Point penPos = point;
|
||||||
const size_t len = str.Length();
|
const size_t len = str.Length();
|
||||||
@@ -599,13 +644,13 @@ void DrawSurface::DrawString(const Point &point, const PLPasStr &str)
|
|||||||
penPos = paraStartPos;
|
penPos = paraStartPos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DrawGlyph(qdState, pixMap, rect, penPos, rfont, chars[i]);
|
DrawGlyph(qdState, pixMap, rect, penPos, rfont, chars[i], m_cachedAATable, m_cachedAAColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str)
|
void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa)
|
||||||
{
|
{
|
||||||
PortabilityLayer::QDPort *port = &m_port;
|
PortabilityLayer::QDPort *port = &m_port;
|
||||||
|
|
||||||
@@ -617,7 +662,7 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
|
|||||||
const int fontVariationFlags = qdState->m_fontVariationFlags;
|
const int fontVariationFlags = qdState->m_fontVariationFlags;
|
||||||
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
|
PortabilityLayer::FontFamily *fontFamily = qdState->m_fontFamily;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, fontVariationFlags);
|
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, aa, fontVariationFlags);
|
||||||
|
|
||||||
Point penPos = point;
|
Point penPos = point;
|
||||||
const size_t len = str.Length();
|
const size_t len = str.Length();
|
||||||
@@ -703,7 +748,7 @@ void DrawSurface::DrawStringWrap(const Point &point, const Rect &constrainRect,
|
|||||||
{
|
{
|
||||||
const uint8_t character = chars[currentStartChar + ci];
|
const uint8_t character = chars[currentStartChar + ci];
|
||||||
|
|
||||||
DrawGlyph(qdState, pixMap, pixMap->m_rect, penPos, rfont, character);
|
DrawGlyph(qdState, pixMap, pixMap->m_rect, penPos, rfont, character, m_cachedAATable, m_cachedAAColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStartChar += committedLength;
|
currentStartChar += committedLength;
|
||||||
@@ -728,7 +773,7 @@ size_t DrawSurface::MeasureString(const PLPasStr &str)
|
|||||||
const int variationFlags = qdState->m_fontVariationFlags;
|
const int variationFlags = qdState->m_fontVariationFlags;
|
||||||
const int fontSize = qdState->m_fontSize;
|
const int fontSize = qdState->m_fontSize;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, variationFlags);
|
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -748,7 +793,7 @@ int32_t DrawSurface::MeasureFontAscender()
|
|||||||
const int variationFlags = qdState->m_fontVariationFlags;
|
const int variationFlags = qdState->m_fontVariationFlags;
|
||||||
const int fontSize = qdState->m_fontSize;
|
const int fontSize = qdState->m_fontSize;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, variationFlags);
|
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -768,7 +813,7 @@ int32_t DrawSurface::MeasureFontLineGap()
|
|||||||
const int variationFlags = qdState->m_fontVariationFlags;
|
const int variationFlags = qdState->m_fontVariationFlags;
|
||||||
const int fontSize = qdState->m_fontSize;
|
const int fontSize = qdState->m_fontSize;
|
||||||
|
|
||||||
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, variationFlags);
|
PortabilityLayer::RenderedFont *rfont = fontManager->GetRenderedFontFromFamily(fontFamily, fontSize, false, variationFlags);
|
||||||
if (!rfont)
|
if (!rfont)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace PortabilityLayer
|
|||||||
surface->SetForeColor(StdColors::Black());
|
surface->SetForeColor(StdColors::Black());
|
||||||
surface->SetSystemFont(12, FontFamilyFlag_Bold);
|
surface->SetSystemFont(12, FontFamilyFlag_Bold);
|
||||||
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
|
int32_t textV = (m_rect.top + m_rect.bottom + surface->MeasureFontAscender()) / 2;
|
||||||
surface->DrawString(Point::Create(m_rect.left + radioFrameSize + 2, textV), m_text.ToShortStr());
|
surface->DrawString(Point::Create(m_rect.left + radioFrameSize + 2, textV), m_text.ToShortStr(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioButtonWidget::SetString(const PLPasStr &str)
|
void RadioButtonWidget::SetString(const PLPasStr &str)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "ResourceManager.h"
|
#include "ResourceManager.h"
|
||||||
#include "VirtualDirectory.h"
|
|
||||||
|
#include "BMPFormat.h"
|
||||||
#include "FileManager.h"
|
#include "FileManager.h"
|
||||||
#include "GPArchive.h"
|
#include "GPArchive.h"
|
||||||
#include "HostFileSystem.h"
|
#include "HostFileSystem.h"
|
||||||
@@ -14,10 +15,67 @@
|
|||||||
#include "ResourceFile.h"
|
#include "ResourceFile.h"
|
||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "PLErrorCodes.h"
|
#include "PLErrorCodes.h"
|
||||||
|
#include "VirtualDirectory.h"
|
||||||
|
#include "WaveFormat.h"
|
||||||
#include "ZipFileProxy.h"
|
#include "ZipFileProxy.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace ResourceValidationRules
|
||||||
|
{
|
||||||
|
enum ResourceValidationRule
|
||||||
|
{
|
||||||
|
kNone,
|
||||||
|
kWAV,
|
||||||
|
kBMP,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef ResourceValidationRules::ResourceValidationRule ResourceValidationRule_t;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// Validation is only intended to validate enough of the file structure that constrained validation can be performed
|
||||||
|
// without needing to pass the file size
|
||||||
|
static bool ValidateResource(const void *res, size_t size, ResourceValidationRule_t validationRule)
|
||||||
|
{
|
||||||
|
switch (validationRule)
|
||||||
|
{
|
||||||
|
case ResourceValidationRules::kWAV:
|
||||||
|
{
|
||||||
|
if (size < sizeof(PortabilityLayer::RIFFTag))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PortabilityLayer::RIFFTag mainTag;
|
||||||
|
memcpy(&mainTag, res, sizeof(mainTag));
|
||||||
|
if (mainTag.m_chunkSize > size - sizeof(sizeof(PortabilityLayer::RIFFTag)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ResourceValidationRules::kBMP:
|
||||||
|
{
|
||||||
|
if (size < sizeof(PortabilityLayer::BitmapFileHeader))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PortabilityLayer::BitmapFileHeader mainHeader;
|
||||||
|
memcpy(&mainHeader, res, sizeof(mainHeader));
|
||||||
|
if (mainHeader.m_fileSize > size)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
struct MMHandleBlock;
|
struct MMHandleBlock;
|
||||||
@@ -315,6 +373,14 @@ namespace PortabilityLayer
|
|||||||
THandle<void> ResourceArchive::GetResource(const ResTypeID &resTypeID, int id, bool load)
|
THandle<void> ResourceArchive::GetResource(const ResTypeID &resTypeID, int id, bool load)
|
||||||
{
|
{
|
||||||
const char *extension = ".bin";
|
const char *extension = ".bin";
|
||||||
|
ResourceValidationRule_t validationRule = ResourceValidationRules::kNone;
|
||||||
|
|
||||||
|
if (resTypeID == ResTypeID('snd '))
|
||||||
|
{
|
||||||
|
extension = ".wav";
|
||||||
|
validationRule = ResourceValidationRules::kWAV;
|
||||||
|
}
|
||||||
|
|
||||||
char resourceFile[64];
|
char resourceFile[64];
|
||||||
|
|
||||||
GpArcResourceTypeTag resTag = GpArcResourceTypeTag::Encode(resTypeID);
|
GpArcResourceTypeTag resTag = GpArcResourceTypeTag::Encode(resTypeID);
|
||||||
@@ -350,11 +416,13 @@ namespace PortabilityLayer
|
|||||||
handle->m_contents = contents;
|
handle->m_contents = contents;
|
||||||
handle->m_size = ref->m_size;
|
handle->m_size = ref->m_size;
|
||||||
|
|
||||||
if (!m_zipFileProxy->LoadFile(index, contents))
|
if (!m_zipFileProxy->LoadFile(index, contents) || (validationRule != ResourceValidationRules::kNone && !ValidateResource(contents, ref->m_size, validationRule)))
|
||||||
{
|
{
|
||||||
MemoryManager::GetInstance()->Release(contents);
|
MemoryManager::GetInstance()->Release(contents);
|
||||||
handle->m_contents = nullptr;
|
handle->m_contents = nullptr;
|
||||||
handle->m_size = 0;
|
handle->m_size = 0;
|
||||||
|
|
||||||
|
return THandle<void>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "HostMutex.h"
|
#include "HostMutex.h"
|
||||||
#include "HostSystemServices.h"
|
#include "HostSystemServices.h"
|
||||||
#include "HostThreadEvent.h"
|
#include "HostThreadEvent.h"
|
||||||
|
#include "WaveFormat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ namespace PortabilityLayer
|
|||||||
~AudioChannelImpl();
|
~AudioChannelImpl();
|
||||||
|
|
||||||
void Destroy(bool wait) override;
|
void Destroy(bool wait) override;
|
||||||
bool AddBuffer(const void *smBuffer, bool blocking) override;
|
bool AddBuffer(const void *lengthTaggedBuffer, bool blocking) override;
|
||||||
bool AddCallback(AudioChannelCallback_t callback, bool blocking) override;
|
bool AddCallback(AudioChannelCallback_t callback, bool blocking) override;
|
||||||
void ClearAllCommands() override;
|
void ClearAllCommands() override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
@@ -67,7 +68,6 @@ namespace PortabilityLayer
|
|||||||
void DigestBufferCommand(const void *dataPointer);
|
void DigestBufferCommand(const void *dataPointer);
|
||||||
|
|
||||||
PortabilityLayer::HostAudioChannel *m_audioChannel;
|
PortabilityLayer::HostAudioChannel *m_audioChannel;
|
||||||
;
|
|
||||||
|
|
||||||
HostMutex *m_mutex;
|
HostMutex *m_mutex;
|
||||||
HostThreadEvent *m_threadEvent;
|
HostThreadEvent *m_threadEvent;
|
||||||
@@ -145,11 +145,11 @@ namespace PortabilityLayer
|
|||||||
PortabilityLayer::MemoryManager::GetInstance()->Release(this);
|
PortabilityLayer::MemoryManager::GetInstance()->Release(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioChannelImpl::AddBuffer(const void *smBuffer, bool blocking)
|
bool AudioChannelImpl::AddBuffer(const void *lengthTaggedBuffer, bool blocking)
|
||||||
{
|
{
|
||||||
AudioCommand cmd;
|
AudioCommand cmd;
|
||||||
cmd.m_commandType = AudioCommandTypes::kBuffer;
|
cmd.m_commandType = AudioCommandTypes::kBuffer;
|
||||||
cmd.m_param.m_ptr = smBuffer;
|
cmd.m_param.m_ptr = lengthTaggedBuffer;
|
||||||
|
|
||||||
return this->PushCommand(cmd, blocking);
|
return this->PushCommand(cmd, blocking);
|
||||||
}
|
}
|
||||||
@@ -195,26 +195,11 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
void AudioChannelImpl::DigestBufferCommand(const void *dataPointer)
|
void AudioChannelImpl::DigestBufferCommand(const void *dataPointer)
|
||||||
{
|
{
|
||||||
struct BufferHeader
|
// At this point, the buffer should already be validated and converted, and the data pointer should point at the data tag
|
||||||
{
|
uint32_t length;
|
||||||
BEUInt32_t m_samplePtr;
|
memcpy(&length, dataPointer, 4);
|
||||||
BEUInt32_t m_length;
|
|
||||||
BEFixed32_t m_sampleRate;
|
|
||||||
BEUInt32_t m_loopStart;
|
|
||||||
BEUInt32_t m_loopEnd;
|
|
||||||
uint8_t m_encoding;
|
|
||||||
uint8_t m_baseFrequency;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferHeader bufferHeader;
|
m_audioChannel->PostBuffer(static_cast<const uint8_t*>(dataPointer) + 4, length);
|
||||||
|
|
||||||
GP_STATIC_ASSERT(sizeof(BufferHeader) >= 22);
|
|
||||||
|
|
||||||
memcpy(&bufferHeader, dataPointer, 22);
|
|
||||||
|
|
||||||
const uint32_t length = bufferHeader.m_length;
|
|
||||||
|
|
||||||
m_audioChannel->PostBuffer(static_cast<const uint8_t*>(dataPointer) + 22, length);
|
|
||||||
m_state = State_PlayingAsync;
|
m_state = State_PlayingAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace PortabilityLayer
|
|||||||
struct AudioChannel
|
struct AudioChannel
|
||||||
{
|
{
|
||||||
virtual void Destroy(bool wait) = 0;
|
virtual void Destroy(bool wait) = 0;
|
||||||
virtual bool AddBuffer(const void *smBuffer, bool blocking) = 0;
|
virtual bool AddBuffer(const void *lengthTaggedBuffer, bool blocking) = 0;
|
||||||
virtual bool AddCallback(AudioChannelCallback_t callback, bool blocking) = 0;
|
virtual bool AddCallback(AudioChannelCallback_t callback, bool blocking) = 0;
|
||||||
virtual void ClearAllCommands() = 0;
|
virtual void ClearAllCommands() = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
|
|||||||
@@ -138,6 +138,7 @@
|
|||||||
<ClInclude Include="..\GpCommon\GpBitfield.h" />
|
<ClInclude Include="..\GpCommon\GpBitfield.h" />
|
||||||
<ClInclude Include="AEHandlerDesc.h" />
|
<ClInclude Include="AEHandlerDesc.h" />
|
||||||
<ClInclude Include="AEManager.h" />
|
<ClInclude Include="AEManager.h" />
|
||||||
|
<ClInclude Include="AntiAliasTable.h" />
|
||||||
<ClInclude Include="BinarySearch.h" />
|
<ClInclude Include="BinarySearch.h" />
|
||||||
<ClInclude Include="BinHex4.h" />
|
<ClInclude Include="BinHex4.h" />
|
||||||
<ClInclude Include="BMPFormat.h" />
|
<ClInclude Include="BMPFormat.h" />
|
||||||
@@ -289,6 +290,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\stb\stb_image_write.c" />
|
<ClCompile Include="..\stb\stb_image_write.c" />
|
||||||
<ClCompile Include="AEManager.cpp" />
|
<ClCompile Include="AEManager.cpp" />
|
||||||
|
<ClCompile Include="AntiAliasTable.cpp" />
|
||||||
<ClCompile Include="BinHex4.cpp" />
|
<ClCompile Include="BinHex4.cpp" />
|
||||||
<ClCompile Include="ByteSwap.cpp" />
|
<ClCompile Include="ByteSwap.cpp" />
|
||||||
<ClCompile Include="CFileStream.cpp" />
|
<ClCompile Include="CFileStream.cpp" />
|
||||||
|
|||||||
@@ -465,6 +465,9 @@
|
|||||||
<ClInclude Include="DeflateCodec.h">
|
<ClInclude Include="DeflateCodec.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="AntiAliasTable.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="CFileStream.cpp">
|
<ClCompile Include="CFileStream.cpp">
|
||||||
@@ -725,5 +728,8 @@
|
|||||||
<ClCompile Include="DeflateCodec.cpp">
|
<ClCompile Include="DeflateCodec.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="AntiAliasTable.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "QDGraf.h"
|
#include "QDGraf.h"
|
||||||
|
|
||||||
|
#include "MemoryManager.h"
|
||||||
#include "QDPixMap.h"
|
#include "QDPixMap.h"
|
||||||
#include "QDPort.h"
|
#include "QDPort.h"
|
||||||
#include "IGpDisplayDriver.h"
|
#include "IGpDisplayDriver.h"
|
||||||
@@ -6,6 +8,8 @@
|
|||||||
|
|
||||||
DrawSurface::~DrawSurface()
|
DrawSurface::~DrawSurface()
|
||||||
{
|
{
|
||||||
|
if (m_cachedAATable)
|
||||||
|
PortabilityLayer::MemoryManager::GetInstance()->Release(m_cachedAATable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver)
|
void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
|
struct AntiAliasTable;
|
||||||
class FontFamily;
|
class FontFamily;
|
||||||
struct RGBAColor;
|
struct RGBAColor;
|
||||||
class ScanlineMask;
|
class ScanlineMask;
|
||||||
@@ -27,12 +28,16 @@ struct DrawSurface final
|
|||||||
DrawSurface()
|
DrawSurface()
|
||||||
: m_port(PortabilityLayer::QDPortType_DrawSurface)
|
: m_port(PortabilityLayer::QDPortType_DrawSurface)
|
||||||
, m_ddSurface(nullptr)
|
, m_ddSurface(nullptr)
|
||||||
|
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||||
|
, m_cachedAATable(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit DrawSurface(PortabilityLayer::QDPortType overridePortType)
|
explicit DrawSurface(PortabilityLayer::QDPortType overridePortType)
|
||||||
: m_port(overridePortType)
|
: m_port(overridePortType)
|
||||||
, m_ddSurface(nullptr)
|
, m_ddSurface(nullptr)
|
||||||
|
, m_cachedAAColor(PortabilityLayer::RGBAColor::Create(0, 0, 0, 255))
|
||||||
|
, m_cachedAATable(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,8 +81,8 @@ struct DrawSurface final
|
|||||||
|
|
||||||
void SetApplicationFont(int size, int variationFlags);
|
void SetApplicationFont(int size, int variationFlags);
|
||||||
void SetSystemFont(int size, int variationFlags);
|
void SetSystemFont(int size, int variationFlags);
|
||||||
void DrawString(const Point &point, const PLPasStr &str);
|
void DrawString(const Point &point, const PLPasStr &str, bool aa);
|
||||||
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str);
|
void DrawStringWrap(const Point &point, const Rect &constrainRect, const PLPasStr &str, bool aa);
|
||||||
|
|
||||||
size_t MeasureString(const PLPasStr &str);
|
size_t MeasureString(const PLPasStr &str);
|
||||||
int32_t MeasureFontAscender();
|
int32_t MeasureFontAscender();
|
||||||
@@ -93,8 +98,13 @@ struct DrawSurface final
|
|||||||
Rect GetClipRect() const;
|
Rect GetClipRect() const;
|
||||||
void SetClipRect(const Rect &rect);
|
void SetClipRect(const Rect &rect);
|
||||||
|
|
||||||
|
void RegenerateAATable(const PortabilityLayer::RGBAColor &color, const PortabilityLayer::RGBAColor *paletteColors, size_t numColors);
|
||||||
|
|
||||||
// Must be the first item
|
// Must be the first item
|
||||||
PortabilityLayer::QDPort m_port;
|
PortabilityLayer::QDPort m_port;
|
||||||
|
|
||||||
IGpDisplayDriverSurface *m_ddSurface;
|
IGpDisplayDriverSurface *m_ddSurface;
|
||||||
|
|
||||||
|
PortabilityLayer::AntiAliasTable *m_cachedAATable;
|
||||||
|
PortabilityLayer::RGBAColor m_cachedAAColor;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,7 +81,35 @@ namespace PortabilityLayer
|
|||||||
for (unsigned int rs = 0; rs < 16; rs++)
|
for (unsigned int rs = 0; rs < 16; rs++)
|
||||||
for (unsigned int gs = 0; gs < 16; gs++)
|
for (unsigned int gs = 0; gs < 16; gs++)
|
||||||
for (unsigned int bs = 0; bs < 16; bs++)
|
for (unsigned int bs = 0; bs < 16; bs++)
|
||||||
m_lut[rs + (gs << 4) + (bs << 8)] = MapColorAnalyticTruncated(rs, gs, bs);
|
m_lut[rs + (gs << 4) + (bs << 8)] = MapColorAnalyticTruncated(rs, gs, bs);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
unsigned int shortChannels[3] =
|
||||||
|
{
|
||||||
|
m_colors[i].r / 17,
|
||||||
|
m_colors[i].g / 17,
|
||||||
|
m_colors[i].b / 17
|
||||||
|
};
|
||||||
|
|
||||||
|
for (unsigned int b = 0; b < 16; b++)
|
||||||
|
{
|
||||||
|
unsigned int whiteScale[3];
|
||||||
|
unsigned int blackScale[3];
|
||||||
|
|
||||||
|
for (unsigned int ch = 0; ch < 3; ch++)
|
||||||
|
{
|
||||||
|
unsigned int scaledBackground = (15 - b) * shortChannels[ch];
|
||||||
|
unsigned int scaledWhiteForeground = 15 * b;
|
||||||
|
|
||||||
|
blackScale[ch] = scaledBackground / 15;
|
||||||
|
whiteScale[ch] = (scaledBackground + scaledWhiteForeground) / 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_blackAATable.m_aaTranslate[i][b] = MapColorAnalyticTruncated(blackScale[0], blackScale[1], blackScale[2]);
|
||||||
|
m_whiteAATable.m_aaTranslate[i][b] = MapColorAnalyticTruncated(whiteScale[0], whiteScale[1], whiteScale[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const RGBAColor *StandardPalette::GetColors() const
|
const RGBAColor *StandardPalette::GetColors() const
|
||||||
@@ -228,6 +256,16 @@ namespace PortabilityLayer
|
|||||||
const StandardPalette *StandardPalette::GetInstance()
|
const StandardPalette *StandardPalette::GetInstance()
|
||||||
{
|
{
|
||||||
return &ms_instance;
|
return &ms_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AntiAliasTable &StandardPalette::GetWhiteAATable() const
|
||||||
|
{
|
||||||
|
return m_whiteAATable;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AntiAliasTable &StandardPalette::GetBlackAATable() const
|
||||||
|
{
|
||||||
|
return m_blackAATable;
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardPalette StandardPalette::ms_instance;
|
StandardPalette StandardPalette::ms_instance;
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "AntiAliasTable.h"
|
||||||
#include "RGBAColor.h"
|
#include "RGBAColor.h"
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
|
struct AntiAliasTable;
|
||||||
|
|
||||||
class StandardPalette
|
class StandardPalette
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -16,14 +19,18 @@ namespace PortabilityLayer
|
|||||||
static uint8_t MapColorAnalytic(uint8_t r, uint8_t g, uint8_t b);
|
static uint8_t MapColorAnalytic(uint8_t r, uint8_t g, uint8_t b);
|
||||||
static uint8_t MapColorAnalytic(const RGBAColor &color);
|
static uint8_t MapColorAnalytic(const RGBAColor &color);
|
||||||
uint8_t MapColorLUT(uint8_t r, uint8_t g, uint8_t b) const;
|
uint8_t MapColorLUT(uint8_t r, uint8_t g, uint8_t b) const;
|
||||||
uint8_t MapColorLUT(const RGBAColor &color) const;
|
uint8_t MapColorLUT(const RGBAColor &color) const;
|
||||||
|
const AntiAliasTable &GetWhiteAATable() const;
|
||||||
|
const AntiAliasTable &GetBlackAATable() const;
|
||||||
|
|
||||||
static const StandardPalette *GetInstance();
|
static const StandardPalette *GetInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static StandardPalette ms_instance;
|
static StandardPalette ms_instance;
|
||||||
|
|
||||||
RGBAColor m_colors[kSize];
|
RGBAColor m_colors[kSize];
|
||||||
|
AntiAliasTable m_whiteAATable;
|
||||||
|
AntiAliasTable m_blackAATable;
|
||||||
uint8_t m_lut[16 * 16 * 16];
|
uint8_t m_lut[16 * 16 * 16];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
|
|
||||||
|
bool operator==(const RGBAColor &other) const;
|
||||||
|
bool operator!=(const RGBAColor &other) const;
|
||||||
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
static RGBAColor Create(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20,5 +22,15 @@ namespace PortabilityLayer
|
|||||||
color.a = a;
|
color.a = a;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool RGBAColor::operator==(const RGBAColor &other) const
|
||||||
|
{
|
||||||
|
return this->r == other.r && this->g == other.g && this->b == other.b && this->a == other.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool RGBAColor::operator!=(const RGBAColor &other) const
|
||||||
|
{
|
||||||
|
return !((*this) == other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace PortabilityLayer
|
|||||||
virtual bool GetGlyph(unsigned int character, const RenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const = 0;
|
virtual bool GetGlyph(unsigned int character, const RenderedGlyphMetrics *&outMetricsPtr, const void *&outData) const = 0;
|
||||||
virtual const RenderedFontMetrics &GetMetrics() const = 0;
|
virtual const RenderedFontMetrics &GetMetrics() const = 0;
|
||||||
virtual size_t MeasureString(const uint8_t *chars, size_t len) const = 0;
|
virtual size_t MeasureString(const uint8_t *chars, size_t len) const = 0;
|
||||||
|
virtual bool IsAntiAliased() const = 0;
|
||||||
|
|
||||||
virtual void Destroy() = 0;
|
virtual void Destroy() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "PLLittleEndian.h"
|
#include "PLLittleEndian.h"
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
@@ -10,9 +10,9 @@ namespace PortabilityLayer
|
|||||||
static const uint32_t kRiffChunkID = 0x46464952;
|
static const uint32_t kRiffChunkID = 0x46464952;
|
||||||
static const uint32_t kWaveChunkID = 0x45564157;
|
static const uint32_t kWaveChunkID = 0x45564157;
|
||||||
static const uint32_t kFormatChunkID = 0x20746d66;
|
static const uint32_t kFormatChunkID = 0x20746d66;
|
||||||
static const uint32_t kDataChunkID = 0x61746164;
|
static const uint32_t kDataChunkID = 0x61746164;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RIFFTag
|
struct RIFFTag
|
||||||
{
|
{
|
||||||
LEUInt32_t m_tag;
|
LEUInt32_t m_tag;
|
||||||
|
|||||||
@@ -490,8 +490,8 @@ bool BMPDumperContext::Export(std::vector<uint8_t> &outData) const
|
|||||||
PortabilityLayer::BitmapFileHeader fileHeader;
|
PortabilityLayer::BitmapFileHeader fileHeader;
|
||||||
fileHeader.m_id[0] = 'B';
|
fileHeader.m_id[0] = 'B';
|
||||||
fileHeader.m_id[1] = 'M';
|
fileHeader.m_id[1] = 'M';
|
||||||
fileHeader.m_fileSize = imageFileSize;
|
fileHeader.m_fileSize = static_cast<uint32_t>(imageFileSize);
|
||||||
fileHeader.m_imageDataStart = fileHeaderSize + infoHeaderSize + ctabSize + postCTabPaddingSize;
|
fileHeader.m_imageDataStart = static_cast<uint32_t>(fileHeaderSize + infoHeaderSize + ctabSize + postCTabPaddingSize);
|
||||||
fileHeader.m_reserved1 = 0;
|
fileHeader.m_reserved1 = 0;
|
||||||
fileHeader.m_reserved2 = 0;
|
fileHeader.m_reserved2 = 0;
|
||||||
|
|
||||||
@@ -499,12 +499,12 @@ bool BMPDumperContext::Export(std::vector<uint8_t> &outData) const
|
|||||||
|
|
||||||
PortabilityLayer::BitmapInfoHeader infoHeader;
|
PortabilityLayer::BitmapInfoHeader infoHeader;
|
||||||
infoHeader.m_thisStructureSize = sizeof(infoHeader);
|
infoHeader.m_thisStructureSize = sizeof(infoHeader);
|
||||||
infoHeader.m_width = width;
|
infoHeader.m_width = static_cast<uint32_t>(width);
|
||||||
infoHeader.m_height = height;
|
infoHeader.m_height = static_cast<uint32_t>(height);
|
||||||
infoHeader.m_planes = 1;
|
infoHeader.m_planes = 1;
|
||||||
infoHeader.m_bitsPerPixel = bpp;
|
infoHeader.m_bitsPerPixel = bpp;
|
||||||
infoHeader.m_compression = PortabilityLayer::BitmapConstants::kCompressionRGB;
|
infoHeader.m_compression = PortabilityLayer::BitmapConstants::kCompressionRGB;
|
||||||
infoHeader.m_imageSize = imageDataSize;
|
infoHeader.m_imageSize = static_cast<uint32_t>(imageDataSize);
|
||||||
infoHeader.m_xPixelsPerMeter = 2835;
|
infoHeader.m_xPixelsPerMeter = 2835;
|
||||||
infoHeader.m_yPixelsPerMeter = 2835;
|
infoHeader.m_yPixelsPerMeter = 2835;
|
||||||
infoHeader.m_numColors = (bpp < 16) ? numColors : 0;
|
infoHeader.m_numColors = (bpp < 16) ? numColors : 0;
|
||||||
@@ -669,7 +669,7 @@ bool ImportSound(std::vector<uint8_t> &outWAV, const void *inData, size_t inSize
|
|||||||
|
|
||||||
PortabilityLayer::RIFFTag riffTag;
|
PortabilityLayer::RIFFTag riffTag;
|
||||||
riffTag.m_tag = PortabilityLayer::WaveConstants::kRiffChunkID;
|
riffTag.m_tag = PortabilityLayer::WaveConstants::kRiffChunkID;
|
||||||
riffTag.m_chunkSize = waveMarkerSize + fmtTagSize + fmtContentSize + dataTagSize + dataContentSize;
|
riffTag.m_chunkSize = static_cast<uint32_t>(waveMarkerSize + fmtTagSize + fmtContentSize + dataTagSize + dataContentSize);
|
||||||
|
|
||||||
VectorAppend(outWAV, reinterpret_cast<const uint8_t*>(&riffTag), sizeof(riffTag));
|
VectorAppend(outWAV, reinterpret_cast<const uint8_t*>(&riffTag), sizeof(riffTag));
|
||||||
|
|
||||||
@@ -770,7 +770,9 @@ int main(int argc, const char **argv)
|
|||||||
if (ImportPICT(entry.m_contents, resData, resSize))
|
if (ImportPICT(entry.m_contents, resData, resSize))
|
||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
else if (typeList.m_resType == sndTypeID)
|
else
|
||||||
|
#endif
|
||||||
|
if (typeList.m_resType == sndTypeID)
|
||||||
{
|
{
|
||||||
PlannedEntry entry;
|
PlannedEntry entry;
|
||||||
char resName[256];
|
char resName[256];
|
||||||
@@ -782,7 +784,6 @@ int main(int argc, const char **argv)
|
|||||||
contents.push_back(entry);
|
contents.push_back(entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PlannedEntry entry;
|
PlannedEntry entry;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user