Bug 1342571 - Fix MaxStrokeExtents to account for partial pixel coverage properly. r=mstange, a=lizzard
authorLee Salzman <lsalzman@mozilla.com>
Tue, 28 Feb 2017 15:48:04 -0500
changeset 378874 dd529ec5fef6cf0f1db2db40e316467d54a04361
parent 378873 2dcb9a997569874e25637c8d80c4749173e8d1f9
child 378875 ff92ddc470715eeb1952b4ef7242f85c9836dcc0
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1342571
milestone53.0a2
Bug 1342571 - Fix MaxStrokeExtents to account for partial pixel coverage properly. r=mstange, a=lizzard MozReview-Commit-ID: DS25AJKoVYo
gfx/2d/DrawCommand.h
gfx/2d/PathHelpers.cpp
--- a/gfx/2d/DrawCommand.h
+++ b/gfx/2d/DrawCommand.h
@@ -367,16 +367,21 @@ PathExtentsToMaxStrokeExtents(const Stro
     styleExpansionFactor = M_SQRT2 * aStrokeOptions.mMiterLimit;
   }
 
   styleExpansionFactor *= aStrokeOptions.mLineWidth;
 
   double dx = styleExpansionFactor * hypot(aTransform._11, aTransform._21);
   double dy = styleExpansionFactor * hypot(aTransform._22, aTransform._12);
 
+  // Even if the stroke only partially covers a pixel, it must still render to
+  // full pixels. Round up to compensate for this.
+  dx = ceil(dx);
+  dy = ceil(dy);
+
   Rect result = aRect;
   result.Inflate(dx, dy);
   return result;
 }
 
 class StrokeCommand : public DrawingCommand
 {
 public:
--- a/gfx/2d/PathHelpers.cpp
+++ b/gfx/2d/PathHelpers.cpp
@@ -265,13 +265,19 @@ MaxStrokeExtents(const StrokeOptions& aS
       styleExpansionFactor < M_SQRT2 * aStrokeOptions.mMiterLimit) {
     styleExpansionFactor = M_SQRT2 * aStrokeOptions.mMiterLimit;
   }
 
   styleExpansionFactor *= aStrokeOptions.mLineWidth;
 
   double dx = styleExpansionFactor * hypot(aTransform._11, aTransform._21);
   double dy = styleExpansionFactor * hypot(aTransform._22, aTransform._12);
+
+  // Even if the stroke only partially covers a pixel, it must still render to
+  // full pixels. Round up to compensate for this.
+  dx = ceil(dx);
+  dy = ceil(dy);
+
   return Margin(dy, dx, dy, dx);
 }
 
 } // namespace gfx
 } // namespace mozilla