aboutsummaryrefslogtreecommitdiff
path: root/graphics/surface.cpp
diff options
context:
space:
mode:
authorKamil Zbróg2013-10-19 12:40:55 +0100
committerKamil Zbróg2013-10-19 12:40:55 +0100
commit852a9637119b544400984508ca20ccf47ed66a81 (patch)
tree34f4091af3ee3f08b6ee32092eaf28d7b8a62f83 /graphics/surface.cpp
parent3a4068f87be678bd7446c32a1baa8869522ebd71 (diff)
parenta9aaca460875c6d7a244e3f36a1cad62ec09411d (diff)
downloadscummvm-rg350-852a9637119b544400984508ca20ccf47ed66a81.tar.gz
scummvm-rg350-852a9637119b544400984508ca20ccf47ed66a81.tar.bz2
scummvm-rg350-852a9637119b544400984508ca20ccf47ed66a81.zip
Merge branch 'master' into prince
Conflicts: engines/plugins_table.h
Diffstat (limited to 'graphics/surface.cpp')
-rw-r--r--graphics/surface.cpp24
1 files changed, 24 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)