aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/base')
-rw-r--r--engines/wintermute/base/font/base_font_truetype.cpp164
-rw-r--r--engines/wintermute/base/gfx/base_image.cpp25
-rw-r--r--engines/wintermute/base/gfx/base_renderer.h1
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp114
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.h2
-rw-r--r--engines/wintermute/base/scriptables/script_ext_date.cpp4
-rw-r--r--engines/wintermute/base/scriptables/script_value.cpp4
7 files changed, 34 insertions, 280 deletions
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp
index c643a5e1b1..638b939ec1 100644
--- a/engines/wintermute/base/font/base_font_truetype.cpp
+++ b/engines/wintermute/base/font/base_font_truetype.cpp
@@ -256,12 +256,6 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
} else if (align == TAL_RIGHT) {
alignment = Graphics::kTextAlignRight;
}
- // TODO: This function gets called a lot, so warnings like these drown out the usefull information
- static bool hasWarned = false;
- if (!hasWarned) {
- hasWarned = true;
- warning("BaseFontTT::RenderTextToTexture - Not fully ported yet");
- }
debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color));
// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
@@ -287,104 +281,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
delete surface;
delete convertedSurface;
return retSurface;
-#if 0 //TODO
- int textHeight = lines.size() * (_maxCharHeight + _ascender);
- SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
-
- SDL_LockSurface(surface);
-
- int posY = (int)GetLineHeight() - (int)_descender;
-
- for (it = lines.begin(); it != lines.end(); ++it) {
- TextLine *line = (*it);
- int posX = 0;
-
- switch (align) {
- case TAL_CENTER:
- posX += (width - line->GetWidth()) / 2;
- break;
-
- case TAL_RIGHT:
- posX += width - line->GetWidth();
- break;
- }
-
-
- textOffset = 0;
- for (size_t i = 0; i < line->GetText().size(); i++) {
- wchar_t ch = line->GetText()[i];
-
- GlyphInfo *glyph = _glyphCache->GetGlyph(ch);
- if (!glyph) {
- continue;
- }
-
- textOffset = MAX(textOffset, glyph->GetBearingY());
- }
-
-
- int origPosX = posX;
-
- wchar_t prevChar = L'\0';
- for (size_t i = 0; i < line->GetText().size(); i++) {
- wchar_t ch = line->GetText()[i];
-
- GlyphInfo *glyph = _glyphCache->GetGlyph(ch);
- if (!glyph) {
- continue;
- }
-
- float kerning = 0;
- if (prevChar != L'\0') {
- kerning = GetKerning(prevChar, ch);
- }
- posX += (int)kerning;
-
-
- if (glyph->GetBearingY() > 0) {
- int i = 10;
- }
-
- SDL_Rect rect;
- rect.x = posX + glyph->GetBearingX();
- rect.y = posY - glyph->GetBearingY() + textOffset;
- rect.w = glyph->GetImage()->w;
- rect.h = glyph->GetImage()->h;
-
- BlitSurface(glyph->GetImage(), surface, &rect);
-
- prevChar = ch;
- posX += (int)(glyph->GetAdvanceX());
- posY += (int)(glyph->GetAdvanceY());
- }
-
- if (_isUnderline) {
- for (int i = origPosX; i < origPosX + line->GetWidth(); i++) {
- Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch;
- Uint32 *buf32 = (Uint32 *)buf;
-
- buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255);
- }
- }
-
- SDL_UnlockSurface(surface);
-
- delete line;
- line = NULL;
- posY += GetLineHeight();
- }
-
- BaseSurfaceOSystem *wmeSurface = new BaseSurfaceOSystem(_gameRef);
- if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) {
- SDL_FreeSurface(surface);
- return wmeSurface;
- } else {
- SDL_FreeSurface(surface);
- delete wmeSurface;
- return NULL;
- }
-#endif
- return NULL;
+ // TODO: _isUnderline, _isBold, _isItalic, _isStriked
}
@@ -666,65 +563,6 @@ bool BaseFontTT::initFont() {
}
_lineHeight = _font->getFontHeight();
return STATUS_OK;
-#if 0
- FT_Error error;
-
- float vertDpi = 96.0;
- float horDpi = 96.0;
-
-
- _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)];
- memset(_fTStream, 0, sizeof(*_fTStream));
-
- _fTStream->read = BaseFontTT::FTReadSeekProc;
- _fTStream->close = BaseFontTT::FTCloseProc;
- _fTStream->descriptor.pointer = file;
- _fTStream->size = file->GetSize();
-
- FT_Open_Args args;
- args.flags = FT_OPEN_STREAM;
- args.stream = _fTStream;
-
- error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace);
- if (error) {
- SAFE_DELETE_ARRAY(_fTStream);
- _gameRef->_fileManager->closeFile(file);
- return STATUS_FAILED;
- }
-
- error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi);
- if (error) {
- FT_Done_Face(_fTFace);
- _fTFace = NULL;
- return STATUS_FAILED;
- }
-
- // http://en.wikipedia.org/wiki/E_(typography)
- float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi
- float emsPerUnit = 1.0f / _fTFace->units_per_EM;
- float pixelsPerUnit = pixelsPerEm * EmsPerUnit;
-
- // bounding box in pixels
- float xMin = _fTFace->bbox.xMin * pixelsPerUnit;
- float xMax = _fTFace->bbox.xMax * pixelsPerUnit;
- float yMin = _fTFace->bbox.yMin * pixelsPerUnit;
- float yMax = _fTFace->bbox.yMax * pixelsPerUnit;
-
- // metrics in pixels
- _ascender = _fTFace->ascender * pixelsPerUnit;
- _descender = - _fTFace->descender * pixelsPerUnit;
- _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2;
- _underlinePos = - _fTFace->underline_position * pixelsPerUnit;
-
- // max character size (used for texture grid)
- _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin);
- _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin);
-
- _glyphCache = new FontGlyphCache();
- _glyphCache->Initialize();
-
-#endif
- return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp
index 3aa21d0f7f..1fff59d85b 100644
--- a/engines/wintermute/base/gfx/base_image.cpp
+++ b/engines/wintermute/base/gfx/base_image.cpp
@@ -114,23 +114,16 @@ bool BaseImage::saveBMPFile(const char *filename) const {
//////////////////////////////////////////////////////////////////////////
bool BaseImage::resize(int newWidth, int newHeight) {
- warning("BaseImage::resize(%d, %d), stubbed", newWidth, newHeight);
-#if 0
- if (!_bitmap) {
- return STATUS_FAILED;
- }
-
- if (newWidth == 0) {
- NewWidth = FreeImage_GetWidth(_bitmap);
- }
- if (newHeight == 0) {
- NewHeight = FreeImage_GetHeight(_bitmap);
+ // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here.
+ TransparentSurface temp(*_surface, true);
+ if (_deletableSurface) {
+ _deletableSurface->free();
+ delete _deletableSurface;
+ _deletableSurface = NULL;
}
-
-
- FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR);
-#endif
- return false;
+ _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight);
+ temp.free();
+ return true;
}
diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h
index 83b5ad0e16..008db69713 100644
--- a/engines/wintermute/base/gfx/base_renderer.h
+++ b/engines/wintermute/base/gfx/base_renderer.h
@@ -62,6 +62,7 @@ public:
virtual BaseImage *takeScreenshot() = 0;
virtual bool setViewport(int left, int top, int right, int bottom);
virtual bool setViewport(Rect32 *rect);
+ virtual Rect32 getViewPort() = 0;
virtual bool setScreenViewport();
virtual Graphics::PixelFormat getPixelFormat() const = 0;
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 00ef2ec95c..90dda1af72 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -231,8 +231,6 @@ bool BaseRenderOSystem::flip() {
//////////////////////////////////////////////////////////////////////////
bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) {
- //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF);
- //SDL_RenderClear(_renderer);
_clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b);
if (!_disableDirtyRects) {
return STATUS_OK;
@@ -240,6 +238,7 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) {
if (!rect) {
rect = &_renderRect;
}
+ // TODO: This doesn't work with dirty rects
_renderSurface->fillRect(*rect, _clearColor);
return STATUS_OK;
@@ -410,7 +409,6 @@ void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) {
_dirtyRect->extend(rect);
}
_dirtyRect->clip(_renderRect);
-// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom);
}
void BaseRenderOSystem::drawTickets() {
@@ -421,7 +419,6 @@ void BaseRenderOSystem::drawTickets() {
if ((*it)->_wantsDraw == false || (*it)->_isValid == false) {
RenderTicket *ticket = *it;
addDirtyRect((*it)->_dstRect);
- //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height());
it = _renderQueue.erase(it);
delete ticket;
decrement++;
@@ -436,7 +433,6 @@ void BaseRenderOSystem::drawTickets() {
// The color-mods are stored in the RenderTickets on add, since we set that state again during
// draw, we need to keep track of what it was prior to draw.
uint32 oldColorMod = _colorMod;
-// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height());
// Apply the clear-color to the dirty rect.
_renderSurface->fillRect(*_dirtyRect, _clearColor);
@@ -521,38 +517,11 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) {
//////////////////////////////////////////////////////////////////////////
BaseImage *BaseRenderOSystem::takeScreenshot() {
-// TODO: Fix this
+// TODO: Clip by viewport.
warning("BaseRenderOSystem::TakeScreenshot() - not ported yet");
BaseImage *screenshot = new BaseImage(_gameRef->_fileManager);
screenshot->copyFrom(_renderSurface);
return screenshot;
-#if 0
- SDL_Rect viewport;
-
- SDL_RenderGetViewport(_renderer, &viewport);
-
- SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000);
- if (!surface) {
- return NULL;
- }
-
- if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) {
- return NULL;
- }
-
- FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
-
- int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib);
-
- for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) {
- byte *bits = FreeImage_GetScanLine(dib, y);
- byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch;
- memcpy(bits, src, bytespp * viewport.w);
- }
-
- return new BaseImage(_gameRef, dib);
-#endif
- return NULL;
}
//////////////////////////////////////////////////////////////////////////
@@ -569,84 +538,43 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) {
rect.right = (int16)((right - left) * _ratioX);
rect.bottom = (int16)((bottom - top) * _ratioY);
+ _renderRect = rect;
return STATUS_OK;
}
+Rect32 BaseRenderOSystem::getViewPort() {
+ Rect32 ret;
+ ret.top = _renderRect.top;
+ ret.bottom = _renderRect.bottom;
+ ret.left = _renderRect.left;
+ ret.right = _renderRect.right;
+ return ret;
+}
+
//////////////////////////////////////////////////////////////////////////
void BaseRenderOSystem::modTargetRect(Common::Rect *rect) {
-#if 0
- SDL_Rect viewportRect;
- SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect);
-
- rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x);
- rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y);
- rect->w = MathUtil::RoundUp(rect->w * _ratioX);
- rect->h = MathUtil::RoundUp(rect->h * _ratioY);
-#endif
+ rect->left = MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left);
+ rect->top = MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top);
+ rect->setWidth(MathUtil::roundUp(rect->width() * _ratioX));
+ rect->setHeight(MathUtil::roundUp(rect->height() * _ratioY));
}
//////////////////////////////////////////////////////////////////////////
void BaseRenderOSystem::pointFromScreen(Point32 *point) {
-#if 0
- SDL_Rect viewportRect;
- SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect);
-
- point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x;
- point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y;
-#endif
+ point->x = point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left;
+ point->y = point->y / _ratioY - _borderTop / _ratioY + _renderRect.top;
}
//////////////////////////////////////////////////////////////////////////
void BaseRenderOSystem::pointToScreen(Point32 *point) {
-#if 0
- SDL_Rect viewportRect;
- SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect);
-
- point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x;
- point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y;
-#endif
+ point->x = MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left;
+ point->y = MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top;
}
//////////////////////////////////////////////////////////////////////////
void BaseRenderOSystem::dumpData(const char *filename) {
- warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO
-#if 0
- FILE *f = fopen(filename, "wt");
- if (!f) {
- return;
- }
-
- BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage;
-
- int totalKB = 0;
- int totalLoss = 0;
- fprintf(f, "Filename;Usage;Size;KBytes\n");
- for (int i = 0; i < Mgr->_surfaces.getSize(); i++) {
- BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i];
- if (!Surf->_filename) {
- continue;
- }
- if (!Surf->_valid) {
- continue;
- }
-
- fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount);
- fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight());
-
- int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024;
-
- TotalKB += kb;
- fprintf(f, "%d;", kb);
- fprintf(f, "\n");
- }
- fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB);
-
-
- fclose(f);
- _gameRef->LOG(0, "Texture Stats Dump completed.");
- _gameRef->QuickMessage("Texture Stats Dump completed.");
-#endif
+ warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO
}
BaseSurface *BaseRenderOSystem::createSurface() {
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
index 0d00b1b427..dfffc68c17 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h
@@ -82,7 +82,7 @@ public:
void drawFromTicket(RenderTicket *renderTicket);
bool setViewport(int left, int top, int right, int bottom);
-
+ Rect32 getViewPort();
void modTargetRect(Common::Rect *rect);
void pointFromScreen(Point32 *point);
void pointToScreen(Point32 *point);
diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp
index a3bb7e2183..181be8ddd0 100644
--- a/engines/wintermute/base/scriptables/script_ext_date.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_date.cpp
@@ -68,9 +68,7 @@ const char *SXDate::scToString() {
// TODO: Make this more stringy, and less ISO 8601-like
_strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec);
return _strRep.c_str();
-#if 0
- return asctime(&_tm);
-#endif
+ //return asctime(&_tm);
}
diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp
index 01cb4044ff..9b83daf42f 100644
--- a/engines/wintermute/base/scriptables/script_value.cpp
+++ b/engines/wintermute/base/scriptables/script_value.cpp
@@ -166,11 +166,7 @@ ScValue *ScValue::getProp(const char *name) {
if (_type == VAL_STRING && strcmp(name, "Length") == 0) {
_gameRef->_scValue->_type = VAL_INT;
-#if 0 // TODO: Remove FreeType-dependency
if (_gameRef->_textEncoding == TEXT_ANSI) {
-#else
- if (true) {
-#endif
_gameRef->_scValue->setInt(strlen(_valString));
} else {
WideString wstr = StringUtil::utf8ToWide(_valString);