From 385f8358ab2ea138a39eb6fc76d246b3c5f48e45 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 3 Jun 2014 18:19:59 +0300 Subject: WINTERMUTE: Switch to use of moved to OSystem TransparentSurface --- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_frame.h | 3 +- engines/wintermute/base/base_object.cpp | 8 +-- engines/wintermute/base/base_object.h | 3 +- .../wintermute/base/base_persistence_manager.cpp | 4 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sprite.h | 10 ++-- engines/wintermute/base/base_sub_frame.cpp | 36 +++++++------- engines/wintermute/base/base_sub_frame.h | 3 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/base_image.cpp | 6 +-- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/gfx/base_surface.h | 14 +++--- .../base/gfx/osystem/base_render_osystem.cpp | 6 +-- .../base/gfx/osystem/base_render_osystem.h | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 58 +++++++++++----------- .../base/gfx/osystem/base_surface_osystem.h | 20 ++++---- .../wintermute/base/gfx/osystem/render_ticket.cpp | 18 +++---- .../wintermute/base/gfx/osystem/render_ticket.h | 8 +-- 19 files changed, 107 insertions(+), 102 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index f2c24b8f6a..471185f2d2 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -76,7 +76,7 @@ BaseFrame::~BaseFrame() { ////////////////////////////////////////////////////////////////////// -bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { +bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, Graphics::TSpriteBlendMode blendMode) { bool res; for (uint32 i = 0; i < _subframes.size(); i++) { diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index 49a56592bb..ff9e67a166 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -31,6 +31,7 @@ #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/coll_templ.h" +#include "graphics/transform_struct.h" namespace Wintermute { class BaseSound; @@ -51,7 +52,7 @@ public: int32 _moveX; uint32 _delay; BaseArray _subframes; - bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL); bool loadBuffer(char *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 708df8def1..cce3561f67 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -95,7 +95,7 @@ BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { _sFXType = SFX_NONE; _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - _blendMode = BLEND_NORMAL; + _blendMode = Graphics::BLEND_NORMAL; } @@ -807,10 +807,10 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) { - i = BLEND_NORMAL; + if (i < Graphics::BLEND_NORMAL || i >= Graphics::NUM_BLEND_MODES) { + i = Graphics::BLEND_NORMAL; } - _blendMode = (TSpriteBlendMode)i; + _blendMode = (Graphics::TSpriteBlendMode)i; return STATUS_OK; } diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index f5036f4ec4..8ca8ffc246 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -33,6 +33,7 @@ #include "engines/wintermute/base/base_script_holder.h" #include "engines/wintermute/persistent.h" #include "common/events.h" +#include "graphics/transform_struct.h" namespace Wintermute { @@ -75,7 +76,7 @@ protected: int32 _iD; char *_soundEvent; public: - TSpriteBlendMode _blendMode; + Graphics::TSpriteBlendMode _blendMode; virtual bool afterMove(); float _scale; uint32 _alphaColor; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bea55fb857..bb5e0c4091 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/save_thumb_helper.h" #include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/transparent_surface.h" #include "engines/wintermute/wintermute.h" #include "graphics/scaler.h" #include "image/bmp.h" @@ -173,7 +173,7 @@ void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &des Image::BitmapDecoder bmpDecoder; if (bmpDecoder.loadStream(thumbStream)) { const Graphics::Surface *bmpSurface = bmpDecoder.getSurface(); - TransparentSurface *scaleableSurface = new TransparentSurface(*bmpSurface, false); + Graphics::TransparentSurface *scaleableSurface = new Graphics::TransparentSurface(*bmpSurface, false); Graphics::Surface *scaled = scaleableSurface->scale(kThumbnailWidth, kThumbnailHeight2); Graphics::Surface *thumb = scaled->convertTo(g_system->getOverlayFormat()); desc.setThumbnail(thumb); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 2e00998037..04060bff32 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -418,7 +418,7 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { +bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, Graphics::TSpriteBlendMode blendMode) { if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 92287995d9..ec71512ec9 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -32,7 +32,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base_script_holder.h" -#include "engines/wintermute/graphics/transform_tools.h" +#include "graphics/transform_tools.h" namespace Wintermute { class BaseFrame; @@ -45,17 +45,17 @@ public: void setDefaults(); DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = kDefaultZoomX, float scaleY = kDefaultZoomY); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = Graphics::kDefaultZoomX, float scaleY = Graphics::kDefaultZoomY); int32 _moveY; int32 _moveX; - bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY, uint32 alpha = kDefaultRgbaMod, float rotate = kDefaultAngle, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getCurrentFrame(float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY); + bool display(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = Graphics::kDefaultZoomX, float zoomY = Graphics::kDefaultZoomY, uint32 alpha = Graphics::kDefaultRgbaMod, float rotate = Graphics::kDefaultAngle, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL); + bool getCurrentFrame(float zoomX = Graphics::kDefaultZoomX, float zoomY = Graphics::kDefaultZoomY); void reset(); bool isChanged(); bool isFinished(); bool loadBuffer(char *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = kDefaultZoomX, float zoomY = kDefaultZoomY, uint32 alpha = kDefaultRgbaMod); + bool draw(int x, int y, BaseObject *Register = nullptr, float zoomX = Graphics::kDefaultZoomX, float zoomY = Graphics::kDefaultZoomY, uint32 alpha = Graphics::kDefaultRgbaMod); bool _looping; int32 _currentFrame; bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = nullptr); diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 3a6e28b1f2..4388942064 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -37,8 +37,8 @@ #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/graphics/transform_tools.h" -#include "engines/wintermute/graphics/transform_struct.h" +#include "graphics/transform_tools.h" +#include "graphics/transform_struct.h" namespace Wintermute { @@ -47,9 +47,9 @@ IMPLEMENT_PERSISTENT(BaseSubFrame, false) ////////////////////////////////////////////////////////////////////////// BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _surface = nullptr; - _hotspotX = kDefaultHotspotX; - _hotspotY = kDefaultHotspotY; - _alpha = kDefaultRgbaMod; + _hotspotX = Graphics::kDefaultHotspotX; + _hotspotY = Graphics::kDefaultHotspotY; + _alpha = Graphics::kDefaultRgbaMod; _transparent = 0xFFFF00FF; _wantsDefaultRect = false; @@ -234,7 +234,7 @@ const char* BaseSubFrame::getSurfaceFilename() { } ////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { +bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, Graphics::TSpriteBlendMode blendMode) { rotate = fmod(rotate, 360.0f); if (rotate < 0) { @@ -246,7 +246,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl } if (registerOwner != nullptr && !_decoration) { - if (zoomX == kDefaultZoomX && zoomY == kDefaultZoomY) { + if (zoomX == Graphics::kDefaultZoomX && zoomY == Graphics::kDefaultZoomY) { BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise)); } else { BaseEngine::getRenderer()->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise)); @@ -259,24 +259,26 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl bool res; //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != kDefaultRgbaMod) { + if (_alpha != Graphics::kDefaultRgbaMod) { alpha = _alpha; } - if (rotate != kDefaultAngle) { - Point32 boxOffset, rotatedHotspot, hotspotOffset, newOrigin; - Point32 origin(x, y); - Rect32 oldRect = getRect(); - Point32 newHotspot; - TransformStruct transform = TransformStruct(zoomX, zoomY, (uint32)rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0); - Rect32 newRect = TransformTools::newRect (oldRect, transform, &newHotspot); + if (rotate != Graphics::kDefaultAngle) { + Point32 boxOffset, rotatedHotspot, hotspotOffset; + Common::Point origin(x, y); + Common::Point newOrigin; + Rect32 oldRect1 = getRect(); + Common::Rect oldRect(oldRect1.top, oldRect1.left, oldRect1.bottom, oldRect1.right); + Common::Point newHotspot; + Graphics::TransformStruct transform = Graphics::TransformStruct(zoomX, zoomY, (uint32)rotate, _hotspotX, _hotspotY, blendMode, alpha, _mirrorX, _mirrorY, 0, 0); + Rect32 newRect = Graphics::TransformTools::newRect(oldRect, transform, &newHotspot); newOrigin = origin - newHotspot; res = _surface->displayTransform(newOrigin.x, newOrigin.y, oldRect, newRect, transform); } else { - if (zoomX == kDefaultZoomX && zoomY == kDefaultZoomY) { + if (zoomX == Graphics::kDefaultZoomX && zoomY == Graphics::kDefaultZoomY) { res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY); } else { - res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / kDefaultZoomX)), (int)(y - _hotspotY * (zoomY / kDefaultZoomY)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / Graphics::kDefaultZoomX)), (int)(y - _hotspotY * (zoomY / Graphics::kDefaultZoomY)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); } } diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index b2859fa3f3..f156c332d6 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -32,6 +32,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_scriptable.h" +#include "graphics/transform_struct.h" namespace Wintermute { class BaseObject; @@ -52,7 +53,7 @@ public: BaseSubFrame(BaseGame *inGame); virtual ~BaseSubFrame(); bool loadBuffer(char *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = nullptr, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); const char* getSurfaceFilename(); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index df9a8648db..f27b565a7f 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -234,7 +234,7 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); renderer->_forceAlphaColor = 0; } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + surface->displayTransOffset(x, y - textOffset, rc, color, Graphics::BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); renderer->_forceAlphaColor = origForceAlpha; } diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index e676fafdbf..a1548b83ea 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/transparent_surface.h" #include "graphics/surface.h" #include "image/png.h" #include "image/jpeg.h" @@ -112,7 +112,7 @@ bool BaseImage::saveBMPFile(const Common::String &filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - TransparentSurface temp(*_surface, true); + Graphics::TransparentSurface temp(*_surface, true); if (_deletableSurface) { _deletableSurface->free(); delete _deletableSurface; @@ -216,7 +216,7 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - TransparentSurface temp(*origImage->_surface, false); + Graphics::TransparentSurface temp(*origImage->_surface, false); if (_deletableSurface) { _deletableSurface->free(); delete _deletableSurface; diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index ec42a63c77..f8b96b5baf 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -75,7 +75,7 @@ bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { } ////////////////////////////////////////////////////////////////////////// -bool BaseSurface::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) { +bool BaseSurface::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const Graphics::TransformStruct &transform) { return displayTransform(x, y, rect, newRect, transform); } diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 7bd9bcbaea..ea743bdaf2 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/math/rect32.h" #include "graphics/surface.h" -#include "engines/wintermute/graphics/transform_struct.h" +#include "graphics/transform_struct.h" namespace Wintermute { @@ -50,12 +50,12 @@ public: virtual bool displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); - virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const Graphics::TransformStruct &transform) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) = 0; virtual bool restore(); virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 601fcc0ffa..0f6a184cb3 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_sprite.h" #include "common/system.h" -#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/transparent_surface.h" #include "common/queue.h" #include "common/config-manager.h" @@ -254,7 +254,7 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a) { Common::Rect sizeRect(fillRect); sizeRect.translate(-fillRect.top, -fillRect.left); surf.fillRect(fillRect, col); - TransformStruct temp = TransformStruct(); + Graphics::TransformStruct temp = Graphics::TransformStruct(); temp._alphaDisable = false; drawSurface(nullptr, &surf, &sizeRect, &fillRect, temp); surf.free(); @@ -268,7 +268,7 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { return _renderSurface->format; } -void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform) { +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Graphics::TransformStruct &transform) { if (_disableDirtyRects) { RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, transform); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index c9b8a52282..bc267fd656 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -33,7 +33,7 @@ #include "common/rect.h" #include "graphics/surface.h" #include "common/list.h" -#include "engines/wintermute/graphics/transform_struct.h" +#include "graphics/transform_struct.h" namespace Wintermute { class BaseSurfaceOSystem; @@ -110,7 +110,7 @@ public: virtual bool startSpriteBatch() override; virtual bool endSpriteBatch() override; void endSaveLoad(); - void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct &transform); + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Graphics::TransformStruct &transform); BaseSurface *createSurface() override; private: /** diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 983f9c1296..a2a0032e26 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -32,8 +32,8 @@ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/graphics/transparent_surface.h" -#include "engines/wintermute/graphics/transform_tools.h" +#include "graphics/transparent_surface.h" +#include "graphics/transform_tools.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/stream.h" @@ -45,7 +45,7 @@ namespace Wintermute { BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { _surface = new Graphics::Surface(); _alphaMask = nullptr; - _alphaType = TransparentSurface::ALPHA_FULL; + _alphaType = Graphics::ALPHA_FULL; _lockPixels = nullptr; _lockPitch = 0; _loaded = false; @@ -68,10 +68,10 @@ BaseSurfaceOSystem::~BaseSurfaceOSystem() { renderer->invalidateTicketsFromSurface(this); } -TransparentSurface::AlphaType hasTransparencyType(const Graphics::Surface *surf) { +Graphics::AlphaType hasTransparencyType(const Graphics::Surface *surf) { if (surf->format.bytesPerPixel != 4) { warning("hasTransparencyType:: non 32 bpp surface passed as argument"); - return TransparentSurface::ALPHA_OPAQUE; + return Graphics::ALPHA_OPAQUE; } uint8 r, g, b, a; bool seenAlpha = false; @@ -93,11 +93,11 @@ TransparentSurface::AlphaType hasTransparencyType(const Graphics::Surface *surf) } } if (seenFullAlpha) { - return TransparentSurface::ALPHA_FULL; + return Graphics::ALPHA_FULL; } else if (seenAlpha) { - return TransparentSurface::ALPHA_BINARY; + return Graphics::ALPHA_BINARY; } else { - return TransparentSurface::ALPHA_OPAQUE; + return Graphics::ALPHA_OPAQUE; } } @@ -175,7 +175,7 @@ bool BaseSurfaceOSystem::finishLoad() { } if (needsColorKey) { - TransparentSurface trans(*_surface); + Graphics::TransparentSurface trans(*_surface); trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, replaceAlpha); } @@ -328,46 +328,46 @@ bool BaseSurfaceOSystem::endPixelOp() { ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; - return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, mirrorX, mirrorY)); + return drawSprite(x, y, &rect, nullptr, Graphics::TransformStruct(Graphics::kDefaultZoomX, Graphics::kDefaultZoomY, mirrorX, mirrorY)); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; - return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, blendMode, alpha, mirrorX, mirrorY)); + return drawSprite(x, y, &rect, nullptr, Graphics::TransformStruct(Graphics::kDefaultZoomX, Graphics::kDefaultZoomY, blendMode, alpha, mirrorX, mirrorY)); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { _rotation = 0; - return drawSprite(x, y, &rect, nullptr, TransformStruct(kDefaultZoomX, kDefaultZoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY)); + return drawSprite(x, y, &rect, nullptr, Graphics::TransformStruct(Graphics::kDefaultZoomX, Graphics::kDefaultZoomY, Graphics::kDefaultAngle, Graphics::kDefaultHotspotX, Graphics::kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY, offsetX, offsetY)); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; - return drawSprite(x, y, &rect, nullptr, TransformStruct((int32)zoomX, (int32)zoomY, blendMode, alpha, mirrorX, mirrorY)); + return drawSprite(x, y, &rect, nullptr, Graphics::TransformStruct((int32)zoomX, (int32)zoomY, blendMode, alpha, mirrorX, mirrorY)); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, Graphics::TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { _rotation = 0; - TransformStruct transform; + Graphics::TransformStruct transform; if (transparent) { - transform = TransformStruct((int32)zoomX, (int32)zoomY, kDefaultAngle, kDefaultHotspotX, kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY); + transform = Graphics::TransformStruct((int32)zoomX, (int32)zoomY, Graphics::kDefaultAngle, Graphics::kDefaultHotspotX, Graphics::kDefaultHotspotY, blendMode, alpha, mirrorX, mirrorY); } else { - transform = TransformStruct((int32)zoomX, (int32)zoomY, mirrorX, mirrorY); + transform = Graphics::TransformStruct((int32)zoomX, (int32)zoomY, mirrorX, mirrorY); } return drawSprite(x, y, &rect, nullptr, transform); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) { +bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const Graphics::TransformStruct &transform) { _rotation = (uint32)transform._angle; if (transform._angle < 0.0f) { warning("Negative rotation: %d %d", transform._angle, _rotation); @@ -380,13 +380,13 @@ bool BaseSurfaceOSystem::displayTransform(int x, int y, Rect32 rect, Rect32 newR ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY) { assert(numTimesX > 0 && numTimesY > 0); - TransformStruct transform(numTimesX, numTimesY); + Graphics::TransformStruct transform(numTimesX, numTimesY); return drawSprite(x, y, &rect, nullptr, transform); } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transform) { +bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transform) { BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); if (!_loaded) { @@ -414,13 +414,13 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, position.setHeight(newRect->height()); } else { - Rect32 r; + Common::Rect r; r.top = 0; r.left = 0; r.setWidth(rect->width()); r.setHeight(rect->height()); - r = TransformTools::newRect(r, transform, 0); + r = Graphics::TransformTools::newRect(r, transform, 0); position.top = r.top + y + transform._offset.y; position.left = r.left + x + transform._offset.x; @@ -433,7 +433,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, // But no checking is in place for that yet. // Optimize by not doing alpha-blits if we lack alpha - if (_alphaType == TransparentSurface::ALPHA_OPAQUE && !transform._alphaDisable) { + if (_alphaType == Graphics::ALPHA_OPAQUE && !transform._alphaDisable) { transform._alphaDisable = true; } @@ -452,9 +452,9 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl _surface->copyFrom(surface); } if (hasAlpha) { - _alphaType = TransparentSurface::ALPHA_FULL; + _alphaType = Graphics::ALPHA_FULL; } else { - _alphaType = TransparentSurface::ALPHA_OPAQUE; + _alphaType = Graphics::ALPHA_OPAQUE; } BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 4a05b2c66c..9fbbe1d498 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BASE_SURFACESDL_H #include "graphics/surface.h" -#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/transparent_surface.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "common/list.h" @@ -52,12 +52,12 @@ public: bool endPixelOp() override; - bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; - bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; - bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = kDefaultRgbaMod, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override; - bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = kDefaultRgbaMod, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; - bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const TransformStruct &transform) override; + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = Graphics::kDefaultRgbaMod, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) override; + bool display(int x, int y, Rect32 rect, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = Graphics::kDefaultRgbaMod, bool transparent = false, Graphics::TSpriteBlendMode blendMode = Graphics::BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) override; + bool displayTransform(int x, int y, Rect32 rect, Rect32 newRect, const Graphics::TransformStruct &transform) override; virtual bool displayTiled(int x, int y, Rect32 rect, int numTimesX, int numTimesY); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) override; /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); @@ -82,17 +82,17 @@ public: return _height; } - TransparentSurface::AlphaType getAlphaType() const { return _alphaType; } + Graphics::AlphaType getAlphaType() const { return _alphaType; } private: Graphics::Surface *_surface; bool _loaded; bool finishLoad(); - bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, TransformStruct transformStruct); + bool drawSprite(int x, int y, Rect32 *rect, Rect32 *newRect, Graphics::TransformStruct transformStruct); void genAlphaMask(Graphics::Surface *surface); uint32 getPixelAt(Graphics::Surface *surface, int x, int y); uint32 _rotation; - TransparentSurface::AlphaType _alphaType; + Graphics::AlphaType _alphaType; void *_lockPixels; int _lockPitch; byte *_alphaMask; diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp index f8579dfd41..afe884300a 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp +++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp @@ -29,12 +29,12 @@ #include "engines/wintermute/base/gfx/osystem/render_ticket.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/graphics/transform_tools.h" +#include "graphics/transform_tools.h" #include "common/textconsole.h" namespace Wintermute { -RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, TransformStruct transform) : +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Graphics::TransformStruct transform) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), @@ -57,8 +57,8 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s // NB: Mirroring and rotation are probably done in the wrong order. // (Mirroring should most likely be done before rotation. See also // TransformTools.) - if (_transform._angle != kDefaultAngle) { - TransparentSurface src(*_surface, false); + if (_transform._angle != Graphics::kDefaultAngle) { + Graphics::TransparentSurface src(*_surface, false); Graphics::Surface *temp = src.rotoscale(transform); _surface->free(); delete _surface; @@ -66,7 +66,7 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s } else if ((dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) && _transform._numTimesX * _transform._numTimesY == 1) { - TransparentSurface src(*_surface, false); + Graphics::TransparentSurface src(*_surface, false); Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); _surface->free(); delete _surface; @@ -97,7 +97,7 @@ bool RenderTicket::operator==(const RenderTicket &t) const { // Replacement for SDL2's SDL_RenderCopy void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const { - TransparentSurface src(*getSurface(), false); + Graphics::TransparentSurface src(*getSurface(), false); Common::Rect clipRect; clipRect.setWidth(getSurface()->w); @@ -105,7 +105,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const { if (_owner) { if (_transform._alphaDisable) { - src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE); + src.setAlphaMode(Graphics::ALPHA_OPAQUE); } else { src.setAlphaMode(_owner->getAlphaType()); } @@ -126,7 +126,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface) const { } void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect *dstRect, Common::Rect *clipRect) const { - TransparentSurface src(*getSurface(), false); + Graphics::TransparentSurface src(*getSurface(), false); bool doDelete = false; if (!clipRect) { doDelete = true; @@ -137,7 +137,7 @@ void RenderTicket::drawToSurface(Graphics::Surface *_targetSurface, Common::Rect if (_owner) { if (_transform._alphaDisable) { - src.setAlphaMode(TransparentSurface::ALPHA_OPAQUE); + src.setAlphaMode(Graphics::ALPHA_OPAQUE); } else { src.setAlphaMode(_owner->getAlphaType()); } diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.h b/engines/wintermute/base/gfx/osystem/render_ticket.h index de95273021..3d3bd2e844 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.h +++ b/engines/wintermute/base/gfx/osystem/render_ticket.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_RENDER_TICKET_H #define WINTERMUTE_RENDER_TICKET_H -#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/transparent_surface.h" #include "graphics/surface.h" #include "common/rect.h" @@ -51,8 +51,8 @@ class BaseSurfaceOSystem; */ class RenderTicket { public: - RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, TransformStruct transform); - RenderTicket() : _isValid(true), _wantsDraw(false), _transform(TransformStruct()) {} + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, Graphics::TransformStruct transform); + RenderTicket() : _isValid(true), _wantsDraw(false), _transform(Graphics::TransformStruct()) {} ~RenderTicket(); const Graphics::Surface *getSurface() const { return _surface; } // Non-dirty-rects: @@ -65,7 +65,7 @@ public: bool _isValid; bool _wantsDraw; - TransformStruct _transform; + Graphics::TransformStruct _transform; BaseSurfaceOSystem *_owner; bool operator==(const RenderTicket &a) const; -- cgit v1.2.3