Changeset 561 for trunk/src/gui/painting/qpaintengine_mac.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/qpaintengine_mac.cpp
r2 r561 2 2 ** 3 3 ** 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]) 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 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 103 103 extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice); 104 104 CGColorSpaceRef colorspace = qt_mac_colorSpaceForDeviceType(pe->paintDevice()); 105 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)106 105 uint flags = kCGImageAlphaPremultipliedFirst; 107 106 #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; 113 108 #endif 114 109 const QImage *image = (const QImage *) pe->paintDevice(); … … 122 117 if (devType == QInternal::Widget) { 123 118 QRegion clip = p->paintEngine()->systemClip(); 119 120 124 121 if (p->hasClipping()) { 122 123 125 124 if (clip.isEmpty()) 126 clip = p->clipRegion();125 clip = ; 127 126 else 128 clip &= p->clipRegion();127 clip &= ; 129 128 } 130 129 qt_mac_clip_cg(context, clip, 0); … … 132 131 QPainterState *state = static_cast<QPainterState *>(pe->state); 133 132 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()); 136 135 } 137 136 } … … 529 528 inline static QPaintEngine::PaintEngineFeatures qt_mac_cg_features() 530 529 { 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); 548 536 } 549 537 … … 995 983 image = qt_mac_create_imagemask(pm, sr); 996 984 } 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()))); 1014 987 } else { 1015 988 image = (CGImageRef)pm.macCGHandle(); … … 1033 1006 image = new QImage(img); 1034 1007 1035 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)1036 1008 uint cgflags = kCGImageAlphaNone; 1037 #else1038 CGImageAlphaInfo cgflags = kCGImageAlphaNone;1039 #endif1040 1009 switch (image->format()) { 1041 1010 case QImage::Format_ARGB32_Premultiplied: … … 1050 1019 break; 1051 1020 } 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; 1055 1023 #endif 1056 1024 QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(image, 1057 1025 static_cast<const QImage *>(image)->bits(), 1058 image-> numBytes(),1026 image->(), 1059 1027 drawImageReleaseData); 1060 1028 if (imagePtr) … … 1080 1048 QCFType<CGImageRef> cgimage = qt_mac_createCGImageFromQImage(img, &image); 1081 1049 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())); 1103 1053 qt_mac_drawCGImage(d->hd, &rect, cgimage); 1104 1054 } … … 1436 1386 Q_D(QCoreGraphicsPaintEngine); 1437 1387 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 } 1440 1395 CGContextSetShouldSmoothFonts(d->hd, hints & QPainter::TextAntialiasing); 1441 1396 } … … 1498 1453 linedashes.append(customs.at(i)); 1499 1454 } else if(pen.style() == Qt::DashLine) { 1500 linedashes.append( 3);1501 linedashes.append( 1);1455 linedashes.append(); 1456 linedashes.append(); 1502 1457 } else if(pen.style() == Qt::DotLine) { 1503 1458 linedashes.append(1); 1459 1460 1461 1462 1504 1463 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); 1507 1468 linedashes.append(1); 1469 1508 1470 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); 1517 1472 } 1518 1473 const CGFloat cglinewidth = pen.widthF() <= 0.0f ? 1.0f : float(pen.widthF());
Note:
See TracChangeset
for help on using the changeset viewer.