Bug 1342571 - fix MaxStrokeExtents to account for partial pixel coverage properly. r=mstange
authorLee Salzman <lsalzman@mozilla.com>
Tue, 28 Feb 2017 15:48:04 -0500
changeset 374295 1a8bcf69e88fb38e2bb18ffa1094997c5092fce6
parent 374294 129546a71da906cc26d19656128e0e2f45750e8b
child 374296 f29dad38621ed4462b4416ffa090d25e9c017cde
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1342571
milestone54.0a1
Bug 1342571 - fix MaxStrokeExtents to account for partial pixel coverage properly. r=mstange 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