[Scummvm-cvs-logs] SF.net SVN: scummvm:[39449] scummvm/trunk/engines/sci/gfx

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Mar 16 16:36:17 CET 2009


Revision: 39449
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39449&view=rev
Author:   thebluegr
Date:     2009-03-16 15:36:09 +0000 (Mon, 16 Mar 2009)

Log Message:
-----------
Replaced some rect_t operations with our common ones. For now, two helper functions are used to easily change types between Common::Rect and rect_t, until rect_t is removed

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_system.h
    scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
    scummvm/trunk/engines/sci/gfx/operations.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_system.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-03-16 14:38:57 UTC (rev 39448)
+++ scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-03-16 15:36:09 UTC (rev 39449)
@@ -113,7 +113,6 @@
 	int width, height; /* width, height: (x,y,width,height)=(5,5,1,1) occupies 1 pixel */
 };
 
-
 /* Generates a rect_t from index data
 ** Parameters: (int x int) x,y: Upper left point of the rectangle
 **             (int x int) width, height: Horizontal and vertical extension of the rectangle
@@ -130,6 +129,15 @@
 	return rect;
 }
 
+// Temporary helper functions to ease the transition from rect_t to Common::Rect
+static rect_t toSCIRect(Common::Rect in) {
+	return gfx_rect(in.left, in.top, in.width(), in.height());
+}
+
+static Common::Rect toCommonRect(rect_t in) {
+	return Common::Rect(in.x, in.y, in.x + in.width, in.y + in.height);
+}
+
 #define GFX_PRINT_RECT(rect) (rect).x, (rect).y, (rect).width, (rect).height
 
 #define OVERLAP(a, b, z, zl) (a.z >= b.z && a.z < (b.z + b.zl))
@@ -144,69 +152,9 @@
 
 #undef OVERLAP
 
-#define MERGE_PARTIAL(z, zl) \
-if (a.z < b.z) SUBMERGE_PARTIAL(a, b, z, zl) \
-else SUBMERGE_PARTIAL(b, a, z, zl)
-
-#define SUBMERGE_PARTIAL(a, b, z, zl) \
-{ \
-	retval.z = a.z; \
-	retval.zl = a.zl; \
-	if (b.z + b.zl > a.z + a.zl) \
-		retval.zl = (b.z + b.zl - a.z); \
-}
-
-
-
-#define RECT(a) a.x, a.y, a.width, a.height
-
-/* Merges two rects
-** Parameters: (rect_t x rect_t) a,b: The two rects to merge
-** Returns   : (rect_t) The smallest rect containing both a and b
-*/
-static inline rect_t gfx_rects_merge(rect_t a, rect_t b) {
-	rect_t retval;
-	MERGE_PARTIAL(x, width);
-	MERGE_PARTIAL(y, height);
-	return retval;
-}
-#undef MERGE_PARTIAL
-#undef SUBMERGE_PARTIAL
-
-
-/* Subset predicate for rectangles
-** Parameters: (rect_t) a, b: The two rects to compare
-** Returns   : non-zero iff for each pixel p in a the following holds: p is in b.
-*/
-static inline int gfx_rect_subset(rect_t a, rect_t b) {
-	return ((a.x >= b.x) && (a.y >= b.y) && ((a.x + a.width) <= (b.x + b.width)) && ((a.y + a.height) <= (b.y + b.height)));
-}
-
-
-/* Equality predicate for rects
-** Parameters: (rect_t) a, b
-** Returns   : (int) gfx_rect_subset(a,b) AND gfx_rect_subset(b,a)
-*/
-static inline int gfx_rect_equals(rect_t a, rect_t b) {
-	return (a.x == b.x && a.width == b.width && a.y == b.y && a.height == b.height);
-}
-
-
 /* gfx_rect_fullscreen is declared in gfx/gfx_tools.c */
 extern rect_t gfx_rect_fullscreen;
 
-/* Translation operation for rects
-** Parameters: (rect_t) rect: The rect to translate
-**             (Common::Point) offset: The offset to translate it by
-** Returns   : (rect_t) The translated rect
-*/
-static inline rect_t gfx_rect_translate(rect_t rect, Common::Point offset) {
-	rect.x += offset.x;
-	rect.y += offset.y;
-
-	return rect;
-}
-
 #define GFX_RESID_NONE -1
 
 #define GFX_PIC_COLORS 256

Modified: scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-16 14:38:57 UTC (rev 39448)
+++ scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-16 15:36:09 UTC (rev 39449)
@@ -411,7 +411,7 @@
 	if (box->shade_type != GFX_BOX_SHADE_FLAT && box->color2.alpha)
 		return 0;
 
-	if (!gfx_rect_subset(other->bounds, box->bounds))
+	if (!toCommonRect(box->bounds).contains(toCommonRect(other->bounds)))
 		return 0;
 
 	return 1;
@@ -424,7 +424,7 @@
 
 	obox = (gfxw_box_t *) other;
 
-	if (!gfx_rect_equals(wbox->bounds, obox->bounds))
+	if (!toCommonRect(wbox->bounds).equals(toCommonRect(obox->bounds)))
 		return 0;
 
 	if (!_color_equals(wbox->color1, obox->color1))
@@ -491,7 +491,7 @@
 
 	oprim = (gfxw_primitive_t *) other;
 
-	if (!gfx_rect_equals(wprim->bounds, oprim->bounds))
+	if (!toCommonRect(wprim->bounds).equals(toCommonRect(oprim->bounds)))
 		return 0;
 
 	if (!_color_equals(wprim->color, oprim->color))
@@ -1972,7 +1972,8 @@
 		bounds.y += widget->parent->bounds.y;
 	}
 
-	return ((widget->serial >= free_above_eq || widget->serial < free_below) && gfx_rect_subset(bounds, snapshot->area));
+	return ((widget->serial >= free_above_eq || widget->serial < free_below) && 
+		toCommonRect(snapshot->area).contains(toCommonRect(bounds)));
 }
 
 #define MAGIC_FREE_NUMBER -42
@@ -2074,7 +2075,7 @@
 	gfxw_widget_t *seeker = GFXWC(chrono->contents)->contents;
 
 	while (seeker) {
-		if (gfx_rect_equals(seeker->bounds, widget->bounds)) {
+		if (toCommonRect(seeker->bounds).equals(toCommonRect(widget->bounds))) {
 			gfxw_annihilate(GFXW(seeker));
 			return 1;
 		}
@@ -2106,7 +2107,9 @@
 		bounds = widget->bounds;
 		origin.x = seeker->parent->zone.x;
 		origin.y = seeker->parent->zone.y;
-		gfx_rect_translate(bounds, origin);
+		Common::Rect tmp = toCommonRect(bounds);
+		tmp.translate(origin.x, origin.y);
+		bounds = toSCIRect(tmp);
 
 		if (gfx_rects_overlap(bounds, seeker->bounds))
 			return seeker;
@@ -2134,7 +2137,10 @@
 		gfxw_remove_widget_from_container(GFXWC(chrono->parent), GFXW(chrono));
 		gfxw_annihilate(GFXW(chrono));
 
-		gfx_rect_translate(tw->zone, origin);
+		Common::Rect tmp = toCommonRect(tw->zone);
+		tmp.translate(origin.x, origin.y);
+		tw->zone = toSCIRect(tmp);
+
 		target->add(GFXWC(target), GFXW(tw));
 	}
 }

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-16 14:38:57 UTC (rev 39448)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-16 15:36:09 UTC (rev 39449)
@@ -335,10 +335,13 @@
 	switch (strategy) {
 
 	case GFXOP_DIRTY_FRAMES_ONE:
-		if (base)
-			base->rect = gfx_rects_merge(box, base->rect);
-		else
+		if (base) {
+			Common::Rect tmp = toCommonRect(box);
+			tmp.extend(toCommonRect(base->rect));
+			base->rect = toSCIRect(tmp);
+		} else {
 			base = _rect_create(box);
+		}
 		break;
 
 	case GFXOP_DIRTY_FRAMES_CLUSTERS: {
@@ -347,7 +350,10 @@
 		while (*rectp) {
 			if (gfx_rects_overlap((*rectp)->rect, box)) {
 				gfx_dirty_rect_t *next = (*rectp)->next;
-				box = gfx_rects_merge((*rectp)->rect, box);
+				Common::Rect tmp = toCommonRect((*rectp)->rect);
+				tmp.extend(toCommonRect(box));
+				box = toSCIRect(tmp);
+
 				free(*rectp);
 				*rectp = next;
 			} else


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list