Ticket #8428: drawLine2.diff
File drawLine2.diff, 1.8 KB (added by , 20 years ago) |
---|
-
graphics/surface.cpp
diff -ur --exclude=CVS --exclude=Makefile ScummVM/graphics/surface.cpp ScummVM+hack/graphics/surface.cpp
old new 20 20 21 21 #include "common/stdafx.h" 22 22 #include "common/util.h" 23 #include "graphics/primitives.h" 23 24 #include "graphics/surface.h" 24 25 25 26 namespace Graphics { 26 27 28 static void plotPoint1(int x, int y, int color, void *data) { 29 Surface *s = (Surface *)data; 30 byte *ptr = (byte *)s->getBasePtr(x, y); 31 *ptr = (byte)color; 32 } 33 34 static void plotPoint2(int x, int y, int color, void *data) { 35 Surface *s = (Surface *)data; 36 uint16 *ptr = (uint16 *)s->getBasePtr(x, y); 37 *ptr = (uint16)color; 38 } 39 40 void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) { 41 if (bytesPerPixel == 1) 42 Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint1, this); 43 else if (bytesPerPixel == 2) 44 Graphics::drawLine(x0, y0, x1, y1, color, &plotPoint2, this); 45 else 46 error("Surface::drawLine: bytesPerPixel must be 1 or 2"); 47 } 48 27 49 void Surface::hLine(int x, int y, int x2, uint32 color) { 28 50 // Clipping 29 51 if (y < 0 || y >= h) -
graphics/surface.h
diff -ur --exclude=CVS --exclude=Makefile ScummVM/graphics/surface.h ScummVM+hack/graphics/surface.h
old new 46 46 inline void *getBasePtr(int x, int y) { 47 47 return static_cast<void *>(static_cast<byte *>(pixels) + y * pitch + x * bytesPerPixel); 48 48 } 49 49 50 void drawLine(int x0, int y0, int x1, int y1, uint32 color); 50 51 void hLine(int x, int y, int x2, uint32 color); 51 52 void vLine(int x, int y, int y2, uint32 color); 52 53 void fillRect(const Common::Rect &r, uint32 color);