Changeset 561 for trunk/src/gui/painting/qtextureglyphcache.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/painting/qtextureglyphcache.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 89 89 ti.descent.toReal()); 90 90 #endif 91 int glyph_width = metrics.width.ceil().toInt() + margin * 2;92 int glyph_height = metrics.height.ceil().toInt() + margin * 2;91 int glyph_width = metrics.width.ceil().toInt(); 92 int glyph_height = metrics.height.ceil().toInt(); 93 93 if (glyph_height == 0 || glyph_width == 0) 94 94 continue; 95 95 glyph_width += margin * 2 + 4; 96 glyph_height += margin * 2 + 4; 96 97 // align to 8-bit boundary 97 98 if (m_type == QFontEngineGlyphCache::Raster_Mono) … … 101 102 glyph_width, 102 103 glyph_height, // texture coords 103 metrics.x. truncate(),104 metrics.x.round().truncate(), 104 105 -metrics.y.truncate() }; // baseline for horizontal scripts 105 106 … … 155 156 156 157 158 } 159 160 QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const 161 { 162 #if defined(Q_WS_X11) 163 if (m_transform.type() > QTransform::TxTranslate) { 164 QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_None; 165 QImage::Format imageFormat = QImage::Format_Invalid; 166 switch (m_type) { 167 case Raster_RGBMask: 168 format = QFontEngineFT::Format_A32; 169 imageFormat = QImage::Format_RGB32; 170 break; 171 case Raster_A8: 172 format = QFontEngineFT::Format_A8; 173 imageFormat = QImage::Format_Indexed8; 174 break; 175 case Raster_Mono: 176 format = QFontEngineFT::Format_Mono; 177 imageFormat = QImage::Format_Mono; 178 break; 179 }; 180 181 QFontEngineFT *ft = static_cast<QFontEngineFT*> (m_current_textitem->fontEngine); 182 QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform); 183 184 if (gset && ft->loadGlyphs(gset, &g, 1, format)) { 185 QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g); 186 const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3 187 : (glyph->width + 3) & ~3); 188 return QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, imageFormat); 189 } 190 } else 191 #endif 192 if (m_type == QFontEngineGlyphCache::Raster_RGBMask) 193 return m_current_textitem->fontEngine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform); 194 else 195 return m_current_textitem->fontEngine->alphaMapForGlyph(g, m_transform); 196 197 return QImage(); 157 198 } 158 199 … … 189 230 int QImageTextureGlyphCache::glyphMargin() const 190 231 { 191 #if def Q_WS_MAC192 return 2;232 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) 233 return 0; 193 234 #else 194 235 return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; … … 198 239 void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) 199 240 { 200 QImage mask; 201 #if defined(Q_WS_X11) 202 if (m_transform.type() > QTransform::TxTranslate) { 203 QFontEngineFT::GlyphFormat format = QFontEngineFT::Format_None; 204 switch (m_type) { 205 case Raster_RGBMask: 206 format = QFontEngineFT::Format_A32; break; 207 case Raster_A8: 208 format = QFontEngineFT::Format_A8; break; 209 case Raster_Mono: 210 format = QFontEngineFT::Format_Mono; break; 211 }; 212 213 QFontEngineFT *ft = static_cast<QFontEngineFT*> (m_current_textitem->fontEngine); 214 QFontEngineFT::QGlyphSet *gset = ft->loadTransformedGlyphSet(m_transform); 215 216 if (gset && ft->loadGlyphs(gset, &g, 1, format)) { 217 QFontEngineFT::Glyph *glyph = gset->glyph_data.value(g); 218 const int bytesPerLine = (format == QFontEngineFT::Format_Mono ? ((glyph->width + 31) & ~31) >> 3 219 : (glyph->width + 3) & ~3); 220 mask = QImage(glyph->data, glyph->width, glyph->height, bytesPerLine, m_image.format()); 221 } 222 } else 223 #endif 224 if (m_type == QFontEngineGlyphCache::Raster_RGBMask) 225 mask = m_current_textitem->fontEngine->alphaRGBMapForGlyph(g, glyphMargin(), m_transform); 226 else 227 mask = m_current_textitem->fontEngine->alphaMapForGlyph(g, m_transform); 241 QImage mask = textureMapForGlyph(g); 228 242 229 243 #ifdef CACHE_DEBUG
Note:
See TracChangeset
for help on using the changeset viewer.