44 #include <private/qpaintengine_mac_p.h> 47 #include <private/qpaintengine_raster_p.h> 48 #include <private/qprintengine_mac_p.h> 58 #include <private/qfont_p.h> 59 #include <private/qfontengine_p.h> 60 #include <private/qfontengine_coretext_p.h> 61 #include <private/qfontengine_mac_p.h> 62 #include <private/qnumeric_p.h> 63 #include <private/qpainter_p.h> 64 #include <private/qpainterpath_p.h> 65 #include <private/qpixmap_mac_p.h> 66 #include <private/qt_mac_p.h> 67 #include <private/qtextengine_p.h> 68 #include <private/qwidget_p.h> 69 #include <private/qt_cocoa_helpers_mac_p.h> 95 pe = static_cast<QMacPrintEngine*>(pe)->paintEngine();
99 context = static_cast<QCoreGraphicsPaintEngine*>(pe)->handle();
107 uint flags = kCGImageAlphaPremultipliedFirst;
108 #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version 109 flags |= kCGBitmapByteOrder32Host;
117 CGContextScaleCTM(
context, 1, -1);
134 CGContextTranslateCTM(
context, native.
dx(), native.
dy());
150 return CGAffineTransformMake(t.
m11(), t.
m12(), t.
m21(), t.
m22(), t.
dx(), t.
dy());
175 #ifdef QT_MAC_USE_NATIVE_GRADIENTS 176 static bool drawGradientNatively(
const QGradient *gradient)
182 static void qt_mac_color_gradient_function(
void *
info,
const CGFloat *in,
CGFloat *out)
188 const int n = stops.
count();
195 while (i != end && i->
first < p)
201 }
else if (i == end) {
202 c = (end - 1)->second.rgba();
210 int idist = 256 * (p - p1) / (p2 - p1);
211 int dist = 256 - idist;
228 static bool inReset =
false;
233 CGAffineTransform old_xform = CGContextGetCTM(hd);
236 CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform));
237 while (stackCount > 0) {
238 restoreGraphicsState();
243 CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
244 CGContextConcatCTM(hd, old_xform);
249 return CGRectMake(r.
x()+off, r.
y()+off, r.
width(), r.
height());
254 CGMutablePathRef ret = CGPathCreateMutable();
263 CGPathCloseSubpath(ret);
265 CGPathMoveToPoint(ret, 0, elm.
x+off, elm.
y+off);
268 CGPathAddLineToPoint(ret, 0, elm.
x+off, elm.
y+off);
273 CGPathAddCurveToPoint(ret, 0,
274 elm.
x+off, elm.
y+off,
280 qFatal(
"QCoreGraphicsPaintEngine::drawPath(), unhandled type: %d", elm.
type);
287 CGPathCloseSubpath(ret);
298 if (!m_genericColorSpace) {
299 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 301 m_genericColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
305 m_genericColorSpace = CGColorSpaceCreateDeviceRGB();
307 if (!m_postRoutineRegistered) {
308 m_postRoutineRegistered =
true;
312 return m_genericColorSpace;
315 return macDisplayColorSpace();
326 if (m_displayColorSpaceHash.contains(window))
327 return m_displayColorSpaceHash.value(window);
330 CGDirectDisplayID displayID;
332 displayID = CGMainDisplayID();
336 CGDisplayCount throwAway;
337 CGDisplayErr dErr = CGGetDisplaysWithRect(rect, 1, &displayID, &throwAway);
338 if (dErr != kCGErrorSuccess)
339 displayID = CGMainDisplayID();
344 CMProfileRef displayProfile = 0;
345 CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile);
347 colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile);
348 CMCloseProfile(displayProfile);
353 colorSpace = CGColorSpaceCreateDeviceRGB();
356 if (!m_postRoutineRegistered) {
357 m_postRoutineRegistered =
true;
362 m_displayColorSpaceHash.insert(window, colorSpace);
368 if (m_genericColorSpace) {
369 CFRelease(m_genericColorSpace);
370 m_genericColorSpace = 0;
373 while (it != m_displayColorSpaceHash.
constEnd()) {
375 CFRelease(it.
value());
378 m_displayColorSpaceHash.clear();
383 CGAffineTransform old_xform = CGAffineTransformIdentity;
385 old_xform = CGContextGetCTM(hd);
386 CGContextConcatCTM(hd, CGAffineTransformInvert(old_xform));
387 CGContextConcatCTM(hd, *orig_xform);
391 CGContextBeginPath(hd);
393 CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
395 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 399 HIShapeReplacePathInCGContext(shape, hd);
404 const int count = rects.
size();
405 for(
int i = 0; i < count; i++) {
406 const QRect &r = rects[i];
408 CGContextAddRect(hd, mac_r);
416 CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
417 CGContextConcatCTM(hd, old_xform);
424 # define QMACPATTERN_MASK_MULTIPLIER 32 426 # define QMACPATTERN_MASK_MULTIPLIER 1 435 return CGImageGetWidth(image);
438 return data.pixmap.width();
442 return CGImageGetHeight(image);
445 return data.pixmap.height();
468 #if (QMACPATTERN_MASK_MULTIPLIER == 1) 469 CGDataProviderRef provider = CGDataProviderCreateWithData(0, pat->
data.
bytes, w*h, 0);
470 pat->
image = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0,
false);
471 CGDataProviderRelease(provider);
473 const int numBytes = (w*h)/
sizeof(
uchar);
474 uchar xor_bytes[numBytes];
475 for(
int i = 0; i < numBytes; ++i)
476 xor_bytes[i] = pat->
data.
bytes[i] ^ 0xFF;
477 CGDataProviderRef provider = CGDataProviderCreateWithData(0, xor_bytes, w*h, 0);
478 CGImageRef swatch = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0,
false);
479 CGDataProviderRelease(provider);
481 const QColor c0(0, 0, 0, 0), c1(255, 255, 255, 255);
486 CGRect rect = CGRectMake(0, 0, w, h);
488 rect.origin.x = x * w;
490 rect.origin.y = y * h;
495 CGImageRelease(swatch);
496 CGContextRelease(pm_ctx);
509 w = CGImageGetWidth(pat->
image);
510 h = CGImageGetHeight(pat->
image);
514 bool needRestore =
false;
515 if (CGImageIsMask(pat->
image)) {
516 CGContextSaveGState(c);
519 CGRect rect = CGRectMake(0, 0, w, h);
522 CGContextRestoreGState(c);
563 qWarning(
"QCoreGraphicsPaintEngine::begin: Painter already active");
569 d->complexXForm =
false;
571 d->cosmeticPenSize = 1;
572 d->current.clipEnabled =
false;
576 d->saveGraphicsState();
577 d->orig_xform = CGContextGetCTM(
d->hd);
579 CGShadingRelease(
d->shading);
593 qWarning(
"QCoreGraphicsPaintEngine::begin: Does not support clipped desktop on Mac OS X");
595 }
else if(unclipped) {
596 qWarning(
"QCoreGraphicsPaintEngine::begin: Does not support unclipped painting");
601 qWarning(
"QCoreGraphicsPaintEngine::begin: Cannot paint null pixmap");
620 #ifndef QT_MAC_USE_COCOA 628 CGShadingRelease(
d->shading);
633 d->restoreGraphicsState();
634 CGContextSynchronize(
d->hd);
635 CGContextRelease(
d->hd);
645 QPaintEngine::DirtyFlags flags = state.
state();
666 if (flags & (DirtyClipPath | DirtyClipRegion | DirtyClipEnabled))
682 if (flags & (DirtyPen | DirtyTransform)) {
683 if (!
d->current.pen.isCosmetic()) {
685 }
else if (
d->current.transform.m11() <
d->current.transform.m22()-1.0 ||
686 d->current.transform.m11() >
d->current.transform.m22()+1.0) {
688 d->cosmeticPenSize =
d->adjustPenWidth(
d->current.pen.widthF());
689 if (!
d->cosmeticPenSize)
690 d->cosmeticPenSize = 1.0;
693 static const float sqrt2 = sqrt(2);
694 qreal width =
d->current.pen.widthF();
697 d->cosmeticPenSize = sqrt(pow(
d->pixelSize.y(), 2) + pow(
d->pixelSize.x(), 2)) / sqrt2 * width;
707 d->current.pen = pen;
708 d->setStrokePen(pen);
716 d->current.brush = brush;
718 #ifdef QT_MAC_USE_NATIVE_GRADIENTS 721 if (drawGradientNatively(gradient)) {
730 CGShadingRelease(
d->shading);
733 d->setFillBrush(brushOrigin);
740 CGContextSetAlpha(
d->hd, opacity);
762 d->current.transform = transform;
763 d->setTransform(transform.
isIdentity() ? 0 : &transform);
764 d->complexXForm = (transform.
m11() != 1 || transform.
m22() != 1
765 || transform.
m12() != 0 || transform.
m21() != 0);
766 d->pixelSize =
d->devicePixelSize(
d->hd);
775 if(
d->current.clipEnabled) {
776 d->current.clipEnabled =
false;
781 if(!
d->current.clipEnabled)
783 d->current.clipEnabled =
true;
786 d->current.clip = clipRegion;
789 CGRect rect = CGRectMake(0, 0, 0, 0);
790 CGContextClipToRect(
d->hd, rect);
793 CGContextBeginPath(
d->hd);
794 CGContextAddPath(
d->hd, path);
796 CGContextClip(
d->hd);
798 CGContextEOClip(
d->hd);
802 d->current.clip =
d->current.clip.intersected(clipRegion);
803 d->setClip(&
d->current.clip);
805 d->current.clip =
d->current.clip.united(clipRegion);
806 d->setClip(&
d->current.clip);
817 d->current.clipEnabled =
false;
821 if(!
d->current.clipEnabled)
823 d->current.clipEnabled =
true;
825 d->current.clip =
d->current.clip.intersected(clipRegion);
827 d->current.clip = clipRegion;
829 d->current.clip =
d->current.clip.united(clipRegion);
830 d->setClip(&
d->current.clip);
849 CGContextBeginPath(
d->hd);
850 d->drawPath(ops, path);
863 for (
int i=0; i<rectCount; ++i) {
866 CGMutablePathRef path = CGPathCreateMutable();
884 CGContextSetLineCap(
d->hd, kCGLineCapSquare);
886 CGMutablePathRef path = CGPathCreateMutable();
887 for(
int i=0; i < pointCount; i++) {
888 float x = points[i].
x(), y = points[i].
y();
889 CGPathMoveToPoint(path, 0, x, y);
890 CGPathAddLineToPoint(path, 0, x+0.001, y);
893 bool doRestore =
false;
897 d->saveGraphicsState();
898 CGContextSetLineWidth(
d->hd,
d->current.pen.widthF());
902 d->restoreGraphicsState();
905 CGContextSetLineCap(
d->hd, kCGLineCapButt);
917 CGMutablePathRef path = CGPathCreateMutable();
918 CGAffineTransform transform = CGAffineTransformMakeScale(r.
width() / r.
height(), 1);
919 CGPathAddArc(path, &transform,(r.
x() + (r.
width() / 2)) / (r.
width() / r.
height()),
935 CGMutablePathRef path = CGPathCreateMutable();
936 CGPathMoveToPoint(path, 0, points[0].x(), points[0].y());
937 for(
int x = 1; x < pointCount; ++x)
938 CGPathAddLineToPoint(path, 0, points[x].x(), points[x].y());
939 if(mode !=
PolylineMode && points[0] != points[pointCount-1])
940 CGPathAddLineToPoint(path, 0, points[0].x(), points[0].y());
945 d->drawPath(op, path);
958 CGMutablePathRef path = CGPathCreateMutable();
959 for(
int i = 0; i < lineCount; i++) {
961 CGPathMoveToPoint(path, 0, start.
x(), start.
y());
962 CGPathAddLineToPoint(path, 0,
end.x(),
end.y());
979 bool differentSize = (
QRectF(0, 0, pm.
width(), pm.
height()) != sr), doRestore =
false;
982 bool isBitmap = (pm.
depth() == 1);
985 d->saveGraphicsState();
987 const QColor &col =
d->current.pen.color();
990 }
else if (differentSize) {
998 d->restoreGraphicsState();
1009 if (img.
depth() != 32)
1014 uint cgflags = kCGImageAlphaNone;
1015 switch (image->
format()) {
1017 cgflags = kCGImageAlphaPremultipliedFirst;
1020 cgflags = kCGImageAlphaFirst;
1023 cgflags = kCGImageAlphaNoneSkipFirst;
1027 #if defined(kCGBitmapByteOrder32Host) //only needed because CGImage.h added symbols in the minor version 1028 cgflags |= kCGBitmapByteOrder32Host;
1031 static_cast<const QImage *>(image)->bits(),
1036 return CGImageCreate(image->
width(), image->
height(), 8, 32,
1039 cgflags, dataProvider, 0,
false, kCGRenderingIntentDefault);
1044 Qt::ImageConversionFlags flags)
1057 cgimage = CGImageCreateWithImageInRect(cgimage, CGRectMake(sr.
x(), sr.
y(),
1078 return d_func()->hd;
1092 d->saveGraphicsState();
1098 qpattern->
pdev =
d->pdev;
1099 CGPatternCallbacks callbks;
1100 callbks.version = 0;
1103 const int width = qpattern->
width(), height = qpattern->
height();
1104 CGAffineTransform trans = CGContextGetCTM(
d->hd);
1105 CGPatternRef pat = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
1106 trans, width, height,
1107 kCGPatternTilingNoDistortion,
true, &callbks);
1109 CGContextSetFillColorSpace(
d->hd, cs);
1111 CGContextSetFillPattern(
d->hd, pat, &component);
1112 CGSize phase = CGSizeApplyAffineTransform(CGSizeMake(-(p.
x()-r.
x()), -(p.
y()-r.
y())), trans);
1113 CGContextSetPatternPhase(
d->hd, phase);
1117 CGContextFillRect(
d->hd, mac_rect);
1120 d->restoreGraphicsState();
1122 CGColorSpaceRelease(cs);
1123 CGPatternRelease(pat);
1130 #ifndef QMAC_NATIVE_GRADIENTS 1155 if(textAA != lineAA)
1156 CGContextSetShouldAntialias(
d->hd, textAA);
1159 switch (fe->
type()) {
1161 #ifdef QT_MAC_USE_COCOA 1168 d->drawBoxTextItem(pos, ti);
1175 if(textAA != lineAA)
1176 CGContextSetShouldAntialias(
d->hd, !textAA);
1182 QPainter::RenderHints
1208 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 1210 int cg_mode = kCGBlendModeNormal;
1213 cg_mode = kCGBlendModeMultiply;
1216 cg_mode = kCGBlendModeScreen;
1219 cg_mode = kCGBlendModeOverlay;
1222 cg_mode = kCGBlendModeDarken;
1225 cg_mode = kCGBlendModeLighten;
1228 cg_mode = kCGBlendModeColorDodge;
1231 cg_mode = kCGBlendModeColorBurn;
1234 cg_mode = kCGBlendModeHardLight;
1237 cg_mode = kCGBlendModeSoftLight;
1240 cg_mode = kCGBlendModeDifference;
1243 cg_mode = kCGBlendModeExclusion;
1246 cg_mode = kCGBlendModePlusLighter;
1249 cg_mode = kCGBlendModeNormal;
1252 cg_mode = kCGBlendModeDestinationOver;
1255 cg_mode = kCGBlendModeClear;
1258 cg_mode = kCGBlendModeCopy;
1264 cg_mode = kCGBlendModeSourceIn;
1270 cg_mode = kCGBlendModeSourceOut;
1273 cg_mode = kCGBlendModeDestinationOver;
1276 cg_mode = kCGBlendModeSourceAtop;
1279 cg_mode = kCGBlendModeDestinationAtop;
1282 cg_mode = kCGBlendModeXOR;
1288 CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
1307 qWarning(
"QCoreGraphicsPaintEngine: Unhandled composition mode %d", (
int)mode);
1340 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) 1341 bool needPrivateAPI =
false;
1343 int cg_mode = kCGBlendModeNormal;
1346 cg_mode = kCGBlendModeMultiply;
1349 cg_mode = kCGBlendModeScreen;
1352 cg_mode = kCGBlendModeOverlay;
1355 cg_mode = kCGBlendModeDarken;
1358 cg_mode = kCGBlendModeLighten;
1361 cg_mode = kCGBlendModeColorDodge;
1364 cg_mode = kCGBlendModeColorBurn;
1367 cg_mode = kCGBlendModeHardLight;
1370 cg_mode = kCGBlendModeSoftLight;
1373 cg_mode = kCGBlendModeDifference;
1376 cg_mode = kCGBlendModeExclusion;
1379 needPrivateAPI =
true;
1385 if (!needPrivateAPI)
1386 CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
1400 if (ScaleFactor > 1.) {
1401 CGContextSetInterpolationQuality(
d->hd, kCGInterpolationHigh);
1404 kCGInterpolationHigh : kCGInterpolationNone);
1407 if (!textAntialiasing ||
d->disabledSmoothFonts) {
1408 d->disabledSmoothFonts = !textAntialiasing;
1409 CGContextSetShouldSmoothFonts(
d->hd, textAntialiasing);
1430 float ret = penWidth;
1434 else if (penWidth < 3)
1446 CGLineCap cglinecap = kCGLineCapButt;
1448 cglinecap = kCGLineCapSquare;
1450 cglinecap = kCGLineCapRound;
1451 CGContextSetLineCap(hd, cglinecap);
1452 CGContextSetLineWidth(hd, adjustPenWidth(pen.
widthF()));
1455 CGLineJoin cglinejoin = kCGLineJoinMiter;
1457 cglinejoin = kCGLineJoinBevel;
1459 cglinejoin = kCGLineJoinRound;
1460 CGContextSetLineJoin(hd, cglinejoin);
1467 for(
int i = 0; i < customs.
size(); ++i)
1489 for(
int i = 0; i < linedashes.
size(); ++i) {
1490 linedashes[i] *= cglinewidth;
1491 if(cglinewidth < 3 && (cglinecap == kCGLineCapSquare || cglinecap == kCGLineCapRound)) {
1493 linedashes[i] += cglinewidth/2;
1495 linedashes[i] -= cglinewidth/2;
1498 CGContextSetLineDash(hd, pen.
dashOffset() * cglinewidth, linedashes.
data(), linedashes.
size());
1509 static const uchar dense1_pat[] = { 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00 };
1510 static const uchar dense2_pat[] = { 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00, 0x88 };
1511 static const uchar dense3_pat[] = { 0x11, 0xaa, 0x44, 0xaa, 0x11, 0xaa, 0x44, 0xaa };
1512 static const uchar dense4_pat[] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
1513 static const uchar dense5_pat[] = { 0xee, 0x55, 0xbb, 0x55, 0xee, 0x55, 0xbb, 0x55 };
1514 static const uchar dense6_pat[] = { 0xff, 0xdd, 0xff, 0x77, 0xff, 0xdd, 0xff, 0x77 };
1515 static const uchar dense7_pat[] = { 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, 0xff };
1516 static const uchar hor_pat[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff };
1517 static const uchar ver_pat[] = { 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef };
1518 static const uchar cross_pat[] = { 0xef, 0xef, 0xef, 0xef, 0x00, 0xef, 0xef, 0xef };
1519 static const uchar fdiag_pat[] = { 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe };
1520 static const uchar bdiag_pat[] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f };
1521 static const uchar dcross_pat[] = { 0x7e, 0xbd, 0xdb, 0xe7, 0xe7, 0xdb, 0xbd, 0x7e };
1522 static const uchar *
const pat_tbl[] = {
1523 dense1_pat, dense2_pat, dense3_pat, dense4_pat, dense5_pat,
1524 dense6_pat, dense7_pat,
1525 hor_pat, ver_pat, cross_pat, bdiag_pat, fdiag_pat, dcross_pat };
1533 #ifdef QT_MAC_USE_NATIVE_GRADIENTS 1536 if (drawGradientNatively(grad)) {
1539 static const CGFloat domain[] = { 0.0f, +1.0f };
1540 static const CGFunctionCallbacks callbacks = { 0, qt_mac_color_gradient_function, 0 };
1541 CGFunctionRef fill_func = CGFunctionCreate(reinterpret_cast<void *>(¤t.brush),
1542 1, domain, 4, 0, &callbacks);
1549 shading = CGShadingCreateAxial(colorspace, CGPointMake(start.x(), start.y()),
1550 CGPointMake(stop.x(), stop.y()), fill_func,
true,
true);
1558 shading = CGShadingCreateRadial(colorspace, CGPointMake(focal.x(), focal.y()),
1559 focalRadius, CGPointMake(
center.x(),
center.y()), radius, fill_func,
false,
true);
1562 CGFunctionRelease(fill_func);
1567 #ifndef QT_MAC_USE_NATIVE_GRADIENTS
1573 qpattern->
pdev = pdev;
1574 CGFloat components[4] = { 1.0, 1.0, 1.0, 1.0 };
1577 qpattern->
data.
pixmap = current.brush.texture();
1579 const QColor &col = current.brush.color();
1589 const QColor &col = current.brush.color();
1595 int width = qpattern->
width(), height = qpattern->
height();
1596 qpattern->
foreground = current.brush.color();
1598 CGColorSpaceRef fill_colorspace = CGColorSpaceCreatePattern(base_colorspace);
1599 CGContextSetFillColorSpace(hd, fill_colorspace);
1601 CGAffineTransform xform = CGContextGetCTM(hd);
1603 xform = CGAffineTransformTranslate(xform, offset.
x(), offset.
y());
1605 CGPatternCallbacks callbks;
1606 callbks.version = 0;
1609 CGPatternRef fill_pattern = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
1610 xform, width, height, kCGPatternTilingNoDistortion,
1611 !base_colorspace, &callbks);
1612 CGContextSetFillPattern(hd, fill_pattern, components);
1614 CGPatternRelease(fill_pattern);
1615 CGColorSpaceRelease(fill_colorspace);
1617 CGContextSetFillColorWithColor(hd,
cgColorForQColor(current.brush.color(), pdev));
1627 QRegion sysClip = q->systemClip();
1644 switch(element->type) {
1645 case kCGPathElementMoveToPoint:
1646 CGPathMoveToPoint(t->
path, &t->
transform, element->points[0].x, element->points[0].y);
1648 case kCGPathElementAddLineToPoint:
1649 CGPathAddLineToPoint(t->
path, &t->
transform, element->points[0].x, element->points[0].y);
1651 case kCGPathElementAddQuadCurveToPoint:
1652 CGPathAddQuadCurveToPoint(t->
path, &t->
transform, element->points[0].x, element->points[0].y,
1653 element->points[1].x, element->points[1].y);
1655 case kCGPathElementAddCurveToPoint:
1656 CGPathAddCurveToPoint(t->
path, &t->
transform, element->points[0].x, element->points[0].y,
1657 element->points[1].x, element->points[1].y,
1658 element->points[2].x, element->points[2].y);
1660 case kCGPathElementCloseSubpath:
1661 CGPathCloseSubpath(t->
path);
1664 qDebug() <<
"Unhandled path transform type: " << element->type;
1671 Q_ASSERT((ops & (CGFill | CGEOFill)) != (CGFill | CGEOFill));
1672 if((ops & (CGFill | CGEOFill))) {
1675 CGContextBeginPath(hd);
1676 CGContextAddPath(hd, path);
1677 saveGraphicsState();
1680 else if (ops & CGEOFill)
1681 CGContextEOClip(hd);
1683 CGRect boundingBox = CGPathGetBoundingBox(path);
1684 CGContextConcatCTM(hd,
1685 CGAffineTransformMake(boundingBox.size.width, 0,
1686 0, boundingBox.size.height,
1687 boundingBox.origin.x, boundingBox.origin.y));
1689 CGContextDrawShading(hd, shading);
1690 restoreGraphicsState();
1693 }
else if (current.brush.style() ==
Qt::NoBrush) {
1698 if((ops & CGStroke) && current.pen.style() ==
Qt::NoPen)
1701 if(ops & (CGEOFill | CGFill)) {
1702 CGContextBeginPath(hd);
1703 CGContextAddPath(hd, path);
1704 if (ops & CGEOFill) {
1705 CGContextEOFillPath(hd);
1707 CGContextFillPath(hd);
1714 if(ops & CGStroke) {
1715 if (needContextSave)
1716 saveGraphicsState();
1717 CGContextBeginPath(hd);
1724 if (current.pen.style() ==
Qt::SolidLine || current.pen.width() >= 3)
1725 CGContextTranslateCTM(hd,
double(
pixelSize.x()) * 0.25,
double(
pixelSize.y()) * 0.25);
1729 CGContextTranslateCTM(hd, 0,
double(
pixelSize.y()) * 0.1);
1735 CGContextSetLineWidth(hd, cosmeticPenSize);
1736 else if (current.pen.widthF() <= 1)
1737 CGContextSetLineWidth(hd, cosmeticPenSize * 0.9f);
1739 CGContextSetLineWidth(hd, cosmeticPenSize);
1744 t.
path = CGPathCreateMutable();
1747 CGContextSetLineWidth(hd, cosmeticPenSize);
1748 CGContextAddPath(hd, t.
path);
1749 CGPathRelease(t.
path);
1751 CGContextAddPath(hd, path);
1754 CGContextStrokePath(hd);
1755 if (needContextSave)
1756 restoreGraphicsState();
ElementType type
the type of element
QPainterPath clipPath() const
Returns the currently clip as a path.
qreal focalRadius() const
Returns the focal radius of this radial gradient in logical coordinates.
The QPainter class performs low-level painting on widgets and other paint devices.
static const uchar * qt_mac_patternForBrush(int brushStyle)
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
The QColor class provides colors based on RGB, HSV or CMYK values.
static QCFType< CGColorRef > cgColorForQColor(const QColor &col, QPaintDevice *pdev)
QPointF focalPoint() const
Returns the focal point of this radial gradient in logical coordinates.
The QPainterPath::Element class specifies the position and type of a subpath.
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
static CGColorSpaceRef macDisplayColorSpace(const QWidget *widget=0)
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
QPixmap qt_pixmapForBrush(int, bool)
static CGColorSpaceRef macGenericColorSpace()
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
static void cleanUpMacColorSpaces()
static CGMutablePathRef qt_mac_compose_path(const QPainterPath &p, float off=0)
static mach_timebase_info_data_t info
qreal opacity() const
Returns the opacity in the current paint engine state.
#define QT_END_NAMESPACE
This macro expands to.
bool end()
Reimplement this function to finish painting on the current paint device.
int width() const
Returns the width of the pixmap.
void setStrokePen(const QPen &pen)
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
QPointer< QWidget > widget
void syncState()
Updates all dirty states in this engine.
int remove(const Key &key)
Removes all the items that have the key from the hash.
CompositionMode
Defines the modes supported for digital image compositing.
void setFillBrush(const QPointF &origin=QPoint())
const QGradient * gradient() const
Returns the gradient describing this brush.
#define it(className, varName)
void qAddPostRoutine(QtCleanUpFunction p)
void drawPoints(const QPointF *p, int pointCount)
Draws the first pointCount points in the buffer points.
PaintEngineFeatures gccaps
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
QPaintEngineState * state
void updateRenderHints(QPainter::RenderHints hints)
int qt_antialiasing_threshold
Qt::PenStyle style() const
Returns the pen style.
QPointF p1() const
Returns the line's start point.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
QTransform transform() const
Returns the matrix in the current paint engine state.
CGFloat qt_mac_get_scalefactor()
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
The QPointF class defines a point in the plane using floating point precision.
CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *paintDevice)
void updatePen(const QPen &pen)
int byteCount() const
Returns the number of bytes occupied by the image data.
QColor color() const
Returns the color of this pen's brush.
int width() const
Returns the width of the rectangle.
static bool qt_is_nan(double d)
static void drawImageReleaseData(void *info, const void *, size_t)
struct CGImage * CGImageRef
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
Reimplement this function to draw the pixmap in the given rect, starting at the given p...
int bytesPerLine() const
Returns the number of bytes per image scanline.
#define QMACPATTERN_MASK_MULTIPLIER
void updateBrush(const QBrush &brush, const QPointF &pt)
int depth() const
Returns the depth of the pixmap.
ushort red
Returns the red color component of this color.
int height() const
Returns the height of the rectangle.
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush...
qreal y
the y coordinate of the element's position.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
Q_DECL_CONSTEXPR T qAbs(const T &t)
CGContextRef handle() const
The QPen class defines how a QPainter should draw lines and outlines of shapes.
virtual Type type() const =0
QPolygon toPolygon() const
Creates and returns a QPolygon by converting each QPointF to a QPoint.
virtual int devType() const
QVector< qreal > dashPattern() const
Returns the dash pattern of this pen.
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Format format() const
Returns the format of the image.
const T value(const Key &key) const
Returns the value associated with the key.
struct QMacPattern::@240 data
CGImageRef qt_mac_create_imagemask(const QPixmap &px, const QRectF &sr)
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op)
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
qreal x() const
Returns the x-coordinate of this point.
The QLineF class provides a two-dimensional vector using floating point precision.
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
Q_CORE_EXPORT void qDebug(const char *,...)
QGradientStops stops() const
Returns the stop points for this gradient.
void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
QRegion clipRegion() const
Returns the currently set clip region.
static int qt_mac_convert_color_from_cg(float c)
QPainter * painter() const
Returns the paint engine's painter.
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBrush brush() const
Returns the brush in the current paint engine state.
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
The QRectF class defines a rectangle in the plane using floating point precision. ...
void updateCompositionMode(QPainter::CompositionMode mode)
void updateMatrix(const QTransform &matrix)
QPoint brushOrigin() const
Returns the currently set brush origin.
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawTextItem(const QPointF &pos, const QTextItem &item)
This function draws the text item textItem at position p.
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
static float pixelSize(const QFontDef &request, int dpi)
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
void updateOpacity(qreal opacity)
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
void setActive(bool newState)
Sets the active state of the paint engine to state.
Q_STATIC_INLINE_FUNCTION uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
QFont font() const
Returns the font in the current paint engine state.
OSWindowRef qt_mac_window_for(const QWidget *)
qreal height() const
Returns the height of the rectangle.
QPainter::RenderHints supportedRenderHints() const
void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransform *orig_xform)
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
CGContextRef qt_mac_cg_context(const QPaintDevice *)
Returns the CoreGraphics CGContextRef of the paint device.
void append(const T &t)
Inserts value at the end of the vector.
void setClip(const QRegion *rgn=0)
Q_CORE_EXPORT void qWarning(const char *,...)
static void clearColorSpace(QWidget *w)
The QImage class provides a hardware-independent image representation that allows direct access to th...
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
static const char * data(const QByteArray &arr)
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
const QTransform & deviceTransform() const
Returns the matrix that transforms from logical coordinates to device coordinates of the platform dep...
qreal width() const
Returns the width of the rectangle.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Type type() const
Reimplement this function to return the paint engine Type.
void qt_mac_dispose_rgn(RgnHandle r)
QTransform combinedTransform() const
Returns the transformation matrix combining the current window/viewport and world transformation...
The QRegion class specifies a clip region for a painter.
void setDirty(DirtyFlags df)
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
int depth() const
Returns the depth of the image.
Qt::FillRule fillRule() const
Returns the painter path's currently set fill rule.
static qreal component(const QPointF &point, unsigned int i)
QPoint qt_mac_posInWindow(const QWidget *w)
static void qt_mac_dispose_pattern(void *info)
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
struct OpaqueRgnHandle * RgnHandle
QPointF start() const
Returns the start point of this linear gradient in logical coordinates.
void updateFont(const QFont &font)
void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
const T & at(int i) const
Returns the item at index position i in the vector.
static void qt_mac_draw_pattern(void *info, CGContextRef c)
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
~QCoreGraphicsPaintEngine()
const QBrush & brush() const
Returns the painter's current brush.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
float adjustPenWidth(float penWidth)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
uchar * bits()
Returns a pointer to the first pixel data.
Q_CORE_EXPORT void qFatal(const char *,...)
static QHash< QWidget *, CGColorSpaceRef > m_displayColorSpaceHash
int width() const
Returns the width of the image.
void drawPath(uchar ops, CGMutablePathRef path=0)
struct CGColorSpace * CGColorSpaceRef
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
ushort blue
Returns the blue color component of this color.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
ushort alpha
Returns the alpha color component of this color.
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush...
static CGRect qt_mac_compose_rect(const QRectF &r, float off=0)
The QFont class specifies a font used for drawing text.
int y() const
Returns the y-coordinate of the rectangle's top edge.
The QGradient class is used in combination with QBrush to specify gradient fills. ...
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
static CGColorSpaceRef m_genericColorSpace
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
OSStatus qt_mac_drawCGImage(CGContextRef inContext, const CGRect *inBounds, CGImageRef inImage)
QPointF p2() const
Returns the line's end point.
qreal widthF() const
Returns the pen width with floating point precision.
The QRect class defines a rectangle in the plane using integer precision.
CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &t)
qreal radius() const
Returns the radius of this radial gradient in logical coordinates.
Spread spread() const
Returns the spread method use by this gradient.
int height() const
Returns the height of the image.
QRect rect() const
Returns the pixmap's enclosing rectangle.
qreal x
the x coordinate of the element's position.
qreal y() const
Returns the y-coordinate of this point.
QPointF center() const
Returns the center of this radial gradient in logical coordinates.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
qreal dashOffset() const
Returns the dash offset for the pen.
void qt_mac_cg_transform_path_apply(void *info, const CGPathElement *element)
int height() const
Returns the height of the pixmap.
void CGContextSetCompositeOperation(CGContextRef, int)
The QPaintEngineState class provides information about the active paint engine's current state...
static float qt_mac_convert_color_to_cg(int c)
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
T * data()
Returns a pointer to the data stored in the vector.
static bool m_postRoutineRegistered
int elementCount() const
Returns the number of path elements in the painter path.
QPen pen() const
Returns the pen in the current paint engine state.
struct CGContext * CGContextRef
static QPaintEngine::PaintEngineFeatures qt_mac_cg_features()
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
The QTextItem class provides all the information required to draw text in a custom paint engine...
CGImageRef toMacCGImageRef() const
Creates a CGImageRef equivalent to the QPixmap.
QCoreGraphicsPaintEngine()
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
static const KeyPair *const end
QRegion systemClip() const
Returns the system clip.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
ushort green
Returns the green color component of this color.
int size() const
Returns the number of items in the vector.
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
Q_DECL_CONSTEXPR int qRound(qreal d)
QPointF finalStop() const
Returns the final stop point of this linear gradient in logical coordinates.
QPointF devicePixelSize(CGContextRef context)
CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imagePtr=0)
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.