aboutsummaryrefslogtreecommitdiff
path: root/engines/toon/picture.cpp
diff options
context:
space:
mode:
authorsylvaintv2011-03-08 00:51:21 +0100
committersylvaintv2011-03-08 00:51:21 +0100
commit53d6a4f831c9e7c7de594cdaed3c8546b41ea2e2 (patch)
tree4b89d219842fad3a6ff00778e175c3868b4fe628 /engines/toon/picture.cpp
parent7d36aabd4271212e2c0b741172a40d07871e5b4c (diff)
downloadscummvm-rg350-53d6a4f831c9e7c7de594cdaed3c8546b41ea2e2.tar.gz
scummvm-rg350-53d6a4f831c9e7c7de594cdaed3c8546b41ea2e2.tar.bz2
scummvm-rg350-53d6a4f831c9e7c7de594cdaed3c8546b41ea2e2.zip
TOON: Decrease CPU usage
Added dirty rects Reduced the max FPS from 60 to 30
Diffstat (limited to 'engines/toon/picture.cpp')
-rw-r--r--engines/toon/picture.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/engines/toon/picture.cpp b/engines/toon/picture.cpp
index 18e6a8cf7f..fce711717a 100644
--- a/engines/toon/picture.cpp
+++ b/engines/toon/picture.cpp
@@ -187,6 +187,44 @@ void Picture::drawMask(Graphics::Surface &surface, int32 x, int32 y, int32 dx, i
}
}
+void Picture::drawWithRectList(Graphics::Surface& surface, int32 x, int32 y, int32 dx, int32 dy, Common::Array<Common::Rect>& rectArray) {
+
+ int32 rx = MIN(_width, surface.w - x);
+ int32 ry = MIN(_height, surface.h - y);
+
+ if (rx < 0 || ry < 0)
+ return;
+
+ int32 destPitch = surface.pitch;
+ int32 srcPitch = _width;
+
+ for (uint32 i = 0; i < rectArray.size(); i++) {
+
+ Common::Rect rect = rectArray[i];
+
+ int32 fillRx = MIN<int32>(rx, rect.right - rect.left);
+ int32 fillRy = MIN<int32>(ry, rect.bottom - rect.top);
+
+ uint8 *c = _data + _width * (dy + rect.top) + (dx + rect.left);
+ uint8 *curRow = (uint8 *)surface.pixels + (y + rect.top) * destPitch + (x + rect.left);
+
+ for (int32 yy = 0; yy < fillRy; yy++) {
+ uint8 *curSrc = c;
+ uint8 *cur = curRow;
+ for (int32 xx = 0; xx < fillRx; xx++) {
+ *cur = *curSrc;
+ curSrc++;
+ cur++;
+ }
+ curRow += destPitch;
+ c += srcPitch;
+ }
+
+ }
+
+
+}
+
void Picture::draw(Graphics::Surface &surface, int32 x, int32 y, int32 dx, int32 dy) {
debugC(6, kDebugPicture, "draw(surface, %d, %d, %d, %d)", x, y, dx, dy);