From 6f4e80e36e7729bd2137a1a2bde712521861b0b3 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Thu, 12 Sep 2013 09:30:28 -0500 Subject: ZVISION: Add wrapper function for copyRectToSurface Also rename some arguments to make them more clear --- graphics/surface.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'graphics/surface.cpp') diff --git a/graphics/surface.cpp b/graphics/surface.cpp index d808121c87..a8173f0e9c 100644 --- a/graphics/surface.cpp +++ b/graphics/surface.cpp @@ -133,17 +133,17 @@ const Surface Surface::getSubArea(const Common::Rect &area) const { return subSurface; } -void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int width, int height) { +void Surface::copyRectToSurface(const void *buffer, int pitch, int destX, int destY, int width, int height) { assert(buffer); - assert(x >= 0 && x < w); - assert(y >= 0 && y < h); - assert(height > 0 && y + height <= h); - assert(width > 0 && x + width <= w); + assert(destX >= 0 && destX < w); + assert(destY >= 0 && destY < h); + assert(height > 0 && destY + height <= h); + assert(width > 0 && destX + width <= w); // Copy buffer data to internal buffer const byte *src = (const byte *)buffer; - byte *dst = (byte *)getBasePtr(x, y); + byte *dst = (byte *)getBasePtr(destX, destY); for (int i = 0; i < height; i++) { memcpy(dst, src, width * format.bytesPerPixel); src += pitch; @@ -151,6 +151,12 @@ void Surface::copyRectToSurface(const void *buffer, int pitch, int x, int y, int } } +void Surface::copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect) { + assert(srcSurface.format == format); + + copyRectToSurface(srcSurface.getBasePtr(subRect.left, subRect.top), srcSurface.pitch, destX, destY, subRect.width(), subRect.height()); +} + void Surface::hLine(int x, int y, int x2, uint32 color) { // Clipping if (y < 0 || y >= h) -- cgit v1.2.3