Skip to content
  • Tor Arne Vestbø's avatar
    Restore smooth-scaled drawing of 0.5x-2.0x scaled glyphs in the GL engine · df1e835f
    Tor Arne Vestbø authored
    Commit b5922c89 (Add support for retina glyph-based text drawing
    in the GL engine), and commit 155a2062 (Use QPaintEngineEx to decide
    if font is too big for using the glyph cache) together changed the
    behavior of drawing scaled cached glyphs in the GL engine, producing
    blocky text drawing when using the FreeType font engine.
    
    Whereas before we would cache all glyphs without any transform, and
    let the paint engine take care of the transform, commit b5922c added
    support for a scaled GL glyph cache, resulting in a 2x cache, drawn
    at 1x for example. The problem was that the FreeType engine claimed
    to support producing glyphs at 2x, but did that using the QFontEngine
    baseclass implementations, which use a simple fast-transform to scale
    up the glyphs. The result was a 2x cache with horrible looking glyphs.
    
    The first step in fixing this issue was to have the FreeType engine
    claim to only support translations. This would then make the paint
    engine choose path-based drawing for all scaled text, which is slow.
    
    To restore the optimization that we would draw 0.5x-2.0x scaled text
    using a smooth-scale in the GL engine (which was removed in 155a2062
    
    ),
    we then needed to extend shouldDrawCachedGlyphs() and add a special
    condition for this, coupled with a bit of logic in drawCachedGlyphs()
    that ensures we don't propagate the painter scale to the glyph cache
    if the engine is not able to produce scaled glyphs for it. This
    means we get the old behavior of the GL engine doing a smooth scale
    of the 1x glyph in the cache.
    
    Finally, since the raster engine also checks if the font engine
    supports the current transform, but for FreeType then ends up in
    a separate code path when actually drawing the glyphs (as the
    FreeType font engine supports internal glyph caching), we need
    to add a corresponding check for hasInternalCaching() in the
    shouldDrawCachedGlyphs() function, now that the FreeType engine
    only reports that it supports translations.
    
    Change-Id: Id03de896dec5f29535b281fb235332ef018045d8
    Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
    df1e835f