aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-02-08 20:29:19 +0000
committerJohannes Schickel2010-02-08 20:29:19 +0000
commit17fef2950718cc38fb7f7bfc1f634ed1b7491eaf (patch)
tree9f632be1d6453cc103b72dd6a59257bf7764efef
parentc2932942c80b668fe89aec4c1dcb3da3c668b45c (diff)
downloadscummvm-rg350-17fef2950718cc38fb7f7bfc1f634ed1b7491eaf.tar.gz
scummvm-rg350-17fef2950718cc38fb7f7bfc1f634ed1b7491eaf.tar.bz2
scummvm-rg350-17fef2950718cc38fb7f7bfc1f634ed1b7491eaf.zip
Get rid of the workaround for a g++ (code generation) bug on AMD64, by passing a reference of a Color instance to saturatedAddColor instead of a value.
svn-id: r48006
-rw-r--r--engines/cine/pal.cpp21
-rw-r--r--engines/cine/pal.h2
2 files changed, 4 insertions, 19 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index ca436dc060..460c3431d3 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -227,23 +227,8 @@ Palette &Palette::saturatedAddColor(Palette &output, byte firstIndex, byte lastI
assert(firstIndex < output.colorCount() && lastIndex < output.colorCount());
assert(output.colorFormat() == colorFormat());
- for (uint i = firstIndex; i <= lastIndex; i++) {
- // WORKAROUND for a valgrind warning on AMD64:
- //
- // The old code read: "output._colors[i] = saturatedAddColor(_colors[i], r, g, b);".
- //
- // It seems g++ 4.1.2, 4.3.4 and 4.4.1 do a 8 byte read when passing _colors[i] as parameter,
- // even though the struct is only 3 bytes, resulting in an invalid read, when accessing indices
- // 14 and 15 of 16 color palettes.
- //
- // To work around this issue, we added an temporary variable, which will have padding, so
- // the 8 byte read (which is done when passing src) is assured to be in a valid memory area.
- //
- // For more information about this gcc specific problem, you can read up on the following bug
- // report: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36043
- const Color src = _colors[i];
- saturatedAddColor(output._colors[i], src, r, g, b);
- }
+ for (uint i = firstIndex; i <= lastIndex; i++)
+ saturatedAddColor(output._colors[i], _colors[i], r, g, b);
return output;
}
@@ -267,7 +252,7 @@ Palette &Palette::saturatedAddNormalizedGray(Palette &output, byte firstIndex, b
}
// a.k.a. transformColor
-void Palette::saturatedAddColor(Color &result, Color baseColor, signed r, signed g, signed b) const {
+void Palette::saturatedAddColor(Color &result, const Color &baseColor, signed r, signed g, signed b) const {
result.r = CLIP<int>(baseColor.r + r, 0, _format.rMax());
result.g = CLIP<int>(baseColor.g + g, 0, _format.gMax());
result.b = CLIP<int>(baseColor.b + b, 0, _format.bMax());
diff --git a/engines/cine/pal.h b/engines/cine/pal.h
index c8c1ad62a5..bbfaf54ab2 100644
--- a/engines/cine/pal.h
+++ b/engines/cine/pal.h
@@ -191,7 +191,7 @@ private:
// This is needed because when using a Color as return value, this would crash Chrilith's
// compiler for PalmOS.
// TODO: Add more information about the compiler.
- void saturatedAddColor(Color &result, Color baseColor, signed r, signed g, signed b) const;
+ void saturatedAddColor(Color &result, const Color &baseColor, signed r, signed g, signed b) const;
private:
Graphics::PixelFormat _format; ///< The used source color format