From 77218177d44bb120e4cb558cadeadc0bcf6c3cab Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 13 Oct 2010 18:43:23 +0200 Subject: Fix fontconfig pattern merging When merging fontconfig patterns, we need to clean up existing object first, otherwise the added object will be appended instead of replacing the existing object. When multiple font engines are using shaping, if fontconfig patterns are not correctly merged, it will result using the old font. For instance, in "Fake Bold Normal", "Normal" text will continue using the font for "Fake Bold" (that only happen with fallback fonts). Task-number: QTBUG-14455 Reviewed-by: Eskil --- src/gui/text/qfontdatabase_x11.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index ecc4690..635d2cf 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1455,6 +1455,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD weight_value = FC_WEIGHT_DEMIBOLD; else if (request.weight < (QFont::Bold + QFont::Black) / 2) weight_value = FC_WEIGHT_BOLD; + FcPatternDel(pattern, FC_WEIGHT); FcPatternAddInteger(pattern, FC_WEIGHT, weight_value); int slant_value = FC_SLANT_ROMAN; @@ -1462,20 +1463,25 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD slant_value = FC_SLANT_ITALIC; else if (request.style == QFont::StyleOblique) slant_value = FC_SLANT_OBLIQUE; + FcPatternDel(pattern, FC_SLANT); FcPatternAddInteger(pattern, FC_SLANT, slant_value); double size_value = qMax(qreal(1.), request.pixelSize); + FcPatternDel(pattern, FC_PIXEL_SIZE); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); int stretch = request.stretch; if (!stretch) stretch = 100; + FcPatternDel(pattern, FC_WIDTH); FcPatternAddInteger(pattern, FC_WIDTH, stretch); if (X11->display && QX11Info::appDepth(screen) <= 8) { + FcPatternDel(pattern, FC_ANTIALIAS); // can't do antialiasing on 8bpp FcPatternAddBool(pattern, FC_ANTIALIAS, false); } else if (request.styleStrategy & (QFont::PreferAntialias|QFont::NoAntialias)) { + FcPatternDel(pattern, FC_ANTIALIAS); FcPatternAddBool(pattern, FC_ANTIALIAS, !(request.styleStrategy & QFont::NoAntialias)); } @@ -1484,6 +1490,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD Q_ASSERT(script < QUnicodeTables::ScriptCount); FcLangSet *ls = FcLangSetCreate(); FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]); + FcPatternDel(pattern, FC_LANG); FcPatternAddLangSet(pattern, FC_LANG, ls); FcLangSetDestroy(ls); } -- cgit v0.12 From 7eb560609cf1fc82f897a9a67c76e42b06823f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 18 Nov 2010 12:06:41 +0100 Subject: Some optimizations for the gray-raster (raster engine antialiasing). Increase the size of the initial memory pool (it's anyways free'd later on) to improve the performance of the rasterizer and also decrease the chance of re-allocations. Also, by combining gray_record_cell and gray_find_cell into one function, as gray_find_cell is only called from the former, we can skip some unnecessary operations. Measured performance improvements range from 58 % to 154 % for rounded rect filling and stroking. Reviewed-by: Andreas Kling --- src/gui/painting/qgrayraster.c | 35 ++++++++++++----------------------- src/gui/painting/qgrayraster_p.h | 2 +- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/gui/painting/qgrayraster.c b/src/gui/painting/qgrayraster.c index ec9ebeb..536f265 100644 --- a/src/gui/painting/qgrayraster.c +++ b/src/gui/painting/qgrayraster.c @@ -408,25 +408,31 @@ /* */ /* Record the current cell in the table. */ /* */ - static PCell - gray_find_cell( RAS_ARG ) + static void + gray_record_cell( RAS_ARG ) { PCell *pcell, cell; int x = ras.ex; + if ( ras.invalid || !( ras.area | ras.cover ) ) + return; if ( x > ras.max_ex ) x = ras.max_ex; pcell = &ras.ycells[ras.ey]; + for (;;) { cell = *pcell; if ( cell == NULL || cell->x > x ) break; - if ( cell->x == x ) - goto Exit; + if ( cell->x == x ) { + cell->area += ras.area; + cell->cover += ras.cover; + return; + } pcell = &cell->next; } @@ -436,28 +442,11 @@ cell = ras.cells + ras.num_cells++; cell->x = x; - cell->area = 0; - cell->cover = 0; + cell->area = ras.area; + cell->cover = ras.cover; cell->next = *pcell; *pcell = cell; - - Exit: - return cell; - } - - - static void - gray_record_cell( RAS_ARG ) - { - if ( !ras.invalid && ( ras.area | ras.cover ) ) - { - PCell cell = gray_find_cell( RAS_VAR ); - - - cell->area += ras.area; - cell->cover += ras.cover; - } } diff --git a/src/gui/painting/qgrayraster_p.h b/src/gui/painting/qgrayraster_p.h index ad595b8..d610a9a 100644 --- a/src/gui/painting/qgrayraster_p.h +++ b/src/gui/painting/qgrayraster_p.h @@ -91,7 +91,7 @@ /* Minimum buffer size for raster object, that accounts for TWorker and TCell sizes.*/ -#define MINIMUM_POOL_SIZE 4096 +#define MINIMUM_POOL_SIZE 8192 QT_FT_EXPORT_VAR( const QT_FT_Raster_Funcs ) qt_ft_grays_raster; -- cgit v0.12