From 8d228219c9121b0152fbf1f1fcab6a477574e9a2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 25 Nov 2007 10:27:50 +0000 Subject: Switch to our common drawLine routine svn-id: r29635 --- engines/touche/graphics.cpp | 56 +++++++-------------------------------------- 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'engines/touche/graphics.cpp') diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp index cb5f60a4c9..13619eebd1 100644 --- a/engines/touche/graphics.cpp +++ b/engines/touche/graphics.cpp @@ -24,6 +24,7 @@ */ #include "common/endian.h" +#include "graphics/primitives.h" #include "touche/graphics.h" @@ -128,56 +129,15 @@ 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; - 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); -} - -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); - - dst += y1 * dstPitch + x1; - - int yInc, dy = y2 - y1; - if (dy < 0) { - dy = -dy; - yInc = -dstPitch; - } else { - yInc = dstPitch; - } - - int xInc, dx = x2 - x1; - if (dx < 0) { - dx = -dx; - xInc = -1; - } else { - xInc = 1; - } + drawProcP lineP; - int step = 0; + lineP.dst = dst; + lineP.width = dstPitch; - if (dx > dy) { - for (int i = 0; i < dx + 1; ++i) { - *dst = color; - dst += xInc; - step += dy; - if (step > dx) { - step -= dx; - dst += yInc; - } - } - } else { - for (int i = 0; i < dy + 1; ++i) { - *dst = color; - dst += yInc; - step += dx; - if (step > 0) { - step -= dy; - dst += xInc; - } - } - } + ::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); } 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) { -- cgit v1.2.3