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/qpaintengine_mac.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    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
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    103103        extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice);
    104104        CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice());
    105 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    106105        uint flags = kCGImageAlphaPremultipliedFirst;
    107106#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
    108         if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
    109             flags |= kCGBitmapByteOrder32Host;
    110 #endif
    111 #else
    112         CGImageAlphaInfo flags = kCGImageAlphaPremultipliedFirst;
     107        flags |= kCGBitmapByteOrder32Host;
    113108#endif
    114109        const QImage *image = (const QImage *) pe->paintDevice();
     
    122117        if (devType == QInternal::Widget) {
    123118            QRegion clip = p->paintEngine()->systemClip();
     119
     120
    124121            if (p->hasClipping()) {
     122
     123
    125124                if (clip.isEmpty())
    126                     clip = p->clipRegion();
     125                    clip = ;
    127126                else
    128                     clip &= p->clipRegion();
     127                    clip &= ;
    129128            }
    130129            qt_mac_clip_cg(context, clip, 0);
     
    132131            QPainterState *state = static_cast<QPainterState *>(pe->state);
    133132            Q_ASSERT(state);
    134             if (!state->redirection_offset.isNull())
    135                 CGContextTranslateCTM(context, -state->redirection_offset.x(), -state->redirection_offset.y());
     133            if (!state->redirection())
     134                CGContextTranslateCTM(context, y());
    136135        }
    137136    }
     
    529528inline static QPaintEngine::PaintEngineFeatures qt_mac_cg_features()
    530529{
    531     QPaintEngine::PaintEngineFeatures ret(QPaintEngine::AllFeatures
    532                                           & ~QPaintEngine::PaintOutsidePaintEvent
    533                                           & ~QPaintEngine::PerspectiveTransform
    534                                           & ~QPaintEngine::ConicalGradientFill
    535                                           & ~QPaintEngine::LinearGradientFill
    536                                           & ~QPaintEngine::RadialGradientFill
    537                                           & ~QPaintEngine::BrushStroke);
    538 
    539 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    540     if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    541         ;
    542     } else
    543 #endif
    544     {
    545         ret &= ~QPaintEngine::BlendModes;
    546     }
    547     return ret;
     530    return QPaintEngine::PaintEngineFeatures(QPaintEngine::AllFeatures & ~QPaintEngine::PaintOutsidePaintEvent
     531                                              & ~QPaintEngine::PerspectiveTransform
     532                                              & ~QPaintEngine::ConicalGradientFill
     533                                              & ~QPaintEngine::LinearGradientFill
     534                                              & ~QPaintEngine::RadialGradientFill
     535                                              & ~QPaintEngine::BrushStroke);
    548536}
    549537
     
    995983        image = qt_mac_create_imagemask(pm, sr);
    996984    } else if (differentSize) {
    997 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    998         if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    999             CGImageRef img = (CGImageRef)pm.macCGHandle();
    1000             image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
    1001             CGImageRelease(img);
    1002         } else
    1003 #endif
    1004         {
    1005             const int sx = qRound(sr.x()), sy = qRound(sr.y()), sw = qRound(sr.width()), sh = qRound(sr.height());
    1006             const QMacPixmapData *pmData = static_cast<const QMacPixmapData*>(pm.data);
    1007             quint32 *pantherData = pmData->pixels + (sy * pm.width() + sx);
    1008             QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0, pantherData, sw*sh*pmData->bytesPerRow, 0);
    1009             image = CGImageCreate(sw, sh, 8, 32, pmData->bytesPerRow,
    1010                                   macGenericColorSpace(),
    1011                                   kCGImageAlphaPremultipliedFirst, provider, 0, 0,
    1012                                   kCGRenderingIntentDefault);
    1013         }
     985        QCFType<CGImageRef> img = pm.toMacCGImageRef();
     986        image = CGImageCreateWithImageInRect(img, CGRectMake(qRound(sr.x()), qRound(sr.y()), qRound(sr.width()), qRound(sr.height())));
    1014987    } else {
    1015988        image = (CGImageRef)pm.macCGHandle();
     
    10331006        image = new QImage(img);
    10341007
    1035 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    10361008    uint cgflags = kCGImageAlphaNone;
    1037 #else
    1038     CGImageAlphaInfo cgflags = kCGImageAlphaNone;
    1039 #endif
    10401009    switch (image->format()) {
    10411010    case QImage::Format_ARGB32_Premultiplied:
     
    10501019        break;
    10511020    }
    1052 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) && defined(kCGBitmapByteOrder32Host) //only needed because CGImage.h added symbols in the minor version
    1053     if(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
    1054         cgflags |= kCGBitmapByteOrder32Host;
     1021#if defined(kCGBitmapByteOrder32Host) //only needed because CGImage.h added symbols in the minor version
     1022    cgflags |= kCGBitmapByteOrder32Host;
    10551023#endif
    10561024    QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(image,
    10571025                                                          static_cast<const QImage *>(image)->bits(),
    1058                                                           image->numBytes(),
     1026                                                          image->(),
    10591027                                                          drawImageReleaseData);
    10601028    if (imagePtr)
     
    10801048    QCFType<CGImageRef> cgimage = qt_mac_createCGImageFromQImage(img, &image);
    10811049    CGRect rect = CGRectMake(r.x(), r.y(), r.width(), r.height());
    1082     if (QRectF(0, 0, img.width(), img.height()) != sr) {
    1083 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    1084         if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
    1085             cgimage = CGImageCreateWithImageInRect(cgimage, CGRectMake(sr.x(), sr.y(),
    1086                         sr.width(), sr.height()));
    1087         } else
    1088 #endif
    1089         {
    1090             int sx = qRound(sr.x());
    1091             int sy = qRound(sr.y());
    1092             int sw = qRound(sr.width());
    1093             int sh = qRound(sr.height());
    1094             // Make another CGImage based on the part that we need.
    1095             const uchar *pantherData = image->scanLine(sy) + sx * sizeof(uint);
    1096             QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(0, pantherData,
    1097                                                                                    sw * sh * image->bytesPerLine(), 0);
    1098             cgimage = CGImageCreate(sw, sh, 8, 32, image->bytesPerLine(),
    1099                                     macGenericColorSpace(),
    1100                     CGImageGetAlphaInfo(cgimage), dataProvider, 0, false, kCGRenderingIntentDefault);
    1101         }
    1102     }
     1050    if (QRectF(0, 0, img.width(), img.height()) != sr)
     1051        cgimage = CGImageCreateWithImageInRect(cgimage, CGRectMake(sr.x(), sr.y(),
     1052                                               sr.width(), sr.height()));
    11031053    qt_mac_drawCGImage(d->hd, &rect, cgimage);
    11041054}
     
    14361386    Q_D(QCoreGraphicsPaintEngine);
    14371387    CGContextSetShouldAntialias(d->hd, hints & QPainter::Antialiasing);
    1438     CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ?
    1439                                      kCGInterpolationHigh : kCGInterpolationNone);
     1388    static const CGFloat ScaleFactor = qt_mac_get_scalefactor();
     1389    if (ScaleFactor > 1.) {
     1390        CGContextSetInterpolationQuality(d->hd, kCGInterpolationHigh);
     1391    } else {
     1392        CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ?
     1393                                         kCGInterpolationHigh : kCGInterpolationNone);
     1394    }
    14401395    CGContextSetShouldSmoothFonts(d->hd, hints & QPainter::TextAntialiasing);
    14411396}
     
    14981453            linedashes.append(customs.at(i));
    14991454    } else if(pen.style() == Qt::DashLine) {
    1500         linedashes.append(3);
    1501         linedashes.append(1);
     1455        linedashes.append();
     1456        linedashes.append();
    15021457    } else if(pen.style() == Qt::DotLine) {
    15031458        linedashes.append(1);
     1459
     1460
     1461
     1462
    15041463        linedashes.append(1);
    1505     } else if(pen.style() == Qt::DashDotLine) {
    1506         linedashes.append(3);
     1464        linedashes.append(2);
     1465    } else if(pen.style() == Qt::DashDotDotLine) {
     1466        linedashes.append(4);
     1467        linedashes.append(2);
    15071468        linedashes.append(1);
     1469
    15081470        linedashes.append(1);
    1509         linedashes.append(1);
    1510     } else if(pen.style() == Qt::DashDotDotLine) {
    1511         linedashes.append(3);
    1512         linedashes.append(1);
    1513         linedashes.append(1);
    1514         linedashes.append(1);
    1515         linedashes.append(1);
    1516         linedashes.append(1);
     1471        linedashes.append(2);
    15171472    }
    15181473    const CGFloat cglinewidth = pen.widthF() <= 0.0f ? 1.0f : float(pen.widthF());
Note: See TracChangeset for help on using the changeset viewer.