diff options
author | craigsc | 2020-01-11 12:08:21 -0800 |
---|---|---|
committer | craigsc | 2020-01-11 12:08:21 -0800 |
commit | 3dd4fb16f017a8eab5c6c11fd119a397b457866e (patch) | |
tree | 5b80b5c5038d8577c2d674a5a4742b335deca515 /graphics | |
parent | f9f81ea9baecb714f26cf1c17a1b0ae58431467b (diff) | |
parent | 5893672b80f00fced33c42e63471d68ba47d7dd4 (diff) | |
download | scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.gz scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.tar.bz2 scummvm-rg350-3dd4fb16f017a8eab5c6c11fd119a397b457866e.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/fonts/bdf.cpp | 6 | ||||
-rw-r--r-- | graphics/fonts/macfont.cpp | 205 | ||||
-rw-r--r-- | graphics/fonts/macfont.h | 2 | ||||
-rw-r--r-- | graphics/fonts/winfont.cpp | 55 | ||||
-rw-r--r-- | graphics/fonts/winfont.h | 4 | ||||
-rw-r--r-- | graphics/macgui/macfontmanager.cpp | 51 | ||||
-rw-r--r-- | graphics/macgui/macmenu.cpp | 5 | ||||
-rw-r--r-- | graphics/macgui/macmenu.h | 4 | ||||
-rw-r--r-- | graphics/macgui/mactext.cpp | 16 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.cpp | 6 | ||||
-rw-r--r-- | graphics/macgui/macwindowmanager.h | 6 | ||||
-rw-r--r-- | graphics/primitives.cpp | 4 | ||||
-rw-r--r-- | graphics/transparent_surface.cpp | 13 | ||||
-rw-r--r-- | graphics/wincursor.cpp | 64 | ||||
-rw-r--r-- | graphics/wincursor.h | 8 |
15 files changed, 267 insertions, 182 deletions
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp index 4374c36ff4..d901d1bb8c 100644 --- a/graphics/fonts/bdf.cpp +++ b/graphics/fonts/bdf.cpp @@ -767,17 +767,17 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) { byte b = 0; for (int x = 0; x < box.width; x++) { + b <<= 1; + int sx = (int)((float)x / scale); if (srcd[sx / 8] & (0x80 >> (sx % 8))) b |= 1; - if (!(x % 8) && x) { + if (x % 8 == 7) { *dst++ = b; b = 0; } - - b <<= 1; } if (((box.width - 1) % 8)) { diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp index 4264f64649..a32fac710f 100644 --- a/graphics/fonts/macfont.cpp +++ b/graphics/fonts/macfont.cpp @@ -25,6 +25,8 @@ #include "graphics/managed_surface.h" #include "graphics/fonts/macfont.h" +#define DEBUGSCALING 0 + namespace Graphics { enum { @@ -393,7 +395,14 @@ int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const { return 0; } -MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) { +#if DEBUGSCALING +bool dododo; +#endif + +static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale); +static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height); + +MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bold, bool italic) { if (!src) { warning("Empty font reference in scale font"); return NULL; @@ -404,6 +413,12 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) { return NULL; } + Graphics::Surface srcSurf; + srcSurf.create(MAX(src->getFontSize() * 2, newSize * 2), MAX(src->getFontSize() * 2, newSize * 2), + PixelFormat::createFormatCLUT8()); + int dstGraySize = newSize * 2 * newSize; + int *dstGray = (int *)malloc(dstGraySize * sizeof(int)); + float scale = (float)newSize / (float)src->getFontSize(); MacFONTdata data; @@ -427,7 +442,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) { data._glyphs.resize(src->_data._glyphs.size()); - // Dtermine width of the bit image table + // Determine width of the bit image table int newBitmapWidth = 0; for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) { MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i]; @@ -435,10 +450,11 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) { glyph->width = (int)((float)srcglyph->width * scale); glyph->kerningOffset = (int)((float)srcglyph->kerningOffset * scale); - glyph->bitmapWidth = (int)((float)srcglyph->bitmapWidth * scale); + glyph->bitmapWidth = glyph->width; //(int)((float)srcglyph->bitmapWidth * scale); glyph->bitmapOffset = newBitmapWidth; - newBitmapWidth += (glyph->bitmapWidth + 7) & ~0x7; + // Align width to a byte + newBitmapWidth += (glyph->bitmapWidth + 7 + 2) & ~0x7; // Add 2 pixels for italic and bold } data._rowWords = newBitmapWidth; @@ -446,51 +462,216 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize) { uint bitImageSize = data._rowWords * data._fRectHeight; data._bitImage = new byte[bitImageSize]; - int srcPitch = src->_data._rowWords; int dstPitch = data._rowWords; for (uint i = 0; i < src->_data._glyphs.size() + 1; i++) { const MacGlyph *srcglyph = (i == src->_data._glyphs.size()) ? &src->_data._defaultChar : &src->_data._glyphs[i]; + + int grayLevel = src->_data._fRectHeight * srcglyph->width / 4; + +#if DEBUGSCALING + int ccc = 'c'; + dododo = i == ccc; +#endif + + srcSurf.fillRect(Common::Rect(srcSurf.w, srcSurf.h), 0); + src->drawChar(&srcSurf, i + src->_data._firstChar, 0, 0, 1); + memset(dstGray, 0, dstGraySize * sizeof(int)); + magnifyGray(&srcSurf, dstGray, srcglyph->width, src->_data._fRectHeight, scale); + MacGlyph *glyph = (i == src->_data._glyphs.size()) ? &data._defaultChar : &data._glyphs[i]; + int *grayPtr = dstGray; + + for (int y = 0; y < data._fRectHeight; y++) { + byte *dst = (byte *)srcSurf.getBasePtr(0, y); + + for (int x = 0; x < glyph->width; x++, grayPtr++, dst++) { +#if DEBUGSCALING + if (i == ccc) { + if (*grayPtr) + debugN(1, "%3d ", *grayPtr); + else + debugN(1, " "); + } +#endif + if (*grayPtr > grayLevel) + *dst = 1; + else + *dst = 0; + } +#if DEBUGSCALING + if (i == ccc) + debug(1, ""); +#endif + } + + if (bold) { + memset(dstGray, 0, dstGraySize * sizeof(int)); + makeBold(&srcSurf, dstGray, glyph, data._fRectHeight); + + for (uint16 y = 0; y < data._fRectHeight; y++) { + int *srcPtr = &dstGray[y * glyph->width]; + byte *dstPtr = (byte *)srcSurf.getBasePtr(0, y); + + for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dstPtr++) { + if (*srcPtr) + *dstPtr = 1; + +#if DEBUGSCALING + if (i == ccc) + debugN("%c", *srcPtr ? '@' : '.'); +#endif + } + +#if DEBUGSCALING + if (i == ccc) + debugN("\n"); +#endif + } + } + byte *ptr = &data._bitImage[glyph->bitmapOffset / 8]; for (int y = 0; y < data._fRectHeight; y++) { - const byte *srcd = (const byte *)&src->_data._bitImage[((int)((float)y / scale)) * srcPitch]; byte *dst = ptr; + byte *srcPtr = (byte *)srcSurf.getBasePtr(0, y); byte b = 0; - for (int x = 0; x < glyph->width; x++) { - int sx = (int)((float)x / scale) + srcglyph->bitmapOffset; + for (int x = 0; x < glyph->width; x++, srcPtr++) { + b <<= 1; - if (srcd[sx / 8] & (0x80 >> (sx % 8))) + if (*srcPtr == 1) b |= 1; - if (!(x % 8) && x) { + if (x % 8 == 7) { *dst++ = b; b = 0; } + } - b <<= 1; +#if DEBUGSCALING + if (i == ccc) { + debugN(1, "--> %d ", grayLevel); + + grayPtr = &dstGray[y * glyph->width]; + for (int x = 0; x < glyph->width; x++, grayPtr++) + debugN("%c", *grayPtr > grayLevel ? '#' : '.'); } +#endif if (((glyph->width - 1) % 8)) { +#if DEBUGSCALING + if (i == ccc) + debugN(" --- %02x (w: %d bw: %d << %d)", b, glyph->width, glyph->bitmapWidth, 7 - ((glyph->width - 1) % 8)); +#endif + b <<= 7 - ((glyph->width - 1) % 8); *dst = b; + +#if DEBUGSCALING + if (i == ccc) + debugN(" --- %02x ", b); +#endif + } + +#if DEBUGSCALING + if (i == ccc) { + byte *srcRow = data._bitImage + y * data._rowWords; + + for (uint16 x = 0; x < glyph->bitmapWidth; x++) { + uint16 bitmapOffset = glyph->bitmapOffset + x; + + debugN("%c", srcRow[bitmapOffset / 8] & (1 << (7 - (bitmapOffset % 8))) ? '*' : '.'); + } + + debugN("\n"); } +#endif ptr += dstPitch; } } + srcSurf.free(); + free(dstGray); + return new MacFONTFont(data); } +#define howmany(x, y) (((x)+((y)-1))/(y)) + +static void countupScore(int *dstGray, int x, int y, int bbw, int bbh, float scale) { + int newbbw = bbw * scale; + int newbbh = bbh * scale; + int x_ = x * newbbw; + int y_ = y * newbbh; + int x1 = x_ + newbbw; + int y1 = y_ + newbbh; + + int newxbegin = x_ / bbw; + int newybegin = y_ / bbh; + int newxend = howmany(x1, bbw); + int newyend = howmany(y1, bbh); + + for (int newy = newybegin; newy < newyend; newy++) { + for (int newx = newxbegin; newx < newxend; newx++) { + int newX = newx * bbw; + int newY = newy * bbh; + int newX1 = newX + bbw; + int newY1 = newY + bbh; + dstGray[newy * newbbw + newx] += (MIN(x1, newX1) - MAX(x_, newX)) * + (MIN(y1, newY1) - MAX(y_, newY)); + } + } +} + +static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale) { + for (uint16 y = 0; y < height; y++) { + for (uint16 x = 0; x < width; x++) { + if (*((byte *)src->getBasePtr(x, y)) == 1) + countupScore(dstGray, x, y, width, height, scale); +#if DEBUGSCALING + if (dododo) + debugN("%c", *((byte *)src->getBasePtr(x, y)) == 1 ? '*' : ' '); +#endif + } + +#if DEBUGSCALING + if (dododo) + debugN("\n"); +#endif + } +} + +static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) { + glyph->width++; + + for (uint16 y = 0; y < height; y++) { + byte *srcPtr = (byte *)src->getBasePtr(0, y); + int *dst = &dstGray[y * glyph->width]; + + for (uint16 x = 0; x < glyph->width; x++, srcPtr++, dst++) { + bool left = x ? *(srcPtr - 1) == 1 : false; + bool center = *srcPtr == 1; + bool right = x > glyph->width - 1 ? false : *(srcPtr + 1) == 1; + + bool edge, bold, res; + + bold = center || left; + edge = !center && right; + res = (bold && !edge); + + *dst = res ? 1 : 0; + } + } +} + void MacFONTFont::testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width) { for (int y = 0; y < src->_data._fRectHeight; y++) { byte *srcRow = src->_data._bitImage + y * src->_data._rowWords; for (int x = 0; x < width; x++) { - uint16 bitmapOffset = x; + uint16 bitmapOffset = x + 64; if (srcRow[bitmapOffset / 8] & (1 << (7 - (bitmapOffset % 8)))) { if (dst->format.bytesPerPixel == 1) diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h index b2e1fb0d11..cb11304eb2 100644 --- a/graphics/fonts/macfont.h +++ b/graphics/fonts/macfont.h @@ -159,7 +159,7 @@ public: int getFontSize() const { return _data._size; } - static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize); + static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize, bool bold = false, bool italic = false); static void testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width); private: diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp index ec6ce6f89a..ad5b36ec23 100644 --- a/graphics/fonts/winfont.cpp +++ b/graphics/fonts/winfont.cpp @@ -77,62 +77,20 @@ static WinFontDirEntry readDirEntry(Common::SeekableReadStream &stream) { } bool WinFont::loadFromFON(const Common::String &fileName, const WinFontDirEntry &dirEntry) { - // First try loading via the NE code - if (loadFromNE(fileName, dirEntry)) - return true; - - // Then try loading via the PE code - return loadFromPE(fileName, dirEntry); -} - -bool WinFont::loadFromNE(const Common::String &fileName, const WinFontDirEntry &dirEntry) { - Common::NEResources exe; - - if (!exe.loadFromEXE(fileName)) - return false; - - // Let's pull out the font directory - Common::SeekableReadStream *fontDirectory = exe.getResource(Common::kWinFontDir, Common::String("FONTDIR")); - if (!fontDirectory) { - warning("No font directory in '%s'", fileName.c_str()); - return false; - } - - uint32 fontId = getFontIndex(*fontDirectory, dirEntry); - - delete fontDirectory; - - // Couldn't match the face name - if (fontId == 0xffffffff) { - warning("Could not find face '%s' in '%s'", dirEntry.faceName.c_str(), fileName.c_str()); + Common::WinResources *exe = Common::WinResources::createFromEXE(fileName); + if (!exe) return false; - } - - // Actually go get our font now... - Common::SeekableReadStream *fontStream = exe.getResource(Common::kWinFont, fontId); - if (!fontStream) { - warning("Could not find font %d in %s", fontId, fileName.c_str()); - return false; - } - bool ok = loadFromFNT(*fontStream); - delete fontStream; + bool ok = loadFromEXE(exe, fileName, dirEntry); + delete exe; return ok; } -bool WinFont::loadFromPE(const Common::String &fileName, const WinFontDirEntry &dirEntry) { - Common::PEResources *exe = new Common::PEResources(); - - if (!exe->loadFromEXE(fileName)) { - delete exe; - return false; - } - +bool WinFont::loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry) { // Let's pull out the font directory Common::SeekableReadStream *fontDirectory = exe->getResource(Common::kWinFontDir, Common::String("FONTDIR")); if (!fontDirectory) { warning("No font directory in '%s'", fileName.c_str()); - delete exe; return false; } @@ -143,7 +101,6 @@ bool WinFont::loadFromPE(const Common::String &fileName, const WinFontDirEntry & // Couldn't match the face name if (fontId == 0xffffffff) { warning("Could not find face '%s' in '%s'", dirEntry.faceName.c_str(), fileName.c_str()); - delete exe; return false; } @@ -151,13 +108,11 @@ bool WinFont::loadFromPE(const Common::String &fileName, const WinFontDirEntry & Common::SeekableReadStream *fontStream = exe->getResource(Common::kWinFont, fontId); if (!fontStream) { warning("Could not find font %d in %s", fontId, fileName.c_str()); - delete exe; return false; } bool ok = loadFromFNT(*fontStream); delete fontStream; - delete exe; return ok; } diff --git a/graphics/fonts/winfont.h b/graphics/fonts/winfont.h index 3354fc2381..f1c661f270 100644 --- a/graphics/fonts/winfont.h +++ b/graphics/fonts/winfont.h @@ -28,6 +28,7 @@ namespace Common { class SeekableReadStream; +class WinResources; } namespace Graphics { @@ -67,8 +68,7 @@ public: void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const; private: - bool loadFromPE(const Common::String &fileName, const WinFontDirEntry &dirEntry); - bool loadFromNE(const Common::String &fileName, const WinFontDirEntry &dirEntry); + bool loadFromEXE(Common::WinResources *exe, const Common::String &fileName, const WinFontDirEntry &dirEntry); uint32 getFontIndex(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry); bool loadFromFNT(Common::SeekableReadStream &stream); diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index e8e3d4314b..ff940384c4 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -405,42 +405,67 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) { // No simple substitute was found. Looking for neighborhood fonts // First we gather all font sizes for this font - Common::Array<int> sizes; + Common::Array<MacFont *> sizes; for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) { if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated()) - sizes.push_back(i->_value->getSize()); + sizes.push_back(i->_value); } if (sizes.empty()) { - debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); - return; + if (macFont.getSlant() == kMacFontRegular) { + debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); + return; + } + + // Now let's try to find a regular font + for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) { + if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == kMacFontRegular && !i->_value->isGenerated()) + sizes.push_back(i->_value); + } + + if (sizes.empty()) { + debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str()); + return; + } } - // Now looking next larger font, and store the largest one for next check - int candidate = 1000; - int maxSize = sizes[0]; + // Now looking for the next larger font, and store the largest one for next check + MacFont *candidate = nullptr; + MacFont *maxSize = sizes[0]; for (uint i = 0; i < sizes.size(); i++) { - if (sizes[i] > macFont.getSize() && sizes[i] < candidate) + if (sizes[i]->getSize() == macFont.getSize()) { // Same size but regular slant + candidate = sizes[i]; + break; + } + + if (sizes[i]->getSize() > macFont.getSize() && candidate && sizes[i]->getSize() < candidate->getSize()) candidate = sizes[i]; - if (sizes[i] > maxSize) + if (sizes[i]->getSize() > maxSize->getSize()) maxSize = sizes[i]; } - if (candidate != 1000) { - generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), candidate, macFont.getSlant())]); + if (candidate) { + generateFont(macFont, *candidate); return; } // Now next smaller font, which is the biggest we have - generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), maxSize, macFont.getSlant())]); + generateFont(macFont, *maxSize); } void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) { debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str()); debug("as '%s'", getFontName(fromFont).c_str()); - MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize()); + bool bold = false, italic = false; + + if (fromFont.getSlant() == kMacFontRegular) { + bold = toFont.getSlant() == kMacFontBold; + italic = toFont.getSlant() == kMacFontItalic; + } + + MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize(), bold, italic); if (!font) { warning("Failed to generate font '%s'", getFontName(toFont).c_str()); diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp index 2c9b3f0902..b79ba8cfbc 100644 --- a/graphics/macgui/macmenu.cpp +++ b/graphics/macgui/macmenu.cpp @@ -24,6 +24,7 @@ #include "common/stack.h" #include "common/keyboard.h" #include "common/macresman.h" +#include "common/winexe_pe.h" #include "graphics/primitives.h" #include "graphics/font.h" @@ -200,8 +201,8 @@ static Common::U32String readUnicodeString(Common::SeekableReadStream *stream) { } -MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources &exe, MacWindowManager *wm) { - Common::SeekableReadStream *menuData = exe.getResource(Common::kWinMenu, 128); +MacMenu *MacMenu::createMenuFromPEexe(Common::PEResources *exe, MacWindowManager *wm) { + Common::SeekableReadStream *menuData = exe->getResource(Common::kWinMenu, 128); if (!menuData) return nullptr; diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h index c8633c0cc7..13d374d084 100644 --- a/graphics/macgui/macmenu.h +++ b/graphics/macgui/macmenu.h @@ -24,11 +24,11 @@ #define GRAPHICS_MACGUI_MACMENU_H #include "common/str-array.h" -#include "common/winexe_pe.h" namespace Common { class U32String; class MacResManager; +class PEResources; } namespace Graphics { @@ -51,7 +51,7 @@ public: ~MacMenu(); static Common::StringArray *readMenuFromResource(Common::SeekableReadStream *res); - static MacMenu *createMenuFromPEexe(Common::PEResources &exe, MacWindowManager *wm); + static MacMenu *createMenuFromPEexe(Common::PEResources *exe, MacWindowManager *wm); void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; } void setCommandsCallback(void (*callback)(int, Common::U32String &, void *), void *data) { _unicodeccallback = callback; _cdata = data; } diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 0df403ac8c..2fc9b8dd33 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -69,8 +69,7 @@ MacText::MacText(Common::U32String s, MacWindowManager *wm, const MacFont *macFo _currentFormatting = _defaultFormatting; - if (!_str.empty()) - splitString(_str); + splitString(_str); recalcDims(); @@ -101,8 +100,7 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m _currentFormatting = _defaultFormatting; - if (!_str.empty()) - splitString(_str); + splitString(_str); recalcDims(); @@ -114,13 +112,11 @@ void MacText::setMaxWidth(int maxWidth) { _textLines.clear(); - if (!_str.empty()) { - splitString(_str); + splitString(_str); - recalcDims(); + recalcDims(); - _fullRefresh = true; - } + _fullRefresh = true; } static const Common::U32String::value_type *readHex(uint16 *res, const Common::U32String::value_type *s, int len) { @@ -395,7 +391,7 @@ int MacText::getLineWidth(int line, bool enforce) { height = MAX(height, _textLines[line].chunks[i].getFont()->getFontHeight()); } - if (!hastext) + if (!hastext && _textLines.size() > 1) height = height > 3 ? height - 3 : 0; _textLines[line].width = width; diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp index 12cd391f92..19448053a3 100644 --- a/graphics/macgui/macwindowmanager.cpp +++ b/graphics/macgui/macwindowmanager.cpp @@ -295,7 +295,7 @@ void macDrawPixel(int x, int y, int color, void *data) { uint yu = (uint)y; *((byte *)p->surface->getBasePtr(xu, yu)) = - (pat[yu % 8] & (1 << (7 - xu % 8))) ? + (pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor; } } else { @@ -310,7 +310,7 @@ void macDrawPixel(int x, int y, int color, void *data) { uint xu = (uint)x; // for letting compiler optimize it uint yu = (uint)y; *((byte *)p->surface->getBasePtr(xu, yu)) = - (pat[yu % 8] & (1 << (7 - xu % 8))) ? + (pat[(yu - p->fillOriginY) % 8] & (1 << (7 - (xu - p->fillOriginX) % 8))) ? color : p->bgColor; } } @@ -319,7 +319,7 @@ void macDrawPixel(int x, int y, int color, void *data) { void MacWindowManager::drawDesktop() { Common::Rect r(_screen->getBounds()); - MacPlotData pd(_screen, &_patterns, kPatternCheckers, 1, _colorWhite); + MacPlotData pd(_screen, &_patterns, kPatternCheckers, 0, 0, 1, _colorWhite); Graphics::drawRoundRect(r, kDesktopArc, _colorBlack, true, macDrawPixel, &pd); diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h index c412e64f0a..5846bcba07 100644 --- a/graphics/macgui/macwindowmanager.h +++ b/graphics/macgui/macwindowmanager.h @@ -83,11 +83,13 @@ struct MacPlotData { Graphics::ManagedSurface *surface; MacPatterns *patterns; uint fillType; + int fillOriginX; + int fillOriginY; int thickness; uint bgColor; - MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, int f, int t, uint bg) : - surface(s), patterns(p), fillType(f), thickness(t), bgColor(bg) { + MacPlotData(Graphics::ManagedSurface *s, MacPatterns *p, uint f, int fx, int fy, int t, uint bg) : + surface(s), patterns(p), fillType(f), fillOriginX(fx), fillOriginY(fy), thickness(t), bgColor(bg) { } }; diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp index 60898aa16c..fd6c8fb262 100644 --- a/graphics/primitives.cpp +++ b/graphics/primitives.cpp @@ -247,8 +247,8 @@ void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, in void drawRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) { drawHLine(rect.left, rect.right, rect.top, color, plotProc, data); drawHLine(rect.left, rect.right, rect.bottom, color, plotProc, data); - drawVLine(rect.top, rect.bottom, rect.left, color, plotProc, data); - drawVLine(rect.top, rect.bottom, rect.right, color, plotProc, data); + drawVLine(rect.left, rect.top, rect.bottom, color, plotProc, data); + drawVLine(rect.right, rect.top, rect.bottom, color, plotProc, data); } // http://members.chello.at/easyfilter/bresenham.html diff --git a/graphics/transparent_surface.cpp b/graphics/transparent_surface.cpp index eb8d3fe5ce..1ad1ed637c 100644 --- a/graphics/transparent_surface.cpp +++ b/graphics/transparent_surface.cpp @@ -749,43 +749,30 @@ void TransparentSurface::setAlphaMode(AlphaType mode) { /* - The below two functions are adapted from SDL_rotozoom.c, taken from SDL_gfx-2.0.18. - Its copyright notice: - ============================================================================= SDL_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces - Copyright (C) 2001-2012 Andreas Schiffler - This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - Andreas Schiffler -- aschiffler at ferzkopp dot net ============================================================================= - - The functions have been adapted for different structures and coordinate systems. - */ diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 13d9bebfba..7abd1a33ad 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -23,8 +23,6 @@ #include "common/ptr.h" #include "common/stream.h" #include "common/textconsole.h" -#include "common/winexe_ne.h" -#include "common/winexe_pe.h" #include "graphics/wincursor.h" @@ -242,64 +240,8 @@ WinCursorGroup::~WinCursorGroup() { delete cursors[i].cursor; } -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, const Common::WinResourceID &id) { - Common::ScopedPtr<Common::SeekableReadStream> stream(exe.getResource(Common::kWinGroupCursor, id)); - - if (!stream || stream->size() <= 6) - return 0; - - stream->skip(4); - uint32 cursorCount = stream->readUint16LE(); - if ((uint32)stream->size() < (6 + cursorCount * 14)) - return 0; - - WinCursorGroup *group = new WinCursorGroup(); - group->cursors.reserve(cursorCount); - - for (uint32 i = 0; i < cursorCount; i++) { - stream->readUint16LE(); // width - stream->readUint16LE(); // height - - // Plane count - if (stream->readUint16LE() != 1) { - delete group; - return 0; - } - - // Bits per pixel - // NE cursors can only be 1bpp - if (stream->readUint16LE() != 1) { - delete group; - return 0; - } - - stream->readUint32LE(); // data size - uint32 cursorId = stream->readUint16LE(); - - Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe.getResource(Common::kWinCursor, cursorId)); - if (!cursorStream) { - delete group; - return 0; - } - - WinCursor *cursor = new WinCursor(); - if (!cursor->readFromStream(*cursorStream)) { - delete cursor; - delete group; - return 0; - } - - CursorItem item; - item.id = cursorId; - item.cursor = cursor; - group->cursors.push_back(item); - } - - return group; -} - -WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id) { - Common::ScopedPtr<Common::SeekableReadStream> stream(exe.getResource(Common::kWinGroupCursor, id)); +WinCursorGroup *WinCursorGroup::createCursorGroup(Common::WinResources *exe, const Common::WinResourceID &id) { + Common::ScopedPtr<Common::SeekableReadStream> stream(exe->getResource(Common::kWinGroupCursor, id)); if (!stream || stream->size() <= 6) return 0; @@ -325,7 +267,7 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, cons stream->readUint32LE(); // data size uint32 cursorId = stream->readUint16LE(); - Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe.getResource(Common::kWinCursor, cursorId)); + Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe->getResource(Common::kWinCursor, cursorId)); if (!cursorStream) { delete group; return 0; diff --git a/graphics/wincursor.h b/graphics/wincursor.h index 2780b23a90..77d00d2d69 100644 --- a/graphics/wincursor.h +++ b/graphics/wincursor.h @@ -29,8 +29,6 @@ #include "graphics/cursor.h" namespace Common { -class NEResources; -class PEResources; class SeekableReadStream; } @@ -56,10 +54,8 @@ struct WinCursorGroup { Common::Array<CursorItem> cursors; - /** Create a cursor group from an NE EXE, returns 0 on failure */ - static WinCursorGroup *createCursorGroup(Common::NEResources &exe, const Common::WinResourceID &id); - /** Create a cursor group from an PE EXE, returns 0 on failure */ - static WinCursorGroup *createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id); + /** Create a cursor group from an EXE, returns 0 on failure */ + static WinCursorGroup *createCursorGroup(Common::WinResources *exe, const Common::WinResourceID &id); }; /** |