From f7cb4170847373a84268479bd7487c20c58d5639 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 18 Nov 2018 21:40:23 -0800 Subject: GLK: Add picture drawing --- engines/glk/picture.cpp | 13 ++++++++----- engines/glk/picture.h | 2 +- engines/glk/window_text_buffer.cpp | 7 ++++--- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp index 89e75fa941..122d9c3f30 100644 --- a/engines/glk/picture.cpp +++ b/engines/glk/picture.cpp @@ -21,6 +21,8 @@ */ #include "glk/picture.h" +#include "glk/glk.h" +#include "glk/screen.h" #include "common/file.h" #include "image/jpeg.h" #include "image/png.h" @@ -29,8 +31,8 @@ namespace Glk { void Pictures::clear() { for (uint idx = 0; idx < _store.size(); ++idx) { - delete _store[idx]._picture; - delete _store[idx]._scaled; + _store[idx]._picture->decrement(); + _store[idx]._scaled->decrement(); } _store.clear(); @@ -139,6 +141,7 @@ Picture *Pictures::scale(Picture *src, size_t sx, size_t sy) { dst->transBlitFrom(*src, src->getBounds(), dst->getBounds(), (uint)-1); storeScaled(dst); + return dst; } /*--------------------------------------------------------------------------*/ @@ -154,9 +157,9 @@ void Picture::decrement() { } } -void Picture::drawPicture(int x0, int y0, int dx0, int dy0, int dx1, int dy1) { - // TODO: drawPicture +void Picture::drawPicture(const Common::Point &destPos, const Common::Rect &box) { + Graphics::Surface s = g_vm->_screen->getSubArea(box); + s.copyRectToSurface(*this, destPos.x - box.left, destPos.y, getBounds()); } - } // End of namespace Glk diff --git a/engines/glk/picture.h b/engines/glk/picture.h index c0108dd2a0..f221569368 100644 --- a/engines/glk/picture.h +++ b/engines/glk/picture.h @@ -61,7 +61,7 @@ public: /** * Draw the picture */ - void drawPicture(int x0, int y0, int dx0, int dy0, int dx1, int dy1); + void drawPicture(const Common::Point &destPos, const Common::Rect &box); }; /** diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index 4c55066603..35f5af9c6f 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -1070,7 +1070,8 @@ void TextBufferWindow::redraw() { if (ln->_lPic) { if (y < y1 && y + ln->_lPic->h > y0) { - ln->_lPic->drawPicture(x0 / GLI_SUBPIX, y, x0 / GLI_SUBPIX, y0, x1 / GLI_SUBPIX, y1); + ln->_lPic->drawPicture(Point(x0 / GLI_SUBPIX, y), + Rect(x0 / GLI_SUBPIX, y0, x1 / GLI_SUBPIX, y1)); link = ln->_lHyper; hy0 = y > y0 ? y : y0; hy1 = y + ln->_lPic->h < y1 ? y + ln->_lPic->h : y1; @@ -1084,8 +1085,8 @@ void TextBufferWindow::redraw() { if (ln->_rPic) { if (y < y1 && y + ln->_rPic->h > y0) { - ln->_rPic->drawPicture(x1 / GLI_SUBPIX - ln->_rPic->w, y, - x0 / GLI_SUBPIX, y0, x1 / GLI_SUBPIX, y1); + ln->_rPic->drawPicture(Point(x1 / GLI_SUBPIX - ln->_rPic->w, y), + Rect(x0 / GLI_SUBPIX, y0, x1 / GLI_SUBPIX, y1)); link = ln->_rHyper; hy0 = y > y0 ? y : y0; hy1 = y + ln->_rPic->h < y1 ? y + ln->_rPic->h : y1; -- cgit v1.2.3