Bug 795538 - Ensure we use the correct colour (and alpha) for the clamp values r=mattwoodrow
authorGeorge Wright <gw@gwright.org.uk>
Fri, 28 Sep 2012 21:25:24 -0400
changeset 108594 bed646e2b0f5b298b93a9477cf48a62ebe1c93d9
parent 108593 4a4733ddb26e28f88011ffbe61bacdf38b70ac5f
child 108595 d0194ff64049e5add5e94a910a8ef411b43d2bf4
push id23568
push userryanvm@gmail.com
push dateSat, 29 Sep 2012 16:32:00 +0000
treeherdermozilla-central@879cce846c1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs795538
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 795538 - Ensure we use the correct colour (and alpha) for the clamp values r=mattwoodrow
gfx/skia/src/effects/gradients/SkGradientShader.cpp
--- a/gfx/skia/src/effects/gradients/SkGradientShader.cpp
+++ b/gfx/skia/src/effects/gradients/SkGradientShader.cpp
@@ -468,25 +468,27 @@ const SkPMColor* SkGradientShaderBase::g
             fCache32PixelRef->unref();
             fCache32PixelRef = newPR;
             fCache32 = (SkPMColor*)newPR->getAddr() + 1;
         }
         complete_32bit_cache(fCache32, kCache32Count);
     }
 
     // Write the clamp colours into the first and last entries of fCache32
-    fCache32[kCache32ClampLower] = SkPackARGB32(fCacheAlpha,
-                                                SkColorGetR(fOrigColors[0]),
-                                                SkColorGetG(fOrigColors[0]),
-                                                SkColorGetB(fOrigColors[0]));
+    fCache32[kCache32ClampLower] = SkPremultiplyARGBInline(SkMulDiv255Round(SkColorGetA(fOrigColors[0]),
+                                                                            fCacheAlpha),
+                                                           SkColorGetR(fOrigColors[0]),
+                                                           SkColorGetG(fOrigColors[0]),
+                                                           SkColorGetB(fOrigColors[0]));
 
-    fCache32[kCache32ClampUpper] = SkPackARGB32(fCacheAlpha,
-                                                SkColorGetR(fOrigColors[fColorCount - 1]),
-                                                SkColorGetG(fOrigColors[fColorCount - 1]),
-                                                SkColorGetB(fOrigColors[fColorCount - 1]));
+    fCache32[kCache32ClampUpper] = SkPremultiplyARGBInline(SkMulDiv255Round(SkColorGetA(fOrigColors[fColorCount - 1]),
+                                                                            fCacheAlpha),
+                                                           SkColorGetR(fOrigColors[fColorCount - 1]),
+                                                           SkColorGetG(fOrigColors[fColorCount - 1]),
+                                                           SkColorGetB(fOrigColors[fColorCount - 1]));
 
     return fCache32;
 }
 
 /*
  *  Because our caller might rebuild the same (logically the same) gradient
  *  over and over, we'd like to return exactly the same "bitmap" if possible,
  *  allowing the client to utilize a cache of our bitmap (e.g. with a GPU).