Merge mozilla-central and mozilla-inbound
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 12 Sep 2011 09:54:28 -0400
changeset 76887 e85c4dc116c5875f4ad6f62cf0a111dd5b656501
parent 76884 b991feb93d32ea9c9d8a6b711125d185ce9f6ca3 (current diff)
parent 76886 91906f4106817c721391921e60a591ff49788921 (diff)
child 76888 01a9f0ee22348ecf195f50d74a6edfcbd18b1c67
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
milestone9.0a1
Merge mozilla-central and mozilla-inbound
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -1106,20 +1106,20 @@ struct GlyphBuffer {
         : mNumGlyphs(0) { }
 
     cairo_glyph_t *AppendGlyph() {
         return &mGlyphBuffer[mNumGlyphs++];
     }
 
     void Flush(cairo_t *aCR, PRBool aDrawToPath, PRBool aReverse,
                PRBool aFinish = PR_FALSE) {
-        // Ensure there's enough room for at least two glyphs in the
-        // buffer (because we may allocate two glyphs between flushes)
-        if (!aFinish && mNumGlyphs + 2 <= GLYPH_BUFFER_SIZE)
+        // Ensure there's enough room for a glyph to be added to the buffer
+        if (!aFinish && mNumGlyphs < GLYPH_BUFFER_SIZE) {
             return;
+        }
 
         if (aReverse) {
             for (PRUint32 i = 0; i < mNumGlyphs/2; ++i) {
                 cairo_glyph_t tmp = mGlyphBuffer[i];
                 mGlyphBuffer[i] = mGlyphBuffer[mNumGlyphs - 1 - i];
                 mGlyphBuffer[mNumGlyphs - 1 - i] = tmp;
             }
         }
@@ -1217,35 +1217,35 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUi
                 x -= advance;
                 glyphX = x;
             } else {
                 glyphX = x;
                 x += advance;
             }
             glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
             glyph->y = ToDeviceUnits(y, devUnitsPerAppUnit);
+            glyphs.Flush(cr, aDrawToPath, isRTL);
             
             // synthetic bolding by multi-striking with 1-pixel offsets
             // at least once, more if there's room (large font sizes)
             if (IsSyntheticBold()) {
                 double strikeOffset = synBoldOnePixelOffset;
                 PRInt32 strikeCount = strikes;
                 do {
                     cairo_glyph_t *doubleglyph;
                     doubleglyph = glyphs.AppendGlyph();
                     doubleglyph->index = glyph->index;
                     doubleglyph->x =
                         ToDeviceUnits(glyphX + strikeOffset * appUnitsPerDevUnit,
                                       devUnitsPerAppUnit);
                     doubleglyph->y = glyph->y;
                     strikeOffset += synBoldOnePixelOffset;
+                    glyphs.Flush(cr, aDrawToPath, isRTL);
                 } while (--strikeCount > 0);
             }
-            
-            glyphs.Flush(cr, aDrawToPath, isRTL);
         } else {
             PRUint32 glyphCount = glyphData->GetGlyphCount();
             if (glyphCount > 0) {
                 const gfxTextRun::DetailedGlyph *details =
                     aTextRun->GetDetailedGlyphs(i);
                 NS_ASSERTION(details, "detailedGlyph should not be missing!");
                 for (PRUint32 j = 0; j < glyphCount; ++j, ++details) {
                     double advance = details->mAdvance;
@@ -1270,34 +1270,34 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUi
                         glyph = glyphs.AppendGlyph();
                         glyph->index = details->mGlyphID;
                         double glyphX = x + details->mXOffset;
                         if (isRTL) {
                             glyphX -= advance;
                         }
                         glyph->x = ToDeviceUnits(glyphX, devUnitsPerAppUnit);
                         glyph->y = ToDeviceUnits(y + details->mYOffset, devUnitsPerAppUnit);
+                        glyphs.Flush(cr, aDrawToPath, isRTL);
 
                         if (IsSyntheticBold()) {
                             double strikeOffset = synBoldOnePixelOffset;
                             PRInt32 strikeCount = strikes;
                             do {
                                 cairo_glyph_t *doubleglyph;
                                 doubleglyph = glyphs.AppendGlyph();
                                 doubleglyph->index = glyph->index;
                                 doubleglyph->x =
                                     ToDeviceUnits(glyphX + strikeOffset *
                                                       appUnitsPerDevUnit,
                                                   devUnitsPerAppUnit);
                                 doubleglyph->y = glyph->y;
                                 strikeOffset += synBoldOnePixelOffset;
+                                glyphs.Flush(cr, aDrawToPath, isRTL);
                             } while (--strikeCount > 0);
                         }
-
-                        glyphs.Flush(cr, aDrawToPath, isRTL);
                     }
                     x += direction*advance;
                 }
             }
         }
 
         if (aSpacing) {
             double space = aSpacing[i - aStart].mAfter;