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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Mar 19 20:52:05 CET 2009


Revision: 39534
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39534&view=rev
Author:   thebluegr
Date:     2009-03-19 19:52:05 +0000 (Thu, 19 Mar 2009)

Log Message:
-----------
Fixed issues with commit #39449, fixing some graphical glitches with the GUI widgets

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

Modified: scummvm/trunk/engines/sci/gfx/gfx_state_internal.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_state_internal.h	2009-03-19 19:42:22 UTC (rev 39533)
+++ scummvm/trunk/engines/sci/gfx/gfx_state_internal.h	2009-03-19 19:52:05 UTC (rev 39534)
@@ -55,7 +55,6 @@
 	GFXW_RECT,
 	GFXW_LINE, /* For lines, the bounding rectangle's xl, yl determine the line's expansion:
 		   ** (x2, y2) = (x+xl, y+yl) */
-	GFXW_INVERSE_LINE,
 	GFXW_VIEW,
 	GFXW_STATIC_VIEW,
 	GFXW_DYN_VIEW,
@@ -119,7 +118,7 @@
 };
 
 
-#define GFXW_IS_PRIMITIVE(widget) ((widget)->type == GFXW_RECT || (widget)->type == GFXW_LINE || (widget->type == GFXW_INVERSE_LINE))
+#define GFXW_IS_PRIMITIVE(widget) ((widget)->type == GFXW_RECT || (widget)->type == GFXW_LINE)
 struct gfxw_primitive_t : public gfxw_widget_t {
 	gfx_color_t color;
 	gfx_line_mode_t line_mode;

Modified: scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-19 19:42:22 UTC (rev 39533)
+++ scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-19 19:52:05 UTC (rev 39534)
@@ -411,7 +411,11 @@
 	if (box->shade_type != GFX_BOX_SHADE_FLAT && box->color2.alpha)
 		return 0;
 
-	if (!toCommonRect(box->bounds).contains(toCommonRect(other->bounds)))
+	// Note: the check for box->bounds and other->bounds is NOT the same as contains()
+	// in Common::Rect (this one includes equality too)
+	if (!(box->bounds.x <= other->bounds.x && box->bounds.y <= other->bounds.y &&
+		  box->bounds.x + box->bounds.width >= other->bounds.x + other->bounds.width && 
+		  box->bounds.y + box->bounds.height >= other->bounds.y + other->bounds.height))
 		return 0;
 
 	return 1;
@@ -491,12 +495,6 @@
 
 	oprim = (gfxw_primitive_t *) other;
 
-	// FIXME: I'm not even sure why this happens...
-	if (wprim->bounds.height < 0 || oprim->bounds.height < 0) {
-		warning("_gfxwop_primitive_equals: height < 0");
-		return 0;
-	}
-
 	if (!toCommonRect(wprim->bounds).equals(toCommonRect(oprim->bounds)))
 		return 0;
 
@@ -553,12 +551,7 @@
 	linepos.width--;
 	linepos.height--;
 
-	if (widget->type == GFXW_INVERSE_LINE) {
-		linepos.x += linepos.width;
-		linepos.width = -linepos.width;
-	} else {
-		DRAW_ASSERT(widget, GFXW_LINE);
-	}
+	DRAW_ASSERT(widget, GFXW_LINE);
 
 	_split_rect(_move_rect(linepos, pos), &p1, &p2);
 	GFX_ASSERT(gfxop_draw_line(line->visual->gfx_state, p1, p2, line->color, line->line_mode, line->line_style));
@@ -567,10 +560,6 @@
 
 static int _gfxwop_line_print(gfxw_widget_t *widget, int indentation) {
 	_gfxw_print_widget(widget, indentation);
-	if (widget->type == GFXW_INVERSE_LINE)
-		sciprintf("INVERSE-LINE");
-	else
-		sciprintf("LINE");
 
 	return 0;
 }
@@ -582,28 +571,20 @@
 
 gfxw_primitive_t *gfxw_new_line(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) {
 	gfxw_primitive_t *prim;
-	// Encode into internal representation
-	rect_t line = gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y);
 
-	byte inverse = 0;
-
-	if (line.width < 0) {
-		line.x += line.width;
-		line.y += line.height;
-		line.width = -line.width;
-		line.height = -line.height;
+	// SCI can draw lines inversely. We convert inverse lines to normal ones here, because the resulting rectangles are invalid
+	if (end.x < start.x || end.y < start.y) {
+		SWAP(start.x, end.x);
+		SWAP(start.y, end.y);
 	}
 
-	if (line.height < 0) {
-		inverse = 1;
-		line.x += line.width;
-		line.width = -line.width;
-	}
+	// Encode into internal representation
+	rect_t line = gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y);
 
 	line.width++;
 	line.height++;
 
-	prim = _gfxw_new_primitive(line, color, line_mode, line_style, inverse ? GFXW_INVERSE_LINE : GFXW_LINE);
+	prim = _gfxw_new_primitive(line, color, line_mode, line_style, GFXW_LINE);
 
 	_gfxw_set_ops_LINE(GFXW(prim));
 
@@ -1976,15 +1957,14 @@
 	if (!GFXW_IS_CONTAINER(widget) && widget->parent) {
 		bounds.x += widget->parent->bounds.x;
 		bounds.y += widget->parent->bounds.y;
-		// FIXME: I'm not even sure why this happens...
-		if (bounds.height < 0) {
-			warning("gfxw_widget_matches_snapshot: height < 0");
-			return 0;
-		}
 	}
 
+	// Note: the check for snapshot->area and bounds is NOT the same as contains() in Common::Rect
+	// (this one includes equality too)
 	return ((widget->serial >= free_above_eq || widget->serial < free_below) && 
-		toCommonRect(snapshot->area).contains(toCommonRect(bounds)));
+			(snapshot->area.x <= bounds.x && snapshot->area.y <= bounds.y &&
+			 snapshot->area.x + snapshot->area.width >= bounds.x + bounds.width && 
+			 snapshot->area.y + snapshot->area.height >= bounds.y + bounds.height));
 }
 
 #define MAGIC_FREE_NUMBER -42
