diff options
author | Gregory Montoir | 2007-11-25 23:26:50 +0000 |
---|---|---|
committer | Gregory Montoir | 2007-11-25 23:26:50 +0000 |
commit | 3d59f805202bd1d2161baa69902d377fa01ee7c6 (patch) | |
tree | 80dee7bda4ee042b3232142dc645168b9a03cfcc /engines/touche | |
parent | 7844ad6f2c5499a1dfd9430cd57686ed36d908c9 (diff) | |
download | scummvm-rg350-3d59f805202bd1d2161baa69902d377fa01ee7c6.tar.gz scummvm-rg350-3d59f805202bd1d2161baa69902d377fa01ee7c6.tar.bz2 scummvm-rg350-3d59f805202bd1d2161baa69902d377fa01ee7c6.zip |
don't expose the Common::drawLine implementation details in client code, keep it local to graphics.cpp.
svn-id: r29640
Diffstat (limited to 'engines/touche')
-rw-r--r-- | engines/touche/graphics.cpp | 29 | ||||
-rw-r--r-- | engines/touche/graphics.h | 12 | ||||
-rw-r--r-- | engines/touche/menu.cpp | 9 |
3 files changed, 24 insertions, 26 deletions
diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp index 13619eebd1..999aa8005c 100644 --- a/engines/touche/graphics.cpp +++ b/engines/touche/graphics.cpp @@ -129,15 +129,30 @@ void Graphics::drawRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, ui const int y1 = y; const int x2 = x + w - 1; const int y2 = y + h - 1; - drawProcP lineP; + drawLine(dst, dstPitch, x1, y1, x2, y1, color1); + drawLine(dst, dstPitch, x1, y1, x1, y2, color1); + drawLine(dst, dstPitch, x2, y1 + 1, x2, y2, color2); + drawLine(dst, dstPitch, x1 + 1, y2, x2, y2, color2); +} + +struct drawLineHelperData { + uint8 *dst; + int width; +}; + +static void drawLineHelper(int x, int y, int c, void *data) { + drawLineHelperData *param = (drawLineHelperData *)data; + *(param->dst + y * param->width + x) = c; +} + +void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2, uint8 color) { + assert(x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0); - lineP.dst = dst; - lineP.width = dstPitch; + drawLineHelperData d; + d.dst = dst; + d.width = dstPitch; - ::Graphics::drawLine(x1, y1, x2, y1, color1, drawProc, &lineP); - ::Graphics::drawLine(x1, y1, x1, y2, color1, drawProc, &lineP); - ::Graphics::drawLine(x2, y1 + 1, x2, y2, color2, drawProc, &lineP); - ::Graphics::drawLine(x1 + 1, y2, x2, y2, color2, drawProc, &lineP); + ::Graphics::drawLine(x1, y1, x2, y2, color, drawLineHelper, &d); } void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) { diff --git a/engines/touche/graphics.h b/engines/touche/graphics.h index 74928cefcf..6b4072d896 100644 --- a/engines/touche/graphics.h +++ b/engines/touche/graphics.h @@ -30,11 +30,6 @@ namespace Touche { -struct drawProcP { - uint8 *dst; - int width; -}; - class Graphics { public: @@ -49,15 +44,10 @@ public: static int drawChar16(uint8 *dst, int dstPitch, uint8 chr, int x, int y, uint16 color); static void fillRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, uint8 color); static void drawRect(uint8 *dst, int dstPitch, int x, int y, int w, int h, uint8 color1, uint8 color2); + static void drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2, uint8 color); static void copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags = 0); static void copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor); - static void drawProc(int x, int y, int c, void *data) { - drawProcP *param = (drawProcP *)data; - - *(param->dst + y * param->width + x) = c; - } - private: /* font data for english version */ diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index 1c3dfe87ee..2dacab4132 100644 --- a/engines/touche/menu.cpp +++ b/engines/touche/menu.cpp @@ -28,8 +28,6 @@ #include "common/system.h" #include "common/savefile.h" -#include "graphics/primitives.h" - #include "touche/graphics.h" #include "touche/midi.h" #include "touche/touche.h" @@ -136,17 +134,12 @@ static void drawArrow(uint8 *dst, int dstPitch, int x, int y, int delta, uint8 c { -9, 0, 0, -9 }, { 0, -9, 9, 0 } }; - drawProcP lineP; - - lineP.dst = dst; - lineP.width = dstPitch; - for (uint i = 0; i < 7; ++i) { const int x1 = x + arrowCoordsTable[i][0]; const int y1 = y + arrowCoordsTable[i][1] * delta; const int x2 = x + arrowCoordsTable[i][2]; const int y2 = y + arrowCoordsTable[i][3] * delta; - ::Graphics::drawLine(x1, y1, x2, y2, color, Graphics::drawProc, &lineP); + Graphics::drawLine(dst, dstPitch, x1, y1, x2, y2, color); } } |