From 00399d27dbe3466b4734345bfb4879c056465f80 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 15 Apr 2016 08:29:10 +0200 Subject: WAGE: Switch to ManagedSurface --- engines/wage/design.cpp | 34 +++++++++++++++++----------------- engines/wage/design.h | 32 ++++++++++++++++---------------- engines/wage/dialog.h | 2 +- engines/wage/entities.cpp | 2 +- engines/wage/entities.h | 4 ++-- engines/wage/gui-console.cpp | 2 +- engines/wage/gui.cpp | 8 ++++---- engines/wage/gui.h | 14 +++++++------- engines/wage/macwindow.cpp | 4 ++-- engines/wage/macwindow.h | 2 +- engines/wage/macwindowmanager.cpp | 4 ++-- engines/wage/macwindowmanager.h | 2 +- engines/wage/menu.cpp | 2 +- engines/wage/menu.h | 4 ++-- 14 files changed, 58 insertions(+), 58 deletions(-) (limited to 'engines') diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index 907a1ec435..a697b89430 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -52,13 +52,13 @@ namespace Wage { struct PlotData { - Graphics::Surface *surface; + Graphics::ManagedSurface *surface; Patterns *patterns; uint fillType; int thickness; Design *design; - PlotData(Graphics::Surface *s, Patterns *p, int f, int t, Design *d) : + PlotData(Graphics::ManagedSurface *s, Patterns *p, int f, int t, Design *d) : surface(s), patterns(p), fillType(f), thickness(t), design(d) {} }; @@ -83,7 +83,7 @@ Design::~Design() { delete _surface; } -void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y) { +void Design::paint(Graphics::ManagedSurface *surface, Patterns &patterns, int x, int y) { bool needRender = false; if (_surface == NULL) { @@ -96,7 +96,7 @@ void Design::paint(Graphics::Surface *surface, Patterns &patterns, int x, int y) } _bounds->debugPrint(4, "Calculated bounds:"); - _surface = new Graphics::Surface; + _surface = new Graphics::ManagedSurface; _surface->create(_bounds->width(), _bounds->height(), Graphics::PixelFormat::createFormatCLUT8()); Common::Rect r(0, 0, _bounds->width(), _bounds->height()); @@ -269,7 +269,7 @@ void drawPixelPlain(int x, int y, int color, void *data) { *((byte *)p->surface->getBasePtr(x, y)) = (byte)color; } -void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, +void Design::drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { int16 y1 = in.readSint16BE(); int16 x1 = in.readSint16BE(); @@ -298,7 +298,7 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, } } -void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, +void Design::drawRoundRect(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { int16 y1 = in.readSint16BE(); int16 x1 = in.readSint16BE(); @@ -324,7 +324,7 @@ void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, Graphics::drawRoundRect(r, arc / 2, kColorBlack, false, drawPixel, &pd); } -void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, +void Design::drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { byte ignored = in.readSint16BE(); // ignored @@ -401,7 +401,7 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, free(ypoints); } -void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, +void Design::drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { int16 y1 = in.readSint16BE(); int16 x1 = in.readSint16BE(); @@ -419,7 +419,7 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, Graphics::drawEllipse(x1, y1, x2-1, y2-1, kColorBlack, false, drawPixel, &pd); } -void Design::drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream &in) { +void Design::drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in) { int numBytes = in.readSint16BE(); int y1 = in.readSint16BE(); int x1 = in.readSint16BE(); @@ -427,7 +427,7 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream & int x2 = in.readSint16BE(); int w = x2 - x1; int h = y2 - y1; - Graphics::Surface tmp; + Graphics::ManagedSurface tmp; tmp.create(w, h, Graphics::PixelFormat::createFormatCLUT8()); @@ -507,11 +507,11 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream & tmp.free(); } -void Design::drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType) { +void Design::drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType) { drawRect(surface, rect.left, rect.top, rect.right, rect.bottom, thickness, color, patterns, fillType); } -void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType) { +void Design::drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType) { PlotData pd(surface, &patterns, fillType, thickness, nullptr); Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd); @@ -521,32 +521,32 @@ void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2 } -void Design::drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) { +void Design::drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType) { PlotData pd(surface, &patterns, fillType, 1, nullptr); for (int y = rect.top; y <= rect.bottom; y++) Graphics::drawHLine(rect.left, rect.right, y, color, drawPixel, &pd); } -void Design::drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) { +void Design::drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType) { PlotData pd(surface, &patterns, fillType, 1, nullptr); Graphics::drawRoundRect(rect, arc, color, true, drawPixel, &pd); } -void Design::drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) { +void Design::drawHLine(Graphics::ManagedSurface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType) { PlotData pd(surface, &patterns, fillType, thickness, nullptr); Graphics::drawHLine(x1, x2, y, color, drawPixel, &pd); } -void Design::drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) { +void Design::drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType) { PlotData pd(surface, &patterns, fillType, thickness, nullptr); Graphics::drawVLine(x, y1, y2, color, drawPixel, &pd); } -FloodFill::FloodFill(Graphics::Surface *surface, byte color1, byte color2) { +FloodFill::FloodFill(Graphics::ManagedSurface *surface, byte color1, byte color2) { _surface = surface; _color1 = color1; _color2 = color2; diff --git a/engines/wage/design.h b/engines/wage/design.h index e8f42f4e04..a6e0df4c40 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -48,7 +48,7 @@ #ifndef WAGE_DESIGN_H #define WAGE_DESIGN_H -#include "graphics/surface.h" +#include "graphics/managed_surface.h" #include "common/memstream.h" #include "common/rect.h" @@ -67,14 +67,14 @@ public: return _bounds; } - void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y); + void paint(Graphics::ManagedSurface *canvas, Patterns &patterns, int x, int y); bool isPointOpaque(int x, int y); - static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType); - static void drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType); - static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType); - static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType); - static void drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType); - static void drawVLine(Graphics::Surface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType); + static void drawRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType); + static void drawRect(Graphics::ManagedSurface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType); + static void drawFilledRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType); + static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType); + static void drawHLine(Graphics::ManagedSurface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType); + static void drawVLine(Graphics::ManagedSurface *surface, int x, int y1, int y2, int thickness, int color, Patterns &patterns, byte fillType); bool isBoundsCalculation() { return _boundsCalculationMode; } void adjustBounds(int16 x, int16 y); @@ -83,32 +83,32 @@ private: byte *_data; int _len; Common::Rect *_bounds; - Graphics::Surface *_surface; + Graphics::ManagedSurface *_surface; bool _boundsCalculationMode; private: void render(Patterns &patterns); - void drawRect(Graphics::Surface *surface, Common::ReadStream &in, + void drawRect(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); - void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, + void drawRoundRect(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); - void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, + void drawPolygon(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); - void drawOval(Graphics::Surface *surface, Common::ReadStream &in, + void drawOval(Graphics::ManagedSurface *surface, Common::ReadStream &in, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); - void drawBitmap(Graphics::Surface *surface, Common::SeekableReadStream &in); + void drawBitmap(Graphics::ManagedSurface *surface, Common::SeekableReadStream &in); }; class FloodFill { public: - FloodFill(Graphics::Surface *surface, byte color1, byte color2); + FloodFill(Graphics::ManagedSurface *surface, byte color1, byte color2); ~FloodFill(); void addSeed(int x, int y); void fill(); private: Common::List _queue; - Graphics::Surface *_surface; + Graphics::ManagedSurface *_surface; byte _color1, _color2; byte *_visited; int _w, _h; diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h index c5878acc95..ec99fc06b2 100644 --- a/engines/wage/dialog.h +++ b/engines/wage/dialog.h @@ -74,7 +74,7 @@ public: private: Gui *_gui; - Graphics::Surface _tempSurface; + Graphics::ManagedSurface _tempSurface; Common::Rect _bbox; Common::String _text; diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp index adb053868a..49e2592949 100644 --- a/engines/wage/entities.cpp +++ b/engines/wage/entities.cpp @@ -134,7 +134,7 @@ Scene::~Scene() { delete _textBounds; } -void Scene::paint(Graphics::Surface *surface, int x, int y) { +void Scene::paint(Graphics::ManagedSurface *surface, int x, int y) { Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10); surface->fillRect(r, kColorWhite); diff --git a/engines/wage/entities.h b/engines/wage/entities.h index 33cf087322..c393f15f01 100644 --- a/engines/wage/entities.h +++ b/engines/wage/entities.h @@ -49,7 +49,7 @@ #define WAGE_ENTITIES_H namespace Graphics { - struct Surface; + class ManagedSurface; } namespace Wage { @@ -326,7 +326,7 @@ public: return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds); } - void paint(Graphics::Surface *screen, int x, int y); + void paint(Graphics::ManagedSurface *screen, int x, int y); const char *getFontName(); }; diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp index ab5df637ec..3a3f189dce 100644 --- a/engines/wage/gui-console.cpp +++ b/engines/wage/gui-console.cpp @@ -142,7 +142,7 @@ void Gui::flowText(Common::String &str) { draw(); } -void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) { +void Gui::renderConsole(Graphics::ManagedSurface *g, Common::Rect &r) { bool fullRedraw = _consoleFullRedraw; bool textReflow = false; int surfW = r.width() + kConWOverlap * 2; diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index 50b8b00861..8d605fee1c 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -314,14 +314,14 @@ void Gui::drawConsole() { paintBorder(&_screen, _consoleTextArea, kWindowConsole); } -void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) { +void Gui::drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h) { Common::Rect r(x, y, x + w + 1, y + h + 1); g->fillRect(r, kColorWhite); g->frameRect(r, kColorBlack); } -void Gui::fillRect(Graphics::Surface *g, int x, int y, int w, int h, int color) { +void Gui::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color) { Common::Rect r(x, y, x + w, y + h); g->fillRect(r, color); @@ -338,7 +338,7 @@ const int arrowPixels[ARROW_H][ARROW_W] = { {1,1,1,1,1,1,1,1,1,1,1,1}}; static void drawPixelInverted(int x, int y, int color, void *data) { - Graphics::Surface *surface = (Graphics::Surface *)data; + Graphics::ManagedSurface *surface = (Graphics::ManagedSurface *)data; if (x >= 0 && x < surface->w && y >= 0 && y < surface->h) { byte *p = (byte *)surface->getBasePtr(x, y); @@ -347,7 +347,7 @@ static void drawPixelInverted(int x, int y, int color, void *data) { } } -void Gui::paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType, int highlightedPart, float scrollPos, float scrollSize) { +void Gui::paintBorder(Graphics::ManagedSurface *g, Common::Rect &r, WindowType windowType, int highlightedPart, float scrollPos, float scrollSize) { bool active = false, scrollable = false, closeable = false, drawTitle = false; const int size = kBorderWidth; int x = r.left - size; diff --git a/engines/wage/gui.h b/engines/wage/gui.h index 11e001b274..9d59e33bc2 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -51,7 +51,7 @@ #include "common/str-array.h" #include "graphics/font.h" #include "graphics/fontman.h" -#include "graphics/surface.h" +#include "graphics/managed_surface.h" #include "common/rect.h" #include "wage/macwindow.h" @@ -117,11 +117,11 @@ private: void drawConsole(); void undrawCursor(); void drawDesktop(); - void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType, int highlightedPart = kBorderNone, + void paintBorder(Graphics::ManagedSurface *g, Common::Rect &r, WindowType windowType, int highlightedPart = kBorderNone, float scrollPos = 0.0, float scrollSize = 0.0); - void renderConsole(Graphics::Surface *g, Common::Rect &r); - void drawBox(Graphics::Surface *g, int x, int y, int w, int h); - void fillRect(Graphics::Surface *g, int x, int y, int w, int h, int color = kColorBlack); + void renderConsole(Graphics::ManagedSurface *g, Common::Rect &r); + void drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h); + void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color = kColorBlack); void loadFonts(); void flowText(Common::String &str); const Graphics::Font *getConsoleFont(); @@ -132,7 +132,7 @@ private: void updateTextSelection(int x, int y); public: - Graphics::Surface _screen; + Graphics::ManagedSurface _screen; int _cursorX, _cursorY; bool _cursorState; Common::Rect _consoleTextArea; @@ -149,7 +149,7 @@ public: bool _menuDirty; private: - Graphics::Surface _console; + Graphics::ManagedSurface _console; Menu *_menu; Scene *_scene; bool _sceneDirty; diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 3abfdf6017..7a080a38fa 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -100,7 +100,7 @@ void MacWindow::setDimensions(const Common::Rect &r) { move(r.left, r.top); } -void MacWindow::draw(Graphics::Surface *g, bool forceRedraw) { +void MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) { if (_borderIsDirty || forceRedraw) drawBorder(); } @@ -124,7 +124,7 @@ const int arrowPixels[ARROW_H][ARROW_W] = { {1,1,1,1,1,1,1,1,1,1,1,1}}; static void drawPixelInverted(int x, int y, int color, void *data) { - Graphics::Surface *surface = (Graphics::Surface *)data; + Graphics::ManagedSurface *surface = (Graphics::ManagedSurface *)data; if (x >= 0 && x < surface->w && y >= 0 && y < surface->h) { byte *p = (byte *)surface->getBasePtr(x, y); diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 0d7d49f06d..b8a04a2af8 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -75,7 +75,7 @@ public: void move(int x, int y); void resize(int w, int h); void setDimensions(const Common::Rect &r); - void draw(Graphics::Surface *g, bool forceRedraw = false); + void draw(Graphics::ManagedSurface *g, bool forceRedraw = false); void setActive(bool active); Graphics::ManagedSurface *getSurface() { return &_surface; } void setTitle(Common::String &title) { _title = title; } diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp index 14c3f236e8..72f01fac67 100644 --- a/engines/wage/macwindowmanager.cpp +++ b/engines/wage/macwindowmanager.cpp @@ -48,7 +48,7 @@ #include "common/list.h" #include "common/array.h" -#include "graphics/surface.h" +#include "graphics/managed_surface.h" #include "wage/wage.h" #include "wage/macwindow.h" @@ -94,7 +94,7 @@ void MacWindowManager::setActive(int id) { _fullRefresh = true; } -void MacWindowManager::draw(Graphics::Surface *g) { +void MacWindowManager::draw(Graphics::ManagedSurface *g) { for (Common::List::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) (*it)->draw(g, _fullRefresh); diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h index b15c7737c6..1c8ed02a85 100644 --- a/engines/wage/macwindowmanager.h +++ b/engines/wage/macwindowmanager.h @@ -60,7 +60,7 @@ public: int add(bool scrollable); void setActive(int id); - void draw(Graphics::Surface *g); + void draw(Graphics::ManagedSurface *g); MacWindow *getWindow(int id) { return _windows[id]; } diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp index 12ef8c2219..9bd43275b2 100644 --- a/engines/wage/menu.cpp +++ b/engines/wage/menu.cpp @@ -397,7 +397,7 @@ void Menu::renderSubmenu(MenuItem *menu) { } if (!text.empty()) { - Graphics::Surface *s = &_gui->_screen; + Graphics::ManagedSurface *s = &_gui->_screen; int tx = x, ty = y; if (!menu->subitems[i]->enabled) { diff --git a/engines/wage/menu.h b/engines/wage/menu.h index 3550356bc6..916ef6d50e 100644 --- a/engines/wage/menu.h +++ b/engines/wage/menu.h @@ -111,8 +111,8 @@ public: private: Gui *_gui; - Graphics::Surface _screenCopy; - Graphics::Surface _tempSurface; + Graphics::ManagedSurface _screenCopy; + Graphics::ManagedSurface _tempSurface; private: const Graphics::Font *getMenuFont(); -- cgit v1.2.3