Bug 892968. Implement POINT filtering properly in DrawTargetCG. r=mattwoodrow
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 12 Jul 2013 10:01:58 -0400
changeset 138403 69fa298ab6d26a37e0a49ed49afc812c9455a961
parent 138402 c9c559b68ead9c263d9abd4041635d55a8d08209
child 138404 92fa0b21fbb8f977f1d4e6f35cb706a80557e451
push id30957
push userjmuizelaar@mozilla.com
push dateFri, 12 Jul 2013 21:39:19 +0000
treeherdermozilla-inbound@69fa298ab6d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs892968
milestone25.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 892968. Implement POINT filtering properly in DrawTargetCG. r=mattwoodrow
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -282,19 +282,20 @@ DrawTargetCG::DrawSurface(SourceSurface 
     image = subimage;
   }
 
   CGContextScaleCTM(cg, 1, -1);
 
   CGRect flippedRect = CGRectMake(aDest.x, -(aDest.y + aDest.height),
                                   aDest.width, aDest.height);
 
-  //XXX: we should implement this for patterns too
   if (aSurfOptions.mFilter == FILTER_POINT)
     CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
+  else
+    CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
 
   CGContextDrawImage(cg, flippedRect, image);
 
   fixer.Fix(mCg);
 
   CGContextRestoreGState(mCg);
 
   CGImageRelease(subimage);
@@ -478,16 +479,21 @@ SetFillFromPattern(CGContextRef cg, CGCo
   } else if (aPattern.GetType() == PATTERN_SURFACE) {
 
     CGColorSpaceRef patternSpace;
     patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetFillColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
+    const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
+    if (pat.mFilter == FILTER_POINT)
+      CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
+    else
+      CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
     CGFloat alpha = 1.;
     CGContextSetFillPattern(cg, pattern, &alpha);
     CGPatternRelease(pattern);
   }
 }
 
 static void
 SetStrokeFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &aPattern)
@@ -501,16 +507,21 @@ SetStrokeFromPattern(CGContextRef cg, CG
     CGColorRelease(cgcolor);
   } else if (aPattern.GetType() == PATTERN_SURFACE) {
     CGColorSpaceRef patternSpace;
     patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetStrokeColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
+    const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
+    if (pat.mFilter == FILTER_POINT)
+      CGContextSetInterpolationQuality(cg, kCGInterpolationNone);
+    else
+      CGContextSetInterpolationQuality(cg, kCGInterpolationLow);
     CGFloat alpha = 1.;
     CGContextSetStrokePattern(cg, pattern, &alpha);
     CGPatternRelease(pattern);
   }
 
 }
 
 void