Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qtextureglyphcache.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    8989               ti.descent.toReal());
    9090#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();
    9393        if (glyph_height == 0 || glyph_width == 0)
    9494            continue;
    95 
     95        glyph_width += margin * 2 + 4;
     96        glyph_height += margin * 2 + 4;
    9697        // align to 8-bit boundary
    9798        if (m_type == QFontEngineGlyphCache::Raster_Mono)
     
    101102                    glyph_width,
    102103                    glyph_height, // texture coords
    103                     metrics.x.truncate(),
     104                    metrics.x.round().truncate(),
    104105                    -metrics.y.truncate() }; // baseline for horizontal scripts
    105106
     
    155156
    156157
     158}
     159
     160QImage 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();
    157198}
    158199
     
    189230int QImageTextureGlyphCache::glyphMargin() const
    190231{
    191 #ifdef Q_WS_MAC
    192     return 2;
     232#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
     233    return 0;
    193234#else
    194235    return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
     
    198239void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g)
    199240{
    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);
    228242
    229243#ifdef CACHE_DEBUG
Note: See TracChangeset for help on using the changeset viewer.