Bug 752341. Avoid using CGContextSetTextMatrix. r=bgirard a=akeybl
authorBenoit Girard <b56girard@gmail.com>
Tue, 22 May 2012 20:36:25 -0400
changeset 92235 491fd5c11f42b549209f2f0a65505e66015510f5
parent 92234 a1ff8cc41063d415f372a56542c6c3e793e19a45
child 92236 5de6e4bd8ede3334849160998a3bb2744b5845bd
child 92238 b20dd59c39df7830824e2c60fc53af1d43d481bf
push id863
push userb56girard@gmail.com
push dateWed, 23 May 2012 00:37:02 +0000
treeherdermozilla-beta@491fd5c11f42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard, akeybl
bugs752341
milestone13.0
Bug 752341. Avoid using CGContextSetTextMatrix. r=bgirard a=akeybl CGContextSetTextMatrix has behaviour that depends on the text drawing mode. We want consistency so avoid CGContextSetTextMatrix.
gfx/2d/DrawTargetCG.cpp
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -718,24 +718,22 @@ DrawTargetCG::FillGlyphs(ScaledFont *aFo
   CGContextSetFontSize(cg, cgFont->mSize);
 
   //XXX: we should use a stack vector here when we have a class like that
   std::vector<CGGlyph> glyphs;
   std::vector<CGPoint> positions;
   glyphs.resize(aBuffer.mNumGlyphs);
   positions.resize(aBuffer.mNumGlyphs);
 
-  CGFloat xprev = aBuffer.mGlyphs[0].mPosition.x;
-  CGFloat yprev = aBuffer.mGlyphs[0].mPosition.y;
-  CGContextSetTextPosition(cg, xprev, yprev);
-
   // Handle the flip
-  CGAffineTransform matrix = CGAffineTransformMakeScale(1, -1);//CGAffineTransformMake(1, 0, 0, -1, 0, -mSize.height);
-  // "Note that the text matrix is not a part of the graphics state"
-  CGContextSetTextMatrix(cg, matrix);
+  CGAffineTransform matrix = CGAffineTransformMakeScale(1, -1);
+  CGContextConcatCTM(cg, matrix);
+  // CGContextSetTextMatrix works differently with kCGTextClip && kCGTextFill
+  // It seems that it transforms the positions with TextFill and not with TextClip
+  // Therefore we'll avoid it.
 
   for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
     glyphs[i] = aBuffer.mGlyphs[i].mIndex;
     // XXX: CGPointMake might not be inlined
     positions[i] = CGPointMake(aBuffer.mGlyphs[i].mPosition.x,
                               -aBuffer.mGlyphs[i].mPosition.y);
   }