aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-10-17 23:00:00 +0200
committerWillem Jan Palenstijn2013-10-17 23:00:00 +0200
commita532c7729f6f16e07948dbf6c6e6ecfe89c87ff8 (patch)
treeeebd8ce8883e50be1487d18c19b818e4e7b91dc9 /graphics
parent6b9abcc2ec8409f37a9926a35d061096fab60018 (diff)
parent7a97c992de67152514886f80f3cf4f2f3686d3d4 (diff)
downloadscummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.tar.gz
scummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.tar.bz2
scummvm-rg350-a532c7729f6f16e07948dbf6c6e6ecfe89c87ff8.zip
Merge branch 'zvision'
This merges pull request 395 for the ZVision engine developed during GSoC2013.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/surface.cpp24
-rw-r--r--graphics/surface.h24
2 files changed, 48 insertions, 0 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 929157203e..777c1058fb 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -133,6 +133,30 @@ const Surface Surface::getSubArea(const Common::Rect &area) const {
return subSurface;
}
+void Surface::copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height) {
+ assert(buffer);
+
+ 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(destX, destY);
+ for (int i = 0; i < height; i++) {
+ memcpy(dst, src, width * format.bytesPerPixel);
+ src += srcPitch;
+ dst += pitch;
+ }
+}
+
+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)
diff --git a/graphics/surface.h b/graphics/surface.h
index b08d4a5cb7..07e289b0bb 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -209,6 +209,30 @@ public:
const Surface getSubArea(const Common::Rect &area) const;
/**
+ * Copies a bitmap to the Surface internal buffer. The pixel format
+ * of buffer must match the pixel format of the Surface.
+ *
+ * @param buffer The buffer containing the graphics data source
+ * @param pitch The pitch of the buffer (number of bytes in a scanline)
+ * @param destX The x coordinate of the destination rectangle
+ * @param destY The y coordinate of the destination rectangle
+ * @param width The width of the destination rectangle
+ * @param height The height of the destination rectangle
+ */
+ void copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height);
+ /**
+ * Copies a bitmap to the Surface internal buffer. The pixel format
+ * of buffer must match the pixel format of the Surface.
+ *
+ * @param srcSurface The source of the bitmap data
+ * @param destX The x coordinate of the destination rectangle
+ * @param destY The y coordinate of the destination rectangle
+ * @param subRect The subRect of surface to be blitted
+ * @return
+ */
+ void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect);
+
+ /**
* Convert the data to another pixel format.
*
* This works in-place. This means it will not create an additional buffer