42 #include "qplatformdefs.h" 44 #include "private/qpixmap_x11_p.h" 60 #include <private/qfont_p.h> 61 #include <private/qtextengine_p.h> 62 #include <private/qpaintengine_x11_p.h> 63 #include <private/qfontengine_x11_p.h> 64 #include <private/qwidget_p.h> 65 #include <private/qpainterpath_p.h> 71 #include <private/qpaintengine_p.h> 74 #include <private/qt_x11_p.h> 75 #include <private/qnumeric_p.h> 79 #include <private/qtessellator_p.h> 82 #include <private/qstylehelper_p.h> 94 #undef X11 // defined in qt_x11_p.h 124 #define X11 qt_x11Data 126 #ifndef QT_NO_XRENDER 150 return op != PictOpOver && op != PictOpSrc;
158 return r.clipRectangles(num);
162 #ifndef QT_NO_XRENDER
173 XSetClipRectangles( dpy, gc, 0, 0, rects, num, YXBanded );
175 XSetClipRectangles( dpy, gc2, 0, 0, rects, num, YXBanded );
177 #ifndef QT_NO_XRENDER 179 XRenderSetPictureClipRectangles(dpy, picture, 0, 0, rects, num);
182 #endif // QT_NO_XRENDER 187 #ifndef QT_NO_XRENDER
195 XSetClipMask(dpy, gc,
XNone);
197 XSetClipMask(dpy, gc2,
XNone);
199 #ifndef QT_NO_XRENDER 201 XRenderPictureAttributes attrs;
202 attrs.clip_mask =
XNone;
203 XRenderChangePicture (dpy, picture, CPClipMask, &attrs);
207 #endif // QT_NO_XRENDER 211 #define DITHER_SIZE 16 213 { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
214 { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
215 { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
216 { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
217 { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
218 { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
219 { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
220 { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
221 { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
222 { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
223 { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
224 { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
225 { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
226 { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
227 { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
228 { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
241 pattern.
fill(0xffffffff);
249 pm.x11SetScreen(screen);
255 #if !defined(QT_NO_XRENDER) 272 if (allocated > 64) {
299 #endif // !defined(QT_NO_XRENDER) 302 #ifndef QT_NO_XRENDER 305 if (!
X11->use_xrender)
308 XRenderColor color =
X11->preMultiply(b.
color());
309 XRenderColor bg_color;
311 bg_color =
X11->preMultiply(
QColor(0, 0, 0, 0));
313 for (
int i = 0; i <
X11->pattern_fill_count; ++i) {
314 if (
X11->pattern_fills[i].screen == screen
315 &&
X11->pattern_fills[i].opaque ==
false 316 &&
X11->pattern_fills[i].style == b.
style()
317 &&
X11->pattern_fills[i].color.alpha == color.alpha
318 &&
X11->pattern_fills[i].color.red == color.red
319 &&
X11->pattern_fills[i].color.green == color.green
320 &&
X11->pattern_fills[i].color.blue == color.blue
321 &&
X11->pattern_fills[i].bg_color.alpha == bg_color.alpha
322 &&
X11->pattern_fills[i].bg_color.red == bg_color.red
323 &&
X11->pattern_fills[i].bg_color.green == bg_color.green
324 &&
X11->pattern_fills[i].bg_color.blue == bg_color.blue)
325 return X11->pattern_fills[i].picture;
328 int i =
qrand() % 16;
330 if (
X11->pattern_fills[i].screen != screen &&
X11->pattern_fills[i].picture) {
331 XRenderFreePicture (
X11->display,
X11->pattern_fills[i].picture);
332 X11->pattern_fills[i].picture = 0;
335 if (!
X11->pattern_fills[i].picture) {
336 Pixmap pixmap = XCreatePixmap (
X11->display, RootWindow (
X11->display, screen), 8, 8, 32);
337 XRenderPictureAttributes attrs;
339 X11->pattern_fills[i].picture = XRenderCreatePicture (
X11->display, pixmap,
340 XRenderFindStandardFormat(
X11->display, PictStandardARGB32),
342 XFreePixmap (
X11->display, pixmap);
345 X11->pattern_fills[i].screen = screen;
346 X11->pattern_fills[i].color = color;
347 X11->pattern_fills[i].bg_color = bg_color;
348 X11->pattern_fills[i].opaque =
false;
349 X11->pattern_fills[i].style = b.
style();
351 XRenderFillRectangle(
X11->display, PictOpSrc,
X11->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8);
354 XRenderPictureAttributes attrs;
356 XRenderChangePicture(
X11->display, pattern.x11PictureHandle(), CPRepeat, &attrs);
359 XRenderComposite(
X11->display, PictOpOver, fill_fg, pattern.x11PictureHandle(),
360 X11->pattern_fills[i].picture,
361 0, 0, 0, 0, 0, 0, 8, 8);
363 return X11->pattern_fills[i].picture;
367 int sx,
int sy,
int x,
int y,
int sw,
int sh,
371 XRenderComposite(dpy, PictOpOver,
372 fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh);
383 #ifndef QT_NO_XRENDER 385 composition_mode = PictOpOver;
392 if (adapted_pen_origin)
393 XSetTSOrigin(dpy, gc, p.
x(), p.
y());
394 if (adapted_brush_origin)
395 XSetTSOrigin(dpy, gc_brush, p.
x(), p.
y());
400 if (adapted_pen_origin)
401 XSetTSOrigin(dpy, gc, 0, 0);
402 if (adapted_brush_origin)
403 XSetTSOrigin(dpy, gc_brush, 0, 0);
408 int clipped_count = 0;
411 &clipped_points, &clipped_count);
412 clipped_poly->
resize(clipped_count);
413 for (
int i=0; i<clipped_count; ++i)
414 (*clipped_poly)[i] = *((
QPointF *)(&clipped_points[i]));
423 q->updateMatrix(q->state->transform());
426 clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
435 QPaintEngine::PaintEngineFeatures features =
442 if (
X11->use_xrender) {
447 if (
X11->xrender_version > 10) {
475 #ifndef QT_NO_XRENDER 477 delete d->tessellator;
487 #ifndef QT_NO_XRENDER 498 d->picture = (
::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
506 d->dpy =
d->xinfo->display();
507 d->scrn =
d->xinfo->screen();
510 d->gc = XCreateGC(
d->dpy,
d->hd, 0, 0);
511 d->gc_brush = XCreateGC(
d->dpy,
d->hd, 0, 0);
512 d->has_alpha_brush =
false;
513 d->has_alpha_pen =
false;
514 d->has_clipping =
false;
515 d->has_complex_xform =
false;
516 d->has_scaling_xform =
false;
517 d->has_non_scaling_xform =
true;
519 d->has_custom_pen =
false;
521 d->pdev_depth =
d->pdev->depth();
524 d->use_path_fallback =
false;
525 #if !defined(QT_NO_XRENDER) 526 d->composition_mode = PictOpOver;
528 d->xlibMaxLinePoints = 32762;
534 const int BUFFERZONE = 1000;
535 QRect devClipRect(-BUFFERZONE, -BUFFERZONE,
536 pdev->
width() + 2*BUFFERZONE, pdev->
height() + 2*BUFFERZONE);
537 d->polygonClipper.setBoundingRect(devClipRect);
551 QPixmap::x11SetDefaultScreen(
d->xinfo->screen());
556 XSetSubwindowMode(
d->dpy,
d->gc, IncludeInferiors);
557 XSetSubwindowMode(
d->dpy,
d->gc_brush, IncludeInferiors);
558 #ifndef QT_NO_XRENDER 559 XRenderPictureAttributes attrs;
560 attrs.subwindow_mode = IncludeInferiors;
561 XRenderChangePicture(
d->dpy,
d->picture, CPSubwindowMode, &attrs);
577 #if !defined(QT_NO_XRENDER) 580 XRenderPictureAttributes attrs;
581 attrs.subwindow_mode = ClipByChildren;
582 attrs.clip_mask =
XNone;
583 XRenderChangePicture(
d->dpy,
d->picture, CPClipMask|CPSubwindowMode, &attrs);
587 if (
d->gc_brush &&
d->pdev->painters < 2) {
588 XFreeGC(
d->dpy,
d->gc_brush);
592 if (
d->gc &&
d->pdev->painters < 2) {
593 XFreeGC(
d->dpy,
d->gc);
620 | ((y1 < top) <<
Top)
621 | ((y1 > bottom) << Bottom);
624 | ((y2 < top) <<
Top)
625 | ((y2 > bottom) << Bottom);
637 y1 += dy/dx * (left - x1);
639 }
else if (x1 > right) {
640 y1 -= dy/dx * (x1 -
right);
644 y2 += dy/dx * (left - x2);
646 }
else if (x2 > right) {
647 y2 -= dy/dx * (x2 -
right);
650 p1 = ((y1 < top) <<
Top)
651 | ((y1 > bottom) << Bottom);
652 p2 = ((y2 < top) <<
Top)
653 | ((y2 > bottom) << Bottom);
658 x1 += dx/dy * (top - y1);
660 }
else if (y1 > bottom) {
661 x1 -= dx/dy * (y1 - bottom);
665 x2 += dx/dy * (top - y2);
667 }
else if (y2 > bottom) {
668 x2 -= dx/dy * (y2 - bottom);
681 if (
d->has_alpha_brush
684 || (
d->cpen.widthF() > 0 &&
d->has_complex_xform
685 && !
d->has_non_scaling_xform)
687 for (
int i = 0; i < lineCount; ++i) {
689 path.
lineTo(lines[i].p2());
696 for (
int i = 0; i < lineCount; ++i) {
701 linef =
d->matrix.map(
QLineF(lines[i]));
703 if (
clipLine(&linef,
d->polygonClipper.boundingRect())) {
709 XDrawLine(
d->dpy,
d->hd,
d->gc, x1, y1, x2, y2);
720 if (
d->has_alpha_brush
723 || (
d->cpen.widthF() > 0 &&
d->has_complex_xform
724 && !
d->has_non_scaling_xform)
726 for (
int i = 0; i < lineCount; ++i) {
728 path.
lineTo(lines[i].p2());
735 for (
int i = 0; i < lineCount; ++i) {
736 QLineF linef =
d->matrix.map(lines[i]);
737 if (
clipLine(&linef,
d->polygonClipper.boundingRect())) {
743 XDrawLine(
d->dpy,
d->hd,
d->gc, x1, y1, x2, y2);
751 if (l.
p1().
x() == l.
p2().
x()) {
756 return QLine(x, y1, x, y2);
764 return QLine(x1, y, x2, y);
776 ||
d->has_alpha_brush
777 ||
d->has_complex_xform
780 #if !defined(QT_NO_XRENDER) 791 QPointF offset(
d->matrix.dx(),
d->matrix.dy());
792 alignedOffset = offset.toPoint();
793 if (offset !=
QPointF(alignedOffset)) {
799 const QRectF& r = rects[0];
801 if (r !=
QRectF(alignedRect)) {
807 QRect clip(
d->polygonClipper.boundingRect());
809 if (alignedRect.isEmpty())
818 xrect.
x = short(alignedRect.x());
819 xrect.y = short(alignedRect.y());
820 xrect.width =
ushort(alignedRect.width());
821 xrect.height =
ushort(alignedRect.height());
822 XFillRectangles(
d->dpy,
d->hd,
d->gc_brush, &xrect, 1);
832 ||
d->has_complex_xform
836 for (
int i = 0; i < rectCount; ++i) {
844 QRect clip(
d->polygonClipper.boundingRect());
846 #if !defined(QT_NO_XRENDER) 849 if (
X11->use_xrender && pict &&
d->has_brush &&
d->pdev_depth != 1
850 && (
d->has_texture ||
d->has_alpha_brush ||
complexPictOp(
d->composition_mode)))
853 if (!
d->has_texture && !
d->has_pattern)
854 xc =
X11->preMultiply(
d->cbrush.color());
856 for (
int i = 0; i < rectCount; ++i) {
864 XDrawLine(
d->dpy,
d->hd,
d->gc, l.
p1().
x(), l.
p1().
y(), l.
p2().
x(), l.
p2().
y());
872 if (
d->has_texture ||
d->has_pattern) {
873 XRenderComposite(
d->dpy,
d->composition_mode,
d->current_brush, 0, pict,
877 XRenderFillRectangle(
d->dpy,
d->composition_mode, pict, &xc, r.
x(), r.
y(), r.
width(), r.
height());
883 #endif // !QT_NO_XRENDER 885 if (
d->has_brush &&
d->has_pen) {
886 for (
int i = 0; i < rectCount; ++i) {
893 XDrawLine(
d->dpy,
d->hd,
d->gc, l.
p1().
x(), l.
p1().
y(), l.
p2().
x(), l.
p2().
y());
901 XFillRectangle(
d->dpy,
d->hd,
d->gc_brush, r.
x(), r.
y(), r.
width(), r.
height());
904 d->resetAdaptedOrigin();
907 int numClipped = rectCount;
908 for (
int i = 0; i < rectCount; ++i) {
917 XDrawLine(
d->dpy,
d->hd,
d->gc, l.
p1().
x(), l.
p1().
y(), l.
p2().
x(), l.
p2().
y());
927 xrects[i].x = short(r.
x());
928 xrects[i].y = short(r.
y());
933 d->setupAdaptedOrigin(rects[0].topLeft());
935 XFillRectangles(
d->dpy,
d->hd,
d->gc_brush, xrects.
data(), numClipped);
937 XDrawRectangles(
d->dpy,
d->hd,
d->gc, xrects.
data(), numClipped);
938 d->resetAdaptedOrigin();
946 ulong mask = GCCapStyle;
948 vals.cap_style = cap_style;
949 XChangeGC(
X11->display, gc, mask, &vals);
963 if (
d->cpen.widthF() > 1.0f
973 while (points < end) {
976 path.
lineTo(points->
x()+.005, points->
y());
983 d->cpen.setCapStyle(capStyle);
991 while (i < pointCount) {
992 while (i < pointCount && j < BUF_SIZE) {
993 const QPoint &xformed =
d->matrix.map(points[i]);
996 if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
1004 XDrawPoints(
d->dpy,
d->hd,
d->gc, xPoints, j, CoordModeOrigin);
1021 if (
d->cpen.widthF() > 1.0f
1032 while (points < end) {
1035 path.
lineTo(points->
x() + 0.005, points->
y());
1041 d->cpen.setCapStyle(capStyle);
1049 while (i < pointCount) {
1050 while (i < pointCount && j < BUF_SIZE) {
1051 const QPointF &xformed =
d->matrix.map(points[i]);
1055 if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
1063 XDrawPoints(
d->dpy,
d->hd,
d->gc, xPoints, j, CoordModeOrigin);
1071 #if !defined(QT_NO_XRENDER) 1072 if (
X11->use_xrender)
1081 QPaintEngine::DirtyFlags flags = state.
state();
1100 d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1110 d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1118 d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1123 int function = GXcopy;
1145 function = GXcopyInverted;
1148 function = GXandReverse;
1151 function = GXandInverted;
1157 #if !defined(QT_NO_XRENDER) 1159 d->composition_mode =
1163 XSetFunction(
X11->display,
d->gc,
function);
1164 XSetFunction(
X11->display,
d->gc_brush,
function);
1166 d->decidePathFallback();
1167 d->decideCoordAdjust();
1173 d->render_hints = hints;
1175 #if !defined(QT_NO_XRENDER) 1176 if (
X11->use_xrender &&
d->picture) {
1177 XRenderPictureAttributes attrs;
1179 XRenderChangePicture(
d->dpy,
d->picture, CPPolyEdge, &attrs);
1190 int ps = pen.
style();
1192 if (
d->opacity < 1.0) {
1195 d->cpen.setColor(c);
1226 d->adapted_pen_origin =
false;
1230 int xStyle = LineSolid;
1238 int scale =
qRound(pen_width < 1 ? 1 : pen_width);
1239 int space = (pen_width < 1 && pen_width > 0 ? 1 : (2 * scale));
1240 int dot = 1 * scale;
1241 int dash = 4 * scale;
1243 d->has_custom_pen =
false;
1254 xStyle = LineOnOffDash;
1260 xStyle = LineOnOffDash;
1268 xStyle = LineOnOffDash;
1278 xStyle = LineOnOffDash;
1281 d->has_custom_pen =
true;
1285 ulong mask = GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth
1286 | GCCapStyle | GCJoinStyle | GCLineStyle;
1288 vals.graphics_exposures =
false;
1289 if (
d->pdev_depth == 1) {
1293 &&
X11->use_xrender) {
1304 vals.cap_style = cp;
1305 vals.join_style = jn;
1306 vals.line_style = xStyle;
1308 XChangeGC(
d->dpy,
d->gc, mask, &vals);
1311 XSetDashes(
d->dpy,
d->gc, 0, dashes, dash_len);
1314 if (!
d->has_clipping) {
1327 d->bg_origin = origin;
1328 d->adapted_brush_origin =
false;
1329 #if !defined(QT_NO_XRENDER) 1330 d->current_brush = 0;
1332 if (
d->opacity < 1.0) {
1335 d->cbrush.setColor(c);
1339 int bs =
d->cbrush.style();
1343 d->has_alpha_brush = brush.
color().
alpha() != 255;
1344 d->has_alpha_texture =
d->has_texture &&
d->cbrush.texture().hasAlphaChannel();
1346 ulong mask = GCForeground | GCBackground | GCGraphicsExposures
1347 | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle;
1349 vals.graphics_exposures =
false;
1350 if (
d->pdev_depth == 1) {
1351 vals.foreground =
qGray(
d->cbrush.color().rgb()) > 127 ? 0 : 1;
1354 &&
d->pdev_depth == 32) {
1355 vals.foreground =
d->cbrush.color().rgba();
1359 vals.foreground = cmap.
pixel(
d->cbrush.color());
1362 if (!
X11->use_xrender &&
d->has_brush && !
d->has_pattern && !brush.
isOpaque()) {
1365 vals.stipple = pattern.
handle();
1367 d->adapted_brush_origin =
true;
1370 vals.cap_style = CapButt;
1371 vals.join_style = JoinMiter;
1372 vals.line_style = LineSolid;
1374 if (
d->has_pattern ||
d->has_texture) {
1377 #if !defined(QT_NO_XRENDER) 1378 if (
X11->use_xrender) {
1379 XRenderPictureAttributes attrs;
1380 attrs.repeat =
true;
1381 XRenderChangePicture(
d->dpy,
d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
1383 if (data->mask_picture)
1384 XRenderChangePicture(
d->dpy, data->mask_picture, CPRepeat, &attrs);
1390 d->brush_pm.x11SetScreen(
d->scrn);
1391 if (
d->brush_pm.depth() == 1) {
1393 vals.stipple =
d->brush_pm.handle();
1395 #if !defined(QT_NO_XRENDER) 1396 if (
X11->use_xrender) {
1397 d->bitmap_texture =
QPixmap(
d->brush_pm.size());
1400 d->bitmap_texture.x11SetScreen(
d->scrn);
1403 XRenderComposite(
d->dpy, PictOpSrc, src,
d->brush_pm.x11PictureHandle(),
1404 d->bitmap_texture.x11PictureHandle(),
1405 0, 0,
d->brush_pm.width(),
d->brush_pm.height(),
1406 0, 0,
d->brush_pm.width(),
d->brush_pm.height());
1408 XRenderPictureAttributes attrs;
1409 attrs.repeat =
true;
1410 XRenderChangePicture(
d->dpy,
d->bitmap_texture.x11PictureHandle(), CPRepeat, &attrs);
1412 d->current_brush =
d->bitmap_texture.x11PictureHandle();
1417 #ifndef QT_NO_XRENDER 1418 if (
d->pdev_depth == 32 &&
d->brush_pm.depth() != 32) {
1419 d->brush_pm.detach();
1424 vals.tile = (
d->brush_pm.depth() ==
d->pdev_depth
1425 ?
d->brush_pm.handle()
1426 :
static_cast<QX11PixmapData*
>(
d->brush_pm.data.data())->x11ConvertToDefaultDepth());
1428 #if !defined(QT_NO_XRENDER) 1429 d->current_brush =
d->cbrush.texture().x11PictureHandle();
1433 mask |= GCTileStipXOrigin | GCTileStipYOrigin;
1434 vals.ts_x_origin =
qRound(origin.
x());
1435 vals.ts_y_origin =
qRound(origin.
y());
1437 #if !defined(QT_NO_XRENDER) 1438 else if (
d->has_alpha_brush) {
1439 d->current_brush =
X11->getSolidFill(
d->scrn,
d->cbrush.color());
1443 vals.fill_style = s;
1444 XChangeGC(
d->dpy,
d->gc_brush, mask, &vals);
1445 if (!
d->has_clipping) {
1457 if (aligned == rect)
1471 QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1);
1474 r =
d->matrix.mapRect(rect);
1478 r =
d->matrix.map(path).boundingRect().toRect();
1483 || (
d->has_complex_xform
1484 && !(
d->has_non_scaling_xform && rect.
width() == rect.
height())))
1498 if (w == 1 && h == 1) {
1499 XDrawPoint(
d->dpy,
d->hd,
d->has_pen ?
d->gc :
d->gc_brush, x, y);
1502 d->setupAdaptedOrigin(rect.
topLeft());
1504 XFillArc(
d->dpy,
d->hd,
d->gc_brush, x, y, w, h, 0, 360*64);
1506 XDrawArc(
d->dpy,
d->hd,
d->gc_brush, x, y, w-1, h-1, 0, 360*64);
1509 XDrawArc(
d->dpy,
d->hd,
d->gc, x, y, w, h, 0, 360*64);
1510 d->resetAdaptedOrigin();
1521 QPointF offset(matrix.dx(), matrix.dy());
1527 for (
int i = 0; i < pointCount; ++i) {
1528 translated_points[i] = polygonPoints[i] + offset;
1530 translated_points[i].rx() =
qRound(translated_points[i].x()) + offs;
1531 translated_points[i].ry() =
qRound(translated_points[i].y()) + offs;
1534 fillPolygon_dev(translated_points.
data(), pointCount, gcMode, mode);
1537 #ifndef QT_NO_XRENDER 1542 _Xconst XRenderPictFormat *maskFormat,
1545 const XTrapezoid *traps,
int size)
1547 const int MAX_TRAPS = 50000;
1550 if (to_draw > MAX_TRAPS)
1551 to_draw = MAX_TRAPS;
1552 XRenderCompositeTrapezoids(dpy, op, src, dst,
1568 int clippedCount = 0;
1571 #ifndef QT_NO_XRENDER 1573 bool has_fill_texture = has_texture;
1574 bool has_fill_pattern = has_pattern;
1579 if (gcMode == BrushGC) {
1582 #ifndef QT_NO_XRENDER 1584 src = current_brush;
1586 src =
X11->getSolidFill(scrn, fill.
color());
1589 fill =
QBrush(cpen.brush());
1591 #ifndef QT_NO_XRENDER 1595 if (has_fill_texture)
1596 src = fill.
texture().x11PictureHandle();
1597 else if (has_fill_pattern)
1600 src =
X11->getSolidFill(scrn, fill.
color());
1604 polygonClipper.clipPolygon((
qt_float_point *) polygonPoints, pointCount,
1605 &clippedPoints, &clippedCount);
1607 #ifndef QT_NO_XRENDER 1608 bool solid_fill = fill.
color().
alpha() == 255;
1609 if (has_fill_texture && fill.
texture().
depth() == 1 && solid_fill) {
1610 has_fill_texture =
false;
1611 has_fill_pattern =
true;
1616 if (
X11->use_xrender
1618 && !has_fill_pattern
1619 && (clippedCount > 0)
1621 && ((has_fill_texture && fill.
texture().
hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush))
1623 tessellator->tessellate((
QPointF *)clippedPoints, clippedCount,
1625 if (tessellator->size > 0) {
1626 XRenderPictureAttributes attrs;
1627 attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
1628 XRenderChangePicture(dpy, picture, CPPolyEdge, &attrs);
1629 int x_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.x) - bg_origin.x());
1630 int y_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.y) - bg_origin.y());
1633 ? XRenderFindStandardFormat(dpy, PictStandardA8)
1634 : XRenderFindStandardFormat(dpy, PictStandardA1),
1636 tessellator->traps, tessellator->size);
1637 tessellator->done();
1642 if (clippedCount > 200000) {
1644 for (
int i = 0; i < clippedCount; ++i)
1648 const QRect aligned = bounds
1658 if (gcMode == BrushGC)
1664 }
else if (clippedCount > 0) {
1666 for (
int i = 0; i < clippedCount; ++i) {
1667 xpoints[i].x =
qFloor(clippedPoints[i].x);
1668 xpoints[i].y =
qFloor(clippedPoints[i].y);
1672 setupAdaptedOrigin(
QPoint(xpoints[0].x, xpoints[0].y));
1673 XFillPolygon(dpy, hd, fill_gc,
1674 xpoints.
data(), clippedCount,
1676 resetAdaptedOrigin();
1686 QPointF offset(matrix.dx(), matrix.dy());
1687 for (
int i = 0; i < pointCount; ++i)
1688 translated_points[i] = polygonPoints[i] + offset;
1689 strokePolygon_dev(translated_points.
data(), pointCount, close);
1694 int clippedCount = 0;
1696 polygonClipper.clipPolygon((
qt_float_point *) polygonPoints, pointCount,
1697 &clippedPoints, &clippedCount, close);
1699 if (clippedCount > 0) {
1701 for (
int i = 0; i < clippedCount; ++i) {
1705 uint numberPoints =
qMin(clippedCount, xlibMaxLinePoints);
1706 XPoint *pts = xpoints.
data();
1707 XDrawLines(dpy, hd, gc, pts, numberPoints, CoordModeOrigin);
1708 pts += numberPoints;
1709 clippedCount -= numberPoints;
1710 numberPoints =
qMin(clippedCount, xlibMaxLinePoints-1);
1711 while (clippedCount) {
1712 XDrawLines(dpy, hd, gc, pts-1, numberPoints+1, CoordModeOrigin);
1713 pts += numberPoints;
1714 clippedCount -= numberPoints;
1715 numberPoints =
qMin(clippedCount, xlibMaxLinePoints-1);
1723 if (
d->use_path_fallback) {
1725 for (
int i = 1; i < pointCount; ++i)
1726 path.
lineTo(polygonPoints[i]);
1732 d->cbrush = oldBrush;
1744 d->strokePolygon_translated(polygonPoints, pointCount, mode !=
PolylineMode);
1754 clipPath.
addRect(polygonClipper.boundingRect());
1757 clippedPath = (path*matrix).intersected(clipPath);
1762 for (
int i = 0; i < polys.
size(); ++i) {
1765 for (
int j = 0; j < polys.
at(i).
size(); ++j) {
1766 translated_points[j] = polys.
at(i).
at(j);
1773 fillPolygon_dev(translated_points.data(), polys.
at(i).
size(), gc_mode,
1789 && !
d->has_non_scaling_xform)
1801 qreal width =
d->cpen.widthF();
1803 QRectF deviceRect(0, 0,
d->pdev->width(),
d->pdev->height());
1805 if (
d->cpen.isCosmetic() ||
d->has_scaling_xform) {
1806 if (
d->cpen.isCosmetic())
1807 stroker.
setWidth(width == 0 ? 1 : width);
1809 stroker.
setWidth(width *
d->xform_scale);
1825 }
else if (
d->has_pen) {
1828 for (
int i = 0; i < polys.
size(); ++i)
1829 d->strokePolygon_dev(polys.
at(i).
data(), polys.
at(i).
size(),
false);
1834 Drawable hd,
GC gc,
Display *dpy, Visual *visual,
int depth)
1841 const uint red_mask = (
uint) visual->red_mask;
1842 bool bgr_layout = (red_mask == 0xff);
1844 const int w = rect.
width();
1845 const int h = rect.
height();
1848 int image_byte_order = ImageByteOrder(
X11->display);
1849 if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
1850 || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
1851 || (image_byte_order == LSBFirst && bgr_layout))
1853 im = image.
copy(rect);
1856 for (
int i=0; i < h; i++) {
1859 if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
1861 *p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
1864 }
else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
1865 || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
1867 *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
1868 | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
1871 }
else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
1872 || (image_byte_order == LSBFirst && bgr_layout))
1875 *p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
1876 | ((*p ) & 0xff00ff00);
1882 xi = XCreateImage(dpy, visual, depth, ZPixmap,
1885 xi = XCreateImage(dpy, visual, depth, ZPixmap,
1888 XPutImage(dpy, hd, gc, xi, 0, 0, pos.
x(), pos.
y(), w, h);
1898 &&
d->pdev_depth >= 24 && image.
depth() == 32
1908 qt_x11_drawImage(
QRect(sx, sy, w, h),
QPoint(x, y), image,
d->hd,
d->gc,
d->dpy,
1909 (Visual *)
d->xinfo->visual(),
d->pdev_depth);
1930 if ((
d->xinfo &&
d->xinfo->screen() != pixmap.x11Info().screen())
1931 || (pixmap.x11Info().screen() != DefaultScreen(
X11->display))) {
1933 p->x11SetScreen(
d->xinfo ?
d->xinfo->screen() : DefaultScreen(
X11->display));
1936 QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
1938 #ifndef QT_NO_XRENDER 1940 if (src_pict &&
d->picture) {
1941 const int pDepth = pixmap.
depth();
1942 if (pDepth == 1 && (
d->has_alpha_pen)) {
1944 sx, sy, x, y, sw, sh,
d->cpen);
1946 }
else if (pDepth != 1 && (pDepth == 32 || pDepth !=
d->pdev_depth)) {
1947 XRenderComposite(
d->dpy,
d->composition_mode,
1948 src_pict, 0,
d->picture, sx, sy, 0, 0, x, y, sw, sh);
1954 bool mono_src = pixmap.depth() == 1;
1955 bool mono_dst =
d->pdev_depth == 1;
1956 bool restore_clip =
false;
1958 if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
1960 GC cgc = XCreateGC(
d->dpy, comb.
handle(), 0, 0);
1961 XSetForeground(
d->dpy, cgc, 0);
1962 XFillRectangle(
d->dpy, comb.
handle(), cgc, 0, 0, sw, sh);
1963 XSetBackground(
d->dpy, cgc, 0);
1964 XSetForeground(
d->dpy, cgc, 1);
1965 if (!
d->crgn.isEmpty()) {
1968 XSetClipRectangles(
d->dpy, cgc, -x, -y, rects, num, Unsorted);
1969 }
else if (
d->has_clipping) {
1970 XSetClipRectangles(
d->dpy, cgc, 0, 0, 0, 0, Unsorted);
1972 XSetFillStyle(
d->dpy, cgc, FillOpaqueStippled);
1973 XSetTSOrigin(
d->dpy, cgc, -sx, -sy);
1974 XSetStipple(
d->dpy, cgc,
1975 static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask);
1976 XFillRectangle(
d->dpy, comb.
handle(), cgc, 0, 0, sw, sh);
1977 XFreeGC(
d->dpy, cgc);
1979 XSetClipOrigin(
d->dpy,
d->gc, x, y);
1980 XSetClipMask(
d->dpy,
d->gc, comb.
handle());
1981 restore_clip =
true;
1985 if (!
d->crgn.isEmpty()) {
1986 Pixmap comb = XCreatePixmap(
d->dpy,
d->hd, sw, sh, 1);
1987 GC cgc = XCreateGC(
d->dpy, comb, 0, 0);
1988 XSetForeground(
d->dpy, cgc, 0);
1989 XFillRectangle(
d->dpy, comb, cgc, 0, 0, sw, sh);
1992 XSetClipRectangles(
d->dpy, cgc, -x, -y, rects, num, Unsorted);
1993 XCopyArea(
d->dpy, pixmap.handle(), comb, cgc, sx, sy, sw, sh, 0, 0);
1994 XFreeGC(
d->dpy, cgc);
1996 XSetClipMask(
d->dpy,
d->gc, comb);
1997 XSetClipOrigin(
d->dpy,
d->gc, x, y);
1998 XFreePixmap(
d->dpy, comb);
2000 XSetClipMask(
d->dpy,
d->gc, pixmap.handle());
2001 XSetClipOrigin(
d->dpy,
d->gc, x - sx, y - sy);
2005 XSetForeground(
d->dpy,
d->gc,
qGray(
d->cpen.color().rgb()) > 127 ? 0 : 1);
2008 XSetForeground(
d->dpy,
d->gc, cmap.
pixel(
d->cpen.color()));
2010 XFillRectangle(
d->dpy,
d->hd,
d->gc, x, y, sw, sh);
2011 restore_clip =
true;
2012 }
else if (mono_dst && !mono_src) {
2014 XCopyArea(
d->dpy, bitmap.
handle(),
d->hd,
d->gc, sx, sy, sw, sh, x, y);
2016 XCopyArea(
d->dpy, pixmap.handle(),
d->hd,
d->gc, sx, sy, sw, sh, x, y);
2021 Pixmap src_mask =
static_cast<QX11PixmapData*
>(pixmap.data.data())->x11_mask;
2024 GC cgc = XCreateGC(
d->dpy, dst_mask, 0, 0);
2026 XCopyArea(
d->dpy, src_mask, dst_mask, cgc, sx, sy, sw, sh, x, y);
2028 XSetBackground(
d->dpy, cgc, 0);
2029 XSetForeground(
d->dpy, cgc, 1);
2030 XFillRectangle(
d->dpy, dst_mask, cgc, x, y, sw, sh);
2032 XFreeGC(
d->dpy, cgc);
2037 XSetClipOrigin(
d->dpy,
d->gc, 0, 0);
2041 XSetClipMask(
d->dpy,
d->gc,
XNone);
2043 XSetClipRectangles(
d->dpy,
d->gc, 0, 0, rects, num, Unsorted);
2050 d->txop = mtx.
type();
2057 d->has_scaling_xform = scaling &&
d->xform_scale != 1.0;
2058 d->has_non_scaling_xform = scaling &&
d->xform_scale == 1.0;
2069 d->has_clipping =
false;
2081 if (
d->has_clipping) {
2082 d->crgn &= clipRegion;
2090 d->crgn = clipRegion;
2093 d->crgn |= clipRegion;
2095 d->crgn =
d->crgn.intersected(sysClip);
2100 d->has_clipping =
true;
2128 bool mono_src = pixmap.
depth() == 1;
2131 if ((
d->xinfo &&
d->xinfo->screen() != pixmap.x11Info().screen())
2132 || (pixmap.x11Info().screen() != DefaultScreen(
X11->display))) {
2134 p->x11SetScreen(
d->xinfo ?
d->xinfo->screen() : DefaultScreen(
X11->display));
2137 QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
2139 #ifndef QT_NO_XRENDER 2140 if (
X11->use_xrender &&
d->picture && pixmap.x11PictureHandle()) {
2143 XRenderPictureAttributes attrs;
2144 attrs.repeat =
true;
2145 XRenderChangePicture(
d->dpy, pixmap.x11PictureHandle(), CPRepeat, &attrs);
2149 sx, sy, x, y, w, h,
d->cpen);
2151 XRenderComposite(
d->dpy,
d->composition_mode,
2152 pixmap.x11PictureHandle(),
XNone,
d->picture,
2153 sx, sy, 0, 0, x, y, w, h);
2156 const int numTiles = (w / pixmap.
width()) * (h / pixmap.
height());
2157 if (numTiles < 100) {
2160 int yPos, xPos, drawH, drawW, yOff, xOff;
2163 while(yPos < y + h) {
2164 drawH = pixmap.
height() - yOff;
2165 if (yPos + drawH > y + h)
2166 drawH = y + h - yPos;
2169 while(xPos < x + w) {
2170 drawW = pixmap.
width() - xOff;
2171 if (xPos + drawW > x + w)
2172 drawW = x + w - xPos;
2175 xOff, yOff, xPos, yPos, drawW, drawH,
d->cpen);
2177 XRenderComposite(
d->dpy,
d->composition_mode,
2178 pixmap.x11PictureHandle(),
XNone,
d->picture,
2179 xOff, yOff, 0, 0, xPos, yPos, drawW, drawH);
2188 w =
qMin(w,
d->pdev->width() - x);
2189 h =
qMin(h,
d->pdev->height() - y);
2190 if (w <= 0 || h <= 0)
2193 const int pw = w + sx;
2194 const int ph = h + sy;
2199 const int mode = pixmap.
hasAlpha() ? PictOpOver : PictOpSrc;
2203 XRenderComposite(
d->dpy, mode,
2204 pixmap.x11PictureHandle(),
XNone, pmPicture,
2208 int xPos = pixmap.
width();
2211 const int sw =
qMin(xPos, pw - xPos);
2212 XRenderComposite(
d->dpy, mode,
2213 pmPicture,
XNone, pmPicture,
2214 0, 0, 0, 0, xPos, 0, sw, sh);
2219 int yPos = pixmap.
height();
2222 const int sh =
qMin(yPos, ph - yPos);
2223 XRenderComposite(
d->dpy, mode,
2224 pmPicture,
XNone, pmPicture,
2225 0, 0, 0, 0, 0, yPos, sw, sh);
2232 sx, sy, x, y, w, h,
d->cpen);
2234 XRenderComposite(
d->dpy,
d->composition_mode,
2235 pmPicture,
XNone,
d->picture,
2236 sx, sy, 0, 0, x, y, w, h);
2240 #endif // !QT_NO_XRENDER 2242 XSetTile(
d->dpy,
d->gc, pixmap.
handle());
2243 XSetFillStyle(
d->dpy,
d->gc, FillTiled);
2244 XSetTSOrigin(
d->dpy,
d->gc, x-sx, y-sy);
2245 XFillRectangle(
d->dpy,
d->hd,
d->gc, x, y, w, h);
2246 XSetTSOrigin(
d->dpy,
d->gc, 0, 0);
2247 XSetFillStyle(
d->dpy,
d->gc, FillSolid);
2260 d_func()->drawBoxTextItem(p, ti);
2265 #ifndef QT_NO_FONTCONFIG 2293 if (glyphs.
size() == 0)
2299 XSetFont(
d->dpy,
d->gc, font_id);
2302 for (
int i = 0; i < glyphs.
size(); i++) {
2303 int xp =
qRound(positions[i].x + offs);
2304 int yp =
qRound(positions[i].y + offs);
2305 if (xp < SHRT_MAX && xp > SHRT_MIN && yp > SHRT_MIN && yp < SHRT_MAX) {
2307 ch.byte1 = glyphs[i] >> 8;
2308 ch.byte2 = glyphs[i] & 0xff;
2309 XDrawString16(
d->dpy,
d->hd,
d->gc, xp, yp, &ch, 1);
2314 #ifndef QT_NO_FONTCONFIG 2323 while (i < glyphs.
size()) {
2332 int xp =
qRound(positions[i].x);
2333 int yp =
qRound(positions[i].y);
2336 yp += -glyph->
y + glyph->
height;
2337 int pitch = ((glyph->
width + 31) & ~31) >> 3;
2341 for (
int x = 0; x < glyph->
width; ++x) {
2342 bool set = src[x >> 3] & (0x80 >> (x & 7));
2344 QRect r(xp + x, yp - h, 1, 1);
2345 while (x+1 < glyph->
width && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
2370 if (!
d->cpen.isSolid()) {
2375 const bool xrenderPath = (
X11->use_xrender
2387 if (glyphs.
count() == 0)
2390 #ifndef QT_NO_XRENDER 2395 if (!
set ||
set->outline_drawing
2403 GlyphSet glyphSet =
set->id;
2404 const QColor &pen =
d->cpen.color();
2406 XRenderPictFormat *maskFormat = 0;
2410 enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
2413 for (; i < glyphs.
size()
2414 && (positions[i].x < t_min || positions[i].x > t_max
2415 || positions[i].y < t_min || positions[i].y > t_max);
2419 if (i >= glyphs.
size())
2423 QFixed xp = positions[i - 1].x;
2424 QFixed yp = positions[i - 1].y;
2428 elt.glyphset = glyphSet;
2429 elt.chars = &glyphs[i - 1];
2431 elt.xOff =
qRound(xp + offs);
2432 elt.yOff =
qRound(yp + offs);
2433 for (; i < glyphs.
size(); ++i) {
2434 if (positions[i].x < t_min || positions[i].x > t_max
2435 || positions[i].y < t_min || positions[i].y > t_max) {
2440 && positions[i].x == xp + g->
advance 2441 && positions[i].y == yp
2448 xp = positions[i].x;
2449 yp = positions[i].y;
2451 XRenderCompositeText32(
X11->display, PictOpOver, src,
d->picture,
2452 maskFormat, 0, 0, 0, 0,
2454 elt.chars = &glyphs[i];
2456 elt.xOff =
qRound(xp + offs);
2457 elt.yOff =
qRound(yp + offs);
2460 XRenderCompositeText32(
X11->display, PictOpOver, src,
d->picture,
2461 maskFormat, 0, 0, 0, 0,
2482 const int rectcount = 256;
2483 XRectangle rects[rectcount];
2487 QRect clip(
d->polygonClipper.boundingRect());
2494 QRect rect =
QRect(x + delta.
x(), y + delta.
y(), w, h);
2499 rects[num_rects].
x = short(rect.
x());
2500 rects[num_rects].y = short(rect.
y());
2504 if (num_rects == rectcount) {
2505 XFillRectangles(
d->dpy,
d->hd,
d->gc, rects, num_rects);
2510 XFillRectangles(
d->dpy,
d->hd,
d->gc, rects, num_rects);
2513 #endif // !QT_NO_XRENDER QPainterPath clipPath() const
Returns the currently clip as a path.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
void setDashOffset(qreal offset)
Sets the dash offset for the generated outlines to offset.
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
void clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly)
static Picture getPatternFill(int screen, const QBrush &b)
void updateMatrix(const QTransform &matrix)
#define Q27Dot5ToXFixed(i)
const T * constData() const
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
void setClipRect(const QRectF &clip)
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
static QColormap instance(int screen=-1)
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
void drawImage(const QRectF &r, const QImage &img, 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...
The QLatin1Literal class provides a thin wrapper around string literals used in source code...
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
QRegion intersected(const QRegion &r) const
Returns a region which is the intersection of this region and r.
virtual 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...
qreal opacity() const
Returns the opacity in the current paint engine state.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
int width() const
Returns the width of the pixmap.
CompositionMode
Defines the modes supported for digital image compositing.
The QLine class provides a two-dimensional vector using integer precision.
static int qpainterOpToXrender(QPainter::CompositionMode mode)
The QFlag class is a helper data type for QFlags.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
QPoint p1() const
Returns the line's start point.
QRect tessellate(const QPointF *points, int nPoints, bool winding)
static void qt_XRenderCompositeTrapezoids(Display *dpy, int op, Picture src, Picture dst, _Xconst XRenderPictFormat *maskFormat, int xSrc, int ySrc, const XTrapezoid *traps, int size)
QPaintEngineState * state
qreal x2() const
Returns the x-coordinate of the line's end point.
Qt::PenStyle style() const
Returns the pen style.
QExplicitlySharedDataPointer< QPixmapData > data
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
QPoint p2() const
Returns the line's end point.
void fill(uint pixel)
Fills the entire image with the given pixelValue.
QTransform transform() const
Returns the matrix in the current paint engine state.
qreal y2() const
Returns the y-coordinate of the line's end point.
void qt_draw_tile(QPaintEngine *, qreal, qreal, qreal, qreal, const QPixmap &, qreal, qreal)
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
The QPointF class defines a point in the plane using floating point precision.
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
void updateRenderHints(QPainter::RenderHints hints)
const Vertex * bottomLeft
void fillPolygon_dev(const QPointF *points, int pointCount, GCMode gcMode, QPaintEngine::PolygonDrawMode mode)
void restore()
Restores the current painter state (pops a saved state off the stack).
QPainterPath intersected(const QPainterPath &r) const
Returns a path which is the intersection of this path's fill area and p's fill area.
QRectF tessellate(const QPointF *points, int nPoints)
static bool complexPictOp(int op)
void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
int left() const
Returns the x-coordinate of the rectangle's left edge.
QColor color() const
Returns the color of this pen's brush.
int width() const
Returns the width of the rectangle.
static const qreal aliasedCoordinateDelta
Q_GUI_EXPORT void * qt_getClipRects(const QRegion &r, int &num)
static bool clipLine(QLineF *line, const QRect &rect)
Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *p)
Returns the X11 specific brush GC for the painter p.
Qt::HANDLE handle() const
Returns the pixmap's handle to the device context.
void drawPoints(const QPoint *points, int pointCount)
Draws the first pointCount points in the buffer points.
int bytesPerLine() const
Returns the number of bytes per image scanline.
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
The QPolygon class provides a vector of points using integer precision.
int depth() const
Returns the depth of the pixmap.
void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
int height() const
Returns the height of the rectangle.
void updateClipRegion_dev(const QRegion ®ion, Qt::ClipOperation op)
qreal y
the y coordinate of the element's position.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
The QString class provides a Unicode character string.
Q_CORE_EXPORT int qrand()
static QFixed fromReal(qreal r)
void resetAdaptedOrigin()
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setBrushOrigin(int x, int y)
Sets the brush's origin to point (x, y).
virtual Type type() const =0
QPolygon toPolygon() const
Creates and returns a QPolygon by converting each QPointF to a QPoint.
virtual int devType() const
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void strokePolygon_translated(const QPointF *points, int pointCount, bool close)
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *p)
Returns the X11 specific pen GC for the painter p.
Format format() const
Returns the format of the image.
QList< QPolygonF > toFillPolygons(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static QPixmap * find(const QString &key)
qreal x() const
Returns the x-coordinate of this point.
void resize(int size)
Sets the size of the vector to size.
void updatePen(const QPen &pen)
The QLineF class provides a two-dimensional vector using floating point precision.
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
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...
void strokePolygon_dev(const QPointF *points, int pointCount, bool close)
The QBitmap class provides monochrome (1-bit depth) pixmaps.
T * data() const
Returns a pointer to the shared data object.
QPainter * painter() const
Returns the paint engine's painter.
const Q_GUI_EXPORT QX11Info * qt_x11Info(const QPaintDevice *pd)
Returns the QX11Info structure for the pd paint device.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QPixmap qt_toX11Pixmap(const QPixmap &pixmap)
QBrush brush() const
Returns the brush in the current paint engine state.
qreal & rx()
Returns a reference to the x coordinate of this point.
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 fillPolygon_translated(const QPointF *points, int pointCount, GCMode gcMode, QPaintEngine::PolygonDrawMode mode)
void systemStateChanged()
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
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.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
QFont font() const
Returns the font in the current paint engine state.
qreal height() const
Returns the height of the rectangle.
QSize size() const
Returns the size of the rectangle.
const T & at(int i) const
Returns the item at index position i in the list.
virtual Qt::HANDLE handle() const
Drawable qt_x11Handle(const QPaintDevice *pd)
Returns the X11 Drawable of the paint device.
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
qreal y1() const
Returns the y-coordinate of the line's start point.
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
The QPolygonF class provides a vector of points using floating point precision.
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
QGlyphSet * defaultGlyphs()
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.
void convertToARGB32(bool preserveContents=true)
static const char * data(const QByteArray &arr)
QScopedPointer< QPainterPathStrokerPrivate > d_ptr
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
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...
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
The QRegion class specifies a clip region for a painter.
void setDirty(DirtyFlags df)
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
int depth() const
Returns the depth of the image.
Qt::FillRule fillRule() const
Returns the painter path's currently set fill rule.
Qt::BrushStyle style() const
Returns the brush style.
static const uchar base_dither_matrix[DITHER_SIZE][DITHER_SIZE]
const Vertex * bottomRight
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
void drawXLFD(const QPointF &p, const QTextItemInt &si)
bool loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, const QFixedPoint *positions, GlyphFormat format=Format_Render)
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.
static QLine clipStraightLine(const QRect &clip, const QLine &l)
uint pixel(const QColor &color) const
QRect toRect() const
Returns a QRect based on the values of this rectangle.
void fillPath(const QPainterPath &path, GCMode gcmode, bool transform)
const T & at(int i) const
Returns the item at index position i in the vector.
QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
The QBrush class defines the fill pattern of shapes drawn by QPainter.
static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst, int sx, int sy, int x, int y, int sw, int sh, const QPen &pen)
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
uchar * bits()
Returns a pointer to the first pixel data.
bool end()
Reimplement this function to finish painting on the current paint device.
bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
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...
void setPixel(int x, int y, uint index_or_rgb)
Sets the pixel index or color at (x, y) to index_or_rgb.
void setupAdaptedOrigin(const QPoint &p)
int top() const
Returns the y-coordinate of the rectangle's top edge.
The QX11Info class provides information about the X display configuration.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
int right() const
Returns the x-coordinate of the rectangle's right edge.
static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe)
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
void drawFreetype(const QPointF &p, const QTextItemInt &si)
void updateFont(const QFont &font)
ushort alpha
Returns the alpha color component of this color.
The QFont class specifies a font used for drawing text.
static void x11SetClipRegion(Display *dpy, GC gc, GC gc2, Picture picture, const QRegion &r)
int y() const
Returns the y-coordinate of the rectangle's top edge.
bool hasAlpha() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false...
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
Glyph * cachedGlyph(glyph_t g) const
virtual 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...
int x() const
Returns the x-coordinate of the rectangle's left edge.
XFontStruct * fontStruct() const
const QX11Info * qt_x11Info(const QPaintDevice *pd)
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
int size() const
Returns the number of items in the list.
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
FT_Face lockFace(Scaling scale=Scaled) const
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
qreal widthF() const
Returns the pen width with floating point precision.
The QRect class defines a rectangle in the plane using integer precision.
void drawEllipse(const QRect &r)
The default implementation of this function calls the floating point version of this function...
QRect boundingRect() const
Returns the bounding rectangle of the polygon, or QRect(0, 0, 0, 0) if the polygon is empty...
static QPixmap qt_patternForAlpha(uchar alpha, int screen)
QSizeF size() const
Returns the size of the rectangle.
qreal x
the x coordinate of the element's position.
int y() const
Returns the y coordinate of this point.
qreal y() const
Returns the y-coordinate of this point.
void addTrap(const Trapezoid &trap)
The QPixmap class is an off-screen image representation that can be used as a paint device...
QList< QPolygonF > toSubpathPolygons(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion)
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
int height() const
Returns the height of the pixmap.
static QBitmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Returns a copy of the given image converted to a bitmap using the specified image conversion flags...
QGlyphSet * loadTransformedGlyphSet(const QTransform &matrix)
The QPaintEngineState class provides information about the active paint engine's current state...
The QSize class defines the size of a two-dimensional object using integer point precision.
T * data()
Returns a pointer to the data stored in the vector.
int elementCount() const
Returns the number of path elements in the painter path.
static void setCapStyle(int cap_style, GC gc)
int x() const
Returns the x coordinate of this point.
QPen pen() const
Returns the pen in the current paint engine state.
static const int compositionModeToRenderOp[QPainter::CompositionMode_Xor+1]
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
void drawLines(const QLine *lines, int lineCount)
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floa...
static QPainterPath path_for_glyphs(const QVarLengthArray< glyph_t > &glyphs, const QVarLengthArray< QFixedPoint > &positions, const QFontEngineFT *ft)
void updateBrush(const QBrush &brush, const QPointF &pt)
The QTextItem class provides all the information required to draw text in a custom paint engine...
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
qreal x1() const
Returns the x-coordinate of the line's start point.
static qreal dot(const QPointF &a, const QPointF &b)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
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...
Glyph * loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format=Format_None, bool fetchMetricsOnly=false) const
int size() const
Returns the number of items in the vector.
QRgb rgb() const
Returns the RGB value of the color.
Q_DECL_CONSTEXPR int qRound(qreal d)
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
static void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, Picture picture)
The QList class is a template class that provides lists.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
static QPaintEngine::PaintEngineFeatures qt_decide_features()
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
QPainter::RenderHints supportedRenderHints() const