diff options
author | Filippos Karapetis | 2009-09-30 08:23:12 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-09-30 08:23:12 +0000 |
commit | 4477f419034b7c606aef7eb7038337b7229cec33 (patch) | |
tree | 7c0b53d4ecf9aa6ea6a578fc7903ef8766f3d3aa | |
parent | eb5beef6a1f5a76735b35fb17796420ba2e6d080 (diff) | |
download | scummvm-rg350-4477f419034b7c606aef7eb7038337b7229cec33.tar.gz scummvm-rg350-4477f419034b7c606aef7eb7038337b7229cec33.tar.bz2 scummvm-rg350-4477f419034b7c606aef7eb7038337b7229cec33.zip |
Converted _color_equals() into respective equality operators within the gfx_color_t structure
svn-id: r44477
-rw-r--r-- | engines/sci/gfx/gfx_system.h | 42 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 34 |
2 files changed, 38 insertions, 38 deletions
diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 35f5dbed27..0e474c8985 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -66,16 +66,6 @@ struct gfx_mode_t { }; - -/** Full color */ -struct gfx_color_t { - PaletteEntry visual; - uint8 alpha; /**< transparency = (1-opacity) */ - int8 priority, control; - byte mask; /**< see mask values below */ -}; - - // TODO: Replace rect_t by Common::Rect /** Rectangle description */ struct rect_t { @@ -259,6 +249,38 @@ enum gfx_rectangle_fill_t { /** @} */ +/** Full color */ +struct gfx_color_t { + PaletteEntry visual; + uint8 alpha; /**< transparency = (1-opacity) */ + int8 priority, control; + byte mask; /**< see mask values below */ + + bool operator==(const gfx_color_t &c) const { + if (mask != c.mask) + return false; + + if (mask & GFX_MASK_VISUAL) { + if (visual.r != c.visual.r || visual.g != c.visual.g || visual.b != c.visual.b || alpha != c.alpha) + return false; + } + + if (mask & GFX_MASK_PRIORITY) + if (priority != c.priority) + return false; + + if (mask & GFX_MASK_CONTROL) + if (control != c.control) + return false; + + return true; + } + + bool operator!=(const gfx_color_t &c) const { + return !(*this == c); + } +}; + } // End of namespace Sci #endif // SCI_GFX_GFX_SYSTEM diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 1d737e9eb2..b208eee4b6 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -192,28 +192,6 @@ static int verify_widget(GfxWidget *widget) { return 1; \ } - -// TODO: Turn this into an operator== -static int _color_equals(gfx_color_t a, gfx_color_t b) { - if (a.mask != b.mask) - return 0; - - if (a.mask & GFX_MASK_VISUAL) { - if (a.visual.r != b.visual.r || a.visual.g != b.visual.g || a.visual.b != b.visual.b || a.alpha != b.alpha) - return 0; - } - - if (a.mask & GFX_MASK_PRIORITY) - if (a.priority != b.priority) - return 0; - - if (a.mask & GFX_MASK_CONTROL) - if (a.control != b.control) - return 0; - - return 1; -} - int GfxWidget::setVisual(GfxVisual *visual) { _visual = visual; @@ -361,14 +339,14 @@ static int _gfxwop_box_equals(GfxWidget *widget, GfxWidget *other) { if (!toCommonRect(wbox->_bounds).equals(toCommonRect(obox->_bounds))) return 0; - if (!_color_equals(wbox->_color1, obox->_color1)) + if (wbox->_color1 != obox->_color1) return 0; if (wbox->_shadeType != obox->_shadeType) return 0; if (wbox->_shadeType != GFX_BOX_SHADE_FLAT - && _color_equals(wbox->_color2, obox->_color2)) + && wbox->_color2 == obox->_color2) return 0; return 1; @@ -438,7 +416,7 @@ static int _gfxwop_primitive_equals(GfxWidget *widget, GfxWidget *other) { wprim->_bounds.width != oprim->_bounds.width || wprim->_bounds.height != oprim->_bounds.height) return 0; - if (!_color_equals(wprim->_color, oprim->_color)) + if (wprim->_color != oprim->_color) return 0; if (wprim->_lineMode != oprim->_lineMode) @@ -685,7 +663,7 @@ static int _gfxwop_dyn_view_equals(GfxWidget *widget, GfxWidget *other) { if (wview->_view != oview->_view || wview->_loop != oview->_loop || wview->_cel != oview->_cel) return 0; - if (!_color_equals(wview->_color, oview->_color)) + if (wview->_color != oview->_color) return 0; if (wview->_flags != oview->_flags) @@ -840,8 +818,8 @@ static int _gfxwop_text_equals(GfxWidget *widget, GfxWidget *other) { if (wtext->_font != otext->_font) return 0; - /* if (!(_color_equals(wtext->_color1, otext->_color1) && _color_equals(wtext->_color2, otext->_color2) - && _color_equals(wtext->_bgcolor, otext->_bgcolor))) + /* if (!(wtext->_color1 == otext->_color1 && wtext->_color2 == otext->_color2 + && wtext->_bgcolor == otext->_bgcolor)) return 0; */ return 1; |