aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects
diff options
context:
space:
mode:
authorGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-25 20:49:39 +0000
committerGravatar tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-04-25 20:49:39 +0000
commit9ce767c41333682c858ff26e99be2b800a2ef2b0 (patch)
tree193a33198455b76e390b7ef15e4838db09cc636d /src/effects
parent1a32d4aed2534337556d452c545444551f0a780c (diff)
Fix to (two-point radial) gradient playback error in SkPictures that swapped
the X and Y coordinates of their centers. git-svn-id: http://skia.googlecode.com/svn/trunk@1179 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/SkGradientShader.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/effects/SkGradientShader.cpp b/src/effects/SkGradientShader.cpp
index 5af04862f2..6aff4fc406 100644
--- a/src/effects/SkGradientShader.cpp
+++ b/src/effects/SkGradientShader.cpp
@@ -50,6 +50,17 @@ static void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1,
#endif
///////////////////////////////////////////////////////////////////////////////
+// Can't use a two-argument function with side effects like this in a
+// constructor's initializer's argument list because the order of
+// evaluations in that context is undefined (and backwards on linux/gcc).
+static SkPoint unflatten_point(SkReader32& buffer) {
+ SkPoint retval;
+ retval.fX = buffer.readScalar();
+ retval.fY = buffer.readScalar();
+ return retval;
+}
+
+///////////////////////////////////////////////////////////////////////////////
typedef SkFixed (*TileProc)(SkFixed);
@@ -780,8 +791,8 @@ public:
protected:
Linear_Gradient(SkFlattenableReadBuffer& buffer)
: Gradient_Shader(buffer),
- fStart(SkPoint::Make(buffer.readScalar(), buffer.readScalar())),
- fEnd(SkPoint::Make(buffer.readScalar(), buffer.readScalar())) {
+ fStart(unflatten_point(buffer)),
+ fEnd(unflatten_point(buffer)) {
}
virtual Factory getFactory() { return CreateProc; }
@@ -1379,7 +1390,7 @@ public:
protected:
Radial_Gradient(SkFlattenableReadBuffer& buffer)
: Gradient_Shader(buffer),
- fCenter(SkPoint::Make(buffer.readScalar(), buffer.readScalar())),
+ fCenter(unflatten_point(buffer)),
fRadius(buffer.readScalar()) {
}
virtual Factory getFactory() { return CreateProc; }
@@ -1772,8 +1783,8 @@ public:
protected:
Two_Point_Radial_Gradient(SkFlattenableReadBuffer& buffer)
: Gradient_Shader(buffer),
- fCenter1(SkPoint::Make(buffer.readScalar(), buffer.readScalar())),
- fCenter2(SkPoint::Make(buffer.readScalar(), buffer.readScalar())),
+ fCenter1(unflatten_point(buffer)),
+ fCenter2(unflatten_point(buffer)),
fRadius1(buffer.readScalar()),
fRadius2(buffer.readScalar()) {
init();
@@ -1857,7 +1868,7 @@ public:
protected:
Sweep_Gradient(SkFlattenableReadBuffer& buffer)
: Gradient_Shader(buffer),
- fCenter(SkPoint::Make(buffer.readScalar(), buffer.readScalar())) {
+ fCenter(unflatten_point(buffer)) {
}
virtual Factory getFactory() { return CreateProc; }
@@ -2256,4 +2267,3 @@ static SkFlattenable::Registrar gRadialGradientReg("Radial_Gradient",
static SkFlattenable::Registrar gSweepGradientReg("Sweep_Gradient",
Sweep_Gradient::CreateProc);
-