GRAPHICS/SJIS: fix out of bounds shadow mode text drawing
svn-id: r54080
This commit is contained in:
parent
206971d16b
commit
4457d10f84
2 changed files with 14 additions and 7 deletions
|
@ -53,7 +53,7 @@ FontSJIS *FontSJIS::createFont(const Common::Platform platform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Color>
|
template<typename Color>
|
||||||
void FontSJISBase::blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c1, Color c2) const {
|
void FontSJISBase::blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c1, Color c2, bool shadowClipRight, bool shadowClipBottom) const {
|
||||||
for (int y = 0; y < h; ++y) {
|
for (int y = 0; y < h; ++y) {
|
||||||
Color *d = (Color *)dst;
|
Color *d = (Color *)dst;
|
||||||
dst += pitch;
|
dst += pitch;
|
||||||
|
@ -65,9 +65,13 @@ void FontSJISBase::blitCharacter(const uint8 *glyph, const int w, const int h, u
|
||||||
|
|
||||||
if (mask & 0x80) {
|
if (mask & 0x80) {
|
||||||
*d = c1;
|
*d = c1;
|
||||||
if (_drawMode == kShadowMode || _drawMode == kFMTownsShadowMode)
|
if (_drawMode == kShadowMode || _drawMode == kFMTownsShadowMode) {
|
||||||
d[1] = d[pitch] = c2;
|
if (!(shadowClipRight && (x == w - 1)))
|
||||||
if (_drawMode == kShadowMode)
|
d[1] = c2;
|
||||||
|
if (!(shadowClipBottom && (y == h - 1)))
|
||||||
|
d[pitch] = c2;
|
||||||
|
}
|
||||||
|
if (_drawMode == kShadowMode && !(shadowClipRight && (x == w - 1)) && !(shadowClipBottom && (y == h - 1)))
|
||||||
d[pitch + 1] = c2;
|
d[pitch + 1] = c2;
|
||||||
}
|
}
|
||||||
++d;
|
++d;
|
||||||
|
@ -143,6 +147,7 @@ void FontSJISBase::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1,
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
int outlineExtraWidth = 2, outlineExtraHeight = 2;
|
int outlineExtraWidth = 2, outlineExtraHeight = 2;
|
||||||
int outlineXOffset = 0, outlineYOffset = 0;
|
int outlineXOffset = 0, outlineYOffset = 0;
|
||||||
|
bool shadowClipRight = false, shadowClipBottom = false;
|
||||||
|
|
||||||
if (is8x16(ch)) {
|
if (is8x16(ch)) {
|
||||||
glyphSource = getCharData8x16(ch);
|
glyphSource = getCharData8x16(ch);
|
||||||
|
@ -158,12 +163,14 @@ void FontSJISBase::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1,
|
||||||
width = maxW;
|
width = maxW;
|
||||||
outlineExtraWidth = 0;
|
outlineExtraWidth = 0;
|
||||||
outlineXOffset = 1;
|
outlineXOffset = 1;
|
||||||
|
shadowClipRight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxH != -1 && maxH < height) {
|
if (maxH != -1 && maxH < height) {
|
||||||
height = maxH;
|
height = maxH;
|
||||||
outlineExtraHeight = 0;
|
outlineExtraHeight = 0;
|
||||||
outlineYOffset = 1;
|
outlineYOffset = 1;
|
||||||
|
shadowClipBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width <= 0 || height <= 0)
|
if (width <= 0 || height <= 0)
|
||||||
|
@ -190,14 +197,14 @@ void FontSJISBase::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1,
|
||||||
blitCharacter<uint8>(outline, width + outlineExtraWidth, height + outlineExtraHeight, (uint8 *)dst, pitch, c2);
|
blitCharacter<uint8>(outline, width + outlineExtraWidth, height + outlineExtraHeight, (uint8 *)dst, pitch, c2);
|
||||||
blitCharacter<uint8>(glyphSource, width - outlineXOffset, height - outlineYOffset, (uint8 *)dst + pitch + 1, pitch, c1);
|
blitCharacter<uint8>(glyphSource, width - outlineXOffset, height - outlineYOffset, (uint8 *)dst + pitch + 1, pitch, c1);
|
||||||
} else {
|
} else {
|
||||||
blitCharacter<uint8>(glyphSource, width, height, (uint8 *)dst, pitch, c1, c2);
|
blitCharacter<uint8>(glyphSource, width, height, (uint8 *)dst, pitch, c1, c2, shadowClipRight, shadowClipBottom);
|
||||||
}
|
}
|
||||||
} else if (bpp == 2) {
|
} else if (bpp == 2) {
|
||||||
if (_drawMode == kOutlineMode) {
|
if (_drawMode == kOutlineMode) {
|
||||||
blitCharacter<uint16>(outline, width + outlineExtraWidth, height + outlineExtraHeight, (uint8 *)dst, pitch, c2);
|
blitCharacter<uint16>(outline, width + outlineExtraWidth, height + outlineExtraHeight, (uint8 *)dst, pitch, c2);
|
||||||
blitCharacter<uint16>(glyphSource, width - outlineXOffset, height - outlineYOffset, (uint8 *)dst + pitch + 2, pitch, c1);
|
blitCharacter<uint16>(glyphSource, width - outlineXOffset, height - outlineYOffset, (uint8 *)dst + pitch + 2, pitch, c1);
|
||||||
} else {
|
} else {
|
||||||
blitCharacter<uint16>(glyphSource, width, height, (uint8 *)dst, pitch, c1, c2);
|
blitCharacter<uint16>(glyphSource, width, height, (uint8 *)dst, pitch, c1, c2, shadowClipRight, shadowClipBottom);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error("FontSJISBase::drawChar: unsupported bpp: %d", bpp);
|
error("FontSJISBase::drawChar: unsupported bpp: %d", bpp);
|
||||||
|
|
|
@ -155,7 +155,7 @@ public:
|
||||||
void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW = -1, int maxH = -1) const;
|
void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2, int maxW = -1, int maxH = -1) const;
|
||||||
private:
|
private:
|
||||||
template<typename Color>
|
template<typename Color>
|
||||||
void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c1, Color c2 = 0) const;
|
void blitCharacter(const uint8 *glyph, const int w, const int h, uint8 *dst, int pitch, Color c1, Color c2 = 0, bool clipShadowRight = false, bool clipShadowBottom = false) const;
|
||||||
void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
|
void createOutline(uint8 *outline, const uint8 *glyph, const int w, const int h) const;
|
||||||
|
|
||||||
#ifndef DISABLE_FLIPPED_MODE
|
#ifndef DISABLE_FLIPPED_MODE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue