Bug 453726 - thebes does an unnecessary float->byte->float conversion on the alpha channel when color management is turned on. r=vlad
authorBobby Holley <bholley@mozilla.com>
Mon, 08 Sep 2008 14:41:26 -0700
changeset 19002 7068d034c12b2c2c5df8c3bc3c0d2d10f80b3e1e
parent 19001 007c88ff0d12b5638caab60df2e4777afb399093
child 19003 4b2977a03aba9d9ca4b719cdc7f95c9441a7da6f
push idunknown
push userunknown
push dateunknown
reviewersvlad
bugs453726
milestone1.9.1b1pre
Bug 453726 - thebes does an unnecessary float->byte->float conversion on the alpha channel when color management is turned on. r=vlad
gfx/thebes/src/gfxContext.cpp
gfx/thebes/src/gfxPattern.cpp
--- a/gfx/thebes/src/gfxContext.cpp
+++ b/gfx/thebes/src/gfxContext.cpp
@@ -632,17 +632,19 @@ gfxContext::SetColor(const gfxRGBA& c)
             gfxRGBA cms(packed, gfxRGBA::PACKED_ABGR);
 #else
             PRUint32 packed = c.Packed(gfxRGBA::PACKED_ARGB);
             cmsDoTransform(transform,
                            (PRUint8 *)&packed + 1, (PRUint8 *)&packed + 1,
                            1);
             gfxRGBA cms(packed, gfxRGBA::PACKED_ARGB);
 #endif
-            cairo_set_source_rgba(mCairo, cms.r, cms.g, cms.b, cms.a);
+            // Use the original alpha to avoid unnecessary float->byte->float
+            // conversion errors
+            cairo_set_source_rgba(mCairo, cms.r, cms.g, cms.b, c.a);
             return;
         }
     }
 
     cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
 }
 
 void
--- a/gfx/thebes/src/gfxPattern.cpp
+++ b/gfx/thebes/src/gfxPattern.cpp
@@ -98,18 +98,20 @@ gfxPattern::AddColorStop(gfxFloat offset
             gfxRGBA cms(packed, gfxRGBA::PACKED_ABGR);
 #else
             PRUint32 packed = c.Packed(gfxRGBA::PACKED_ARGB);
             cmsDoTransform(transform,
                            (PRUint8 *)&packed + 1, (PRUint8 *)&packed + 1,
                            1);
             gfxRGBA cms(packed, gfxRGBA::PACKED_ARGB);
 #endif
+            // Use the original alpha to avoid unnecessary float->byte->float
+            // conversion errors
             cairo_pattern_add_color_stop_rgba(mPattern, offset,
-                                              cms.r, cms.g, cms.b, cms.a);
+                                              cms.r, cms.g, cms.b, c.a);
             return;
         }
     }
     cairo_pattern_add_color_stop_rgba(mPattern, offset, c.r, c.g, c.b, c.a);
 }
 
 void
 gfxPattern::SetMatrix(const gfxMatrix& matrix)