aboutsummaryrefslogtreecommitdiff
path: root/engines/touche/graphics.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2007-11-25 10:27:50 +0000
committerEugene Sandulenko2007-11-25 10:27:50 +0000
commit8d228219c9121b0152fbf1f1fcab6a477574e9a2 (patch)
tree3aa964834553e77a9355662426e7f06c05a37cc8 /engines/touche/graphics.cpp
parent1266b7eb15ca9d095da8eef310726c3bf10899ad (diff)
downloadscummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.tar.gz
scummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.tar.bz2
scummvm-rg350-8d228219c9121b0152fbf1f1fcab6a477574e9a2.zip
Switch to our common drawLine routine
svn-id: r29635
Diffstat (limited to 'engines/touche/graphics.cpp')
-rw-r--r--engines/touche/graphics.cpp56
1 files changed, 8 insertions, 48 deletions
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) {