@@ -2118,9 +2098,8 @@
 		bounds = widget->bounds;
 		origin.x = seeker->parent->zone.x;
 		origin.y = seeker->parent->zone.y;
-		Common::Rect tmp = toCommonRect(bounds);
-		tmp.translate(origin.x, origin.y);
-		bounds = toSCIRect(tmp);
+		bounds.x += origin.x;
+		bounds.y += origin.y;
 
 		if (gfx_rects_overlap(bounds, seeker->bounds))
 			return seeker;
@@ -2148,9 +2127,8 @@
 		gfxw_remove_widget_from_container(GFXWC(chrono->parent), GFXW(chrono));
 		gfxw_annihilate(GFXW(chrono));
 
-		Common::Rect tmp = toCommonRect(tw->zone);
-		tmp.translate(origin.x, origin.y);
-		tw->zone = toSCIRect(tmp);
+		tw->zone.x += origin.x;
+		tw->zone.y += origin.y;
 
 		target->add(GFXWC(target), GFXW(tw));
 	}

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-19 19:42:22 UTC (rev 39533)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-19 19:52:05 UTC (rev 39534)
@@ -335,8 +335,8 @@
 
 	case GFXOP_DIRTY_FRAMES_ONE:
 		if (base) {
-			Common::Rect tmp = toCommonRect(box);
-			tmp.extend(toCommonRect(base->rect));
+			Common::Rect tmp = toCommonRect(base->rect);
+			tmp.extend(toCommonRect(box));
 			base->rect = toSCIRect(tmp);
 		} else {
 			base = _rect_create(box);
@@ -349,8 +349,8 @@
 		while (*rectp) {
 			if (gfx_rects_overlap((*rectp)->rect, box)) {
 				gfx_dirty_rect_t *next = (*rectp)->next;
-				Common::Rect tmp = toCommonRect((*rectp)->rect);
-				tmp.extend(toCommonRect(box));
+				Common::Rect tmp = toCommonRect(box);
+				tmp.extend(toCommonRect((*rectp)->rect));
 				box = toSCIRect(tmp);
 
 				free(*rectp);


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