[Scummvm-cvs-logs] SF.net SVN: scummvm: [29640] scummvm/trunk/engines/touche
cyx at users.sourceforge.net
cyx at users.sourceforge.net
Mon Nov 26 00:26:51 CET 2007
Revision: 29640
http://scummvm.svn.sourceforge.net/scummvm/?rev=29640&view=rev
Author: cyx
Date: 2007-11-25 15:26:50 -0800 (Sun, 25 Nov 2007)
Log Message:
-----------
don't expose the Common::drawLine implementation details in client code, keep it local to graphics.cpp.
Modified Paths:
--------------
scummvm/trunk/engines/touche/graphics.cpp
scummvm/trunk/engines/touche/graphics.h
scummvm/trunk/engines/touche/menu.cpp
Modified: scummvm/trunk/engines/touche/graphics.cpp
===================================================================
--- scummvm/trunk/engines/touche/graphics.cpp 2007-11-25 13:33:28 UTC (rev 29639)
+++ scummvm/trunk/engines/touche/graphics.cpp 2007-11-25 23:26:50 UTC (rev 29640)
@@ -129,17 +129,32 @@
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);
+}
- lineP.dst = dst;
- lineP.width = dstPitch;
+struct drawLineHelperData {
+ uint8 *dst;
+ int width;
+};
- ::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);
+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);
+
+ drawLineHelperData d;
+ d.dst = dst;
+ d.width = dstPitch;
+
+ ::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) {
if (dstX < 0) {
w += dstX;
Modified: scummvm/trunk/engines/touche/graphics.h
===================================================================
--- scummvm/trunk/engines/touche/graphics.h 2007-11-25 13:33:28 UTC (rev 29639)
+++ scummvm/trunk/engines/touche/graphics.h 2007-11-25 23:26:50 UTC (rev 29640)
@@ -30,11 +30,6 @@
namespace Touche {
-struct drawProcP {
- uint8 *dst;
- int width;
-};
-
class Graphics {
public:
@@ -49,15 +44,10 @@
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 */
Modified: scummvm/trunk/engines/touche/menu.cpp
===================================================================
--- scummvm/trunk/engines/touche/menu.cpp 2007-11-25 13:33:28 UTC (rev 29639)
+++ scummvm/trunk/engines/touche/menu.cpp 2007-11-25 23:26:50 UTC (rev 29640)
@@ -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 @@
{ -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);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list