src/gui/painting/qtextureglyphcache.cpp
changeset 29 b72c6db6890b
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
25:e24348a560a6 29:b72c6db6890b
    64     qDebug() << " -> current transformation: " << m_transform;
    64     qDebug() << " -> current transformation: " << m_transform;
    65 #endif
    65 #endif
    66 
    66 
    67     m_current_textitem = &ti;
    67     m_current_textitem = &ti;
    68     const int margin = glyphMargin();
    68     const int margin = glyphMargin();
       
    69     const int paddingDoubled = glyphPadding() * 2;
    69 
    70 
    70     QHash<glyph_t, Coord> listItemCoordinates;
    71     QHash<glyph_t, Coord> listItemCoordinates;
    71     int rowHeight = 0;
    72     int rowHeight = 0;
    72 
    73 
    73     // check each glyph for its metrics and get the required rowHeight.
    74     // check each glyph for its metrics and get the required rowHeight.
   112         rowHeight = qMax(rowHeight, glyph_height);
   113         rowHeight = qMax(rowHeight, glyph_height);
   113     }
   114     }
   114     if (listItemCoordinates.isEmpty())
   115     if (listItemCoordinates.isEmpty())
   115         return;
   116         return;
   116 
   117 
   117     rowHeight += margin * 2;
   118     rowHeight += margin * 2 + paddingDoubled;
   118     if (isNull())
   119     if (isNull())
   119         createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, rowHeight);
   120         createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, rowHeight);
   120 
   121 
   121     // now actually use the coords and paint the wanted glyps into cache.
   122     // now actually use the coords and paint the wanted glyps into cache.
   122     QHash<glyph_t, Coord>::iterator iter = listItemCoordinates.begin();
   123     QHash<glyph_t, Coord>::iterator iter = listItemCoordinates.begin();
   124         Coord c = iter.value();
   125         Coord c = iter.value();
   125 
   126 
   126         if (m_cx + c.w > m_w) {
   127         if (m_cx + c.w > m_w) {
   127             // no room on the current line, start new glyph strip
   128             // no room on the current line, start new glyph strip
   128             m_cx = 0;
   129             m_cx = 0;
   129             m_cy = m_h;
   130             m_cy = m_h + paddingDoubled;
   130         }
   131         }
   131         if (m_cy + c.h > m_h) {
   132         if (m_cy + c.h > m_h) {
   132             int new_height;
   133             int new_height;
   133             if (m_cx == 0) { // add a whole row
   134             if (m_cx == 0) { // add a whole row
   134                 new_height = m_h + rowHeight;
   135                 new_height = m_h + rowHeight;
   151             m_cx = 0;
   152             m_cx = 0;
   152             m_cy += rowHeight;
   153             m_cy += rowHeight;
   153         } else {
   154         } else {
   154             // for the Mono case, glyph_width is 8-bit aligned,
   155             // for the Mono case, glyph_width is 8-bit aligned,
   155             // and therefore so will m_cx
   156             // and therefore so will m_cx
   156             m_cx += c.w;
   157             m_cx += c.w + paddingDoubled;
   157         }
   158         }
   158         ++iter;
   159         ++iter;
   159     }
   160     }
   160 
   161 
   161 
   162