Qt 4.8
Public Functions | Protected Functions | Friends | List of all members
QX11PaintEngine Class Reference

#include <qpaintengine_x11_p.h>

Inheritance diagram for QX11PaintEngine:
QPaintEngine

Public Functions

bool begin (QPaintDevice *pdev)
 Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. More...
 
void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
void drawEllipse (const QRectF &r)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
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 rectangle using the given conversion flags flags, to convert it to a pixmap. More...
 
void drawLines (const QLine *lines, int lineCount)
 The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function. More...
 
void drawLines (const QLineF *lines, int lineCount)
 The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine. More...
 
void drawPath (const QPainterPath &path)
 The default implementation ignores the path and does nothing. More...
 
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. More...
 
void drawPoints (const QPoint *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
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 points, using mode mode. More...
 
void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
void drawRects (const QRect *rects, int rectCount)
 The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function. More...
 
void drawRects (const QRectF *rects, int rectCount)
 Draws the first rectCount rectangles in the buffer rects. More...
 
void drawTextItem (const QPointF &p, const QTextItem &textItem)
 This function draws the text item textItem at position p. More...
 
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. More...
 
bool end ()
 Reimplement this function to finish painting on the current paint device. More...
 
virtual Qt::HANDLE handle () const
 
 QX11PaintEngine ()
 
QPainter::RenderHints supportedRenderHints () const
 
Type type () const
 Reimplement this function to return the paint engine Type. More...
 
void updateBrush (const QBrush &brush, const QPointF &pt)
 
void updateClipRegion_dev (const QRegion &region, Qt::ClipOperation op)
 
void updateFont (const QFont &font)
 
void updateMatrix (const QTransform &matrix)
 
void updatePen (const QPen &pen)
 
void updateRenderHints (QPainter::RenderHints hints)
 
void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
 ~QX11PaintEngine ()
 
- Public Functions inherited from QPaintEngine
void clearDirty (DirtyFlags df)
 
virtual QPoint coordinateOffset () const
 Returns the offset from the painters origo to the engines origo. More...
 
void fix_neg_rect (int *x, int *y, int *w, int *h)
 
virtual HDC getDC () const
 Empty default implementation. More...
 
bool hasFeature (PaintEngineFeatures feature) const
 Returns true if the paint engine supports the specified feature; otherwise returns false. More...
 
bool isActive () const
 Returns true if the paint engine is actively drawing; otherwise returns false. More...
 
bool isExtended () const
 Returns true if the paint engine is a QPaintEngineEx derivative. More...
 
QPaintDevicepaintDevice () const
 Returns the device that this engine is painting on, if painting is active; otherwise returns 0. More...
 
QPainterpainter () const
 Returns the paint engine's painter. More...
 
 QPaintEngine (PaintEngineFeatures features=0)
 Creates a paint engine with the featureset specified by caps. More...
 
virtual void releaseDC (HDC hdc) const
 Empty default implementation. More...
 
void setActive (bool newState)
 Sets the active state of the paint engine to state. More...
 
void setDirty (DirtyFlags df)
 
void setPaintDevice (QPaintDevice *device)
 
void setSystemClip (const QRegion &baseClip)
 Sets the system clip for this engine. More...
 
void setSystemRect (const QRect &rect)
 Sets the target rect for drawing within the backing store. More...
 
void syncState ()
 Updates all dirty states in this engine. More...
 
QRegion systemClip () const
 Returns the system clip. More...
 
QRect systemRect () const
 Retrieves the rect for drawing within the backing store. More...
 
bool testDirty (DirtyFlags df)
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 

Protected Functions

void drawFreetype (const QPointF &p, const QTextItemInt &si)
 
void drawXLFD (const QPointF &p, const QTextItemInt &si)
 
 QX11PaintEngine (QX11PaintEnginePrivate &dptr)
 
- Protected Functions inherited from QPaintEngine
 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 

Friends

class QFontEngineBox
 
class QPixmap
 
Q_GUI_EXPORT GC qt_x11_get_brush_gc (QPainter *)
 Returns the X11 specific brush GC for the painter p. More...
 
Q_GUI_EXPORT GC qt_x11_get_pen_gc (QPainter *)
 Returns the X11 specific pen GC for the painter p. More...
 

Additional Inherited Members

- Public Types inherited from QPaintEngine
enum  DirtyFlag {
  DirtyPen = 0x0001, DirtyBrush = 0x0002, DirtyBrushOrigin = 0x0004, DirtyFont = 0x0008,
  DirtyBackground = 0x0010, DirtyBackgroundMode = 0x0020, DirtyTransform = 0x0040, DirtyClipRegion = 0x0080,
  DirtyClipPath = 0x0100, DirtyHints = 0x0200, DirtyCompositionMode = 0x0400, DirtyClipEnabled = 0x0800,
  DirtyOpacity = 0x1000, AllDirty = 0xffff
}
 QPaintEngine::updateState(). More...
 
enum  PaintEngineFeature {
  PrimitiveTransform = 0x00000001, PatternTransform = 0x00000002, PixmapTransform = 0x00000004, PatternBrush = 0x00000008,
  LinearGradientFill = 0x00000010, RadialGradientFill = 0x00000020, ConicalGradientFill = 0x00000040, AlphaBlend = 0x00000080,
  PorterDuff = 0x00000100, PainterPaths = 0x00000200, Antialiasing = 0x00000400, BrushStroke = 0x00000800,
  ConstantOpacity = 0x00001000, MaskedBrush = 0x00002000, PerspectiveTransform = 0x00004000, BlendModes = 0x00008000,
  ObjectBoundingModeGradients = 0x00010000, RasterOpModes = 0x00020000, PaintOutsidePaintEvent = 0x20000000, AllFeatures = 0xffffffff
}
 This enum is used to describe the features or capabilities that the paint engine has. More...
 
enum  PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
 
enum  Type {
  X11, Windows, QuickDraw, CoreGraphics,
  MacPrinter, QWindowSystem, PostScript, OpenGL,
  Picture, SVG, Raster, Direct3D,
  Pdf, OpenVG, OpenGL2, PaintBuffer,
  Blitter, User = 50, MaxUser = 100
}
 
- Protected Variables inherited from QPaintEngine
uint active: 1
 
QScopedPointer< QPaintEnginePrivated_ptr
 
uint extended: 1
 
PaintEngineFeatures gccaps
 
uint selfDestruct: 1
 
QPaintEngineStatestate
 

Detailed Description

Definition at line 77 of file qpaintengine_x11_p.h.

Constructors and Destructors

◆ QX11PaintEngine() [1/2]

QX11PaintEngine::QX11PaintEngine ( )

Definition at line 461 of file qpaintengine_x11.cpp.

463 {
464  d_func()->init();
465 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
static QPaintEngine::PaintEngineFeatures qt_decide_features()

◆ ~QX11PaintEngine()

QX11PaintEngine::~QX11PaintEngine ( )

Definition at line 473 of file qpaintengine_x11.cpp.

474 {
475 #ifndef QT_NO_XRENDER
477  delete d->tessellator;
478 #endif
479 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ QX11PaintEngine() [2/2]

QX11PaintEngine::QX11PaintEngine ( QX11PaintEnginePrivate dptr)
protected

Definition at line 467 of file qpaintengine_x11.cpp.

469 {
470  d_func()->init();
471 }
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
static QPaintEngine::PaintEngineFeatures qt_decide_features()

Functions

◆ begin()

bool QX11PaintEngine::begin ( QPaintDevice pdev)
virtual

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev.

Return true if the initialization was successful; otherwise return false.

See also
end() isActive()

Implements QPaintEngine.

Definition at line 481 of file qpaintengine_x11.cpp.

482 {
484  d->xinfo = qt_x11Info(pdev);
485  QWidget *w = d->pdev->devType() == QInternal::Widget ? static_cast<QWidget *>(d->pdev) : 0;
486  const bool isAlienWidget = w && !w->internalWinId() && w->testAttribute(Qt::WA_WState_Created);
487 #ifndef QT_NO_XRENDER
488  if (w) {
489  if (isAlienWidget)
490  d->picture = (::Picture)w->nativeParentWidget()->x11PictureHandle();
491  else
492  d->picture = (::Picture)w->x11PictureHandle();
493  } else if (pdev->devType() == QInternal::Pixmap) {
494  const QPixmap *pm = static_cast<const QPixmap *>(pdev);
495  QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
496  if (X11->use_xrender && data->depth() != 32 && data->x11_mask)
497  data->convertToARGB32();
498  d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
499  }
500 #else
501  d->picture = 0;
502 #endif
503  d->hd = !isAlienWidget ? qt_x11Handle(pdev) : qt_x11Handle(w->nativeParentWidget());
504 
505  Q_ASSERT(d->xinfo != 0);
506  d->dpy = d->xinfo->display(); // get display variable
507  d->scrn = d->xinfo->screen(); // get screen variable
508 
509  d->crgn = QRegion();
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;
518  d->xform_scale = 1;
519  d->has_custom_pen = false;
520  d->matrix = QTransform();
521  d->pdev_depth = d->pdev->depth();
522  d->render_hints = 0;
523  d->txop = QTransform::TxNone;
524  d->use_path_fallback = false;
525 #if !defined(QT_NO_XRENDER)
526  d->composition_mode = PictOpOver;
527 #endif
528  d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3;
529  d->opacity = 1;
530 
531  // Set up the polygon clipper. Note: This will only work in
532  // polyline mode as long as we have a buffer zone, since a
533  // polyline may be clipped into several non-connected polylines.
534  const int BUFFERZONE = 1000;
535  QRect devClipRect(-BUFFERZONE, -BUFFERZONE,
536  pdev->width() + 2*BUFFERZONE, pdev->height() + 2*BUFFERZONE);
537  d->polygonClipper.setBoundingRect(devClipRect);
538 
539  if (isAlienWidget) {
540  // Set system clip for alien widgets painting outside the paint event.
541  // This is not a problem with native windows since the windowing system
542  // will handle the clip.
543  QWidgetPrivate *wd = w->d_func();
544  QRegion widgetClip(wd->clipRect());
545  wd->clipToEffectiveMask(widgetClip);
546  wd->subtractOpaqueSiblings(widgetClip);
547  widgetClip.translate(w->mapTo(w->nativeParentWidget(), QPoint()));
548  setSystemClip(widgetClip);
549  }
550 
551  QPixmap::x11SetDefaultScreen(d->xinfo->screen());
552 
553  if (w && w->testAttribute(Qt::WA_PaintUnclipped)) { // paint direct on device
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);
562 #endif
563  }
564 
569 
570  return true;
571 }
double d
Definition: qnumeric_p.h:62
QPoint mapTo(QWidget *, const QPoint &) const
Translates the widget coordinate pos to the coordinate system of parent.
Definition: qwidget.cpp:4409
QExplicitlySharedDataPointer< QPixmapData > data
Definition: qpixmap.h:252
int height() const
Definition: qpaintdevice.h:92
QRect clipRect() const
Definition: qwidget.cpp:1997
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
virtual int devType() const
Definition: qpaintdevice.h:167
void updatePen(const QPen &pen)
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
QWidget * nativeParentWidget() const
Returns the native parent for this widget, i.
Definition: qwidget.cpp:4514
int width() const
Definition: qpaintdevice.h:91
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
Drawable qt_x11Handle(const QPaintDevice *pd)
Returns the X11 Drawable of the paint device.
void convertToARGB32(bool preserveContents=true)
static const char * data(const QByteArray &arr)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setDirty(DirtyFlags df)
Definition: qpaintengine.h:349
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
int depth() const
Qt::HANDLE x11_mask
const QX11Info * qt_x11Info(const QPaintDevice *pd)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
WId internalWinId() const
Returns the window system identifier of the widget, or 0 if the widget is not created yet...
Definition: qwidget.h:244
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
Definition: qwidget.cpp:2139
void updateBrush(const QBrush &brush, const QPointF &pt)
void clipToEffectiveMask(QRegion &region) const
Definition: qwidget.cpp:2230
Qt::HANDLE x11PictureHandle() const
Returns the X11 Picture handle of the widget for XRender support.
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ drawEllipse() [1/2]

void QX11PaintEngine::drawEllipse ( const QRect r)
virtual

The default implementation of this function calls the floating point version of this function.

Reimplemented from QPaintEngine.

Definition at line 1463 of file qpaintengine_x11.cpp.

Referenced by drawEllipse().

1464 {
1465  if (rect.isEmpty()) {
1466  drawRects(&rect, 1);
1467  return;
1468  }
1469 
1471  QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1);
1472  QRect r(rect);
1473  if (d->txop < QTransform::TxRotate) {
1474  r = d->matrix.mapRect(rect);
1475  } else if (d->txop == QTransform::TxRotate && rect.width() == rect.height()) {
1476  QPainterPath path;
1477  path.addEllipse(rect);
1478  r = d->matrix.map(path).boundingRect().toRect();
1479  }
1480 
1481  if (d->has_alpha_brush || d->has_alpha_pen || d->has_custom_pen || (d->render_hints & QPainter::Antialiasing)
1482  || d->has_alpha_texture || devclip.intersected(r) != r
1483  || (d->has_complex_xform
1484  && !(d->has_non_scaling_xform && rect.width() == rect.height())))
1485  {
1486  QPainterPath path;
1487  path.addEllipse(rect);
1488  drawPath(path);
1489  return;
1490  }
1491 
1492  int x = r.x();
1493  int y = r.y();
1494  int w = r.width();
1495  int h = r.height();
1496  if (w < 1 || h < 1)
1497  return;
1498  if (w == 1 && h == 1) {
1499  XDrawPoint(d->dpy, d->hd, d->has_pen ? d->gc : d->gc_brush, x, y);
1500  return;
1501  }
1502  d->setupAdaptedOrigin(rect.topLeft());
1503  if (d->has_brush) { // draw filled ellipse
1504  XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
1505  if (!d->has_pen) // make smoother outline
1506  XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
1507  }
1508  if (d->has_pen) // draw outline
1509  XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
1510  d->resetAdaptedOrigin();
1511 }
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...

◆ drawEllipse() [2/2]

void QX11PaintEngine::drawEllipse ( const QRectF rect)
virtual

Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.

The default implementation calls drawPolygon().

Reimplemented from QPaintEngine.

Definition at line 1454 of file qpaintengine_x11.cpp.

1455 {
1456  QRect aligned = rect.toAlignedRect();
1457  if (aligned == rect)
1458  drawEllipse(aligned);
1459  else
1461 }
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void drawEllipse(const QRect &r)
The default implementation of this function calls the floating point version of this function...

◆ drawFreetype()

void QX11PaintEngine::drawFreetype ( const QPointF p,
const QTextItemInt si 
)
protected

Definition at line 2362 of file qpaintengine_x11.cpp.

Referenced by drawTextItem().

2363 {
2365  if (!ti.glyphs.numGlyphs)
2366  return;
2367 
2368  QFontEngineX11FT *ft = static_cast<QFontEngineX11FT *>(ti.fontEngine);
2369 
2370  if (!d->cpen.isSolid()) {
2372  return;
2373  }
2374 
2375  const bool xrenderPath = (X11->use_xrender
2376  && !(d->pdev->devType() == QInternal::Pixmap
2377  && static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType));
2378 
2380  QVarLengthArray<glyph_t> glyphs;
2381  QTransform matrix;
2382 
2383  if (xrenderPath)
2384  matrix = d->matrix;
2385  matrix.translate(p.x(), p.y());
2386  ft->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
2387  if (glyphs.count() == 0)
2388  return;
2389 
2390 #ifndef QT_NO_XRENDER
2392  if (d->txop >= QTransform::TxScale && xrenderPath)
2393  set = ft->loadTransformedGlyphSet(d->matrix);
2394 
2395  if (!set || set->outline_drawing
2396  || !ft->loadGlyphs(set, glyphs.constData(), glyphs.size(), positions.constData(), QFontEngineFT::Format_Render))
2397  {
2399  return;
2400  }
2401 
2402  if (xrenderPath) {
2403  GlyphSet glyphSet = set->id;
2404  const QColor &pen = d->cpen.color();
2405  ::Picture src = X11->getSolidFill(d->scrn, pen);
2406  XRenderPictFormat *maskFormat = 0;
2407  if (ft->xglyph_format != PictStandardA1)
2408  maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
2409 
2410  enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
2411 
2412  int i = 0;
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);
2416  ++i)
2417  ;
2418 
2419  if (i >= glyphs.size())
2420  return;
2421  ++i;
2422 
2423  QFixed xp = positions[i - 1].x;
2424  QFixed yp = positions[i - 1].y;
2426 
2427  XGlyphElt32 elt;
2428  elt.glyphset = glyphSet;
2429  elt.chars = &glyphs[i - 1];
2430  elt.nchars = 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) {
2436  break;
2437  }
2438  QFontEngineFT::Glyph *g = ft->cachedGlyph(glyphs[i - 1]);
2439  if (g
2440  && positions[i].x == xp + g->advance
2441  && positions[i].y == yp
2442  && elt.nchars < 253 // don't draw more than 253 characters as some X servers
2443  // hang with it
2444  ) {
2445  elt.nchars++;
2446  xp += g->advance;
2447  } else {
2448  xp = positions[i].x;
2449  yp = positions[i].y;
2450 
2451  XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
2452  maskFormat, 0, 0, 0, 0,
2453  &elt, 1);
2454  elt.chars = &glyphs[i];
2455  elt.nchars = 1;
2456  elt.xOff = qRound(xp + offs);
2457  elt.yOff = qRound(yp + offs);
2458  }
2459  }
2460  XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
2461  maskFormat, 0, 0, 0, 0,
2462  &elt, 1);
2463 
2464  return;
2465 
2466  }
2467 #endif
2468 
2469  QPainterPath path = path_for_glyphs(glyphs, positions, ft);
2470  if (path.elementCount() <= 1)
2471  return;
2472  Q_ASSERT((path.elementCount() % 5) == 0);
2473  if (d->txop >= QTransform::TxScale) {
2474  painter()->save();
2475  painter()->setBrush(d->cpen.brush());
2476  painter()->setPen(Qt::NoPen);
2477  painter()->drawPath(path);
2478  painter()->restore();
2479  return;
2480  }
2481 
2482  const int rectcount = 256;
2483  XRectangle rects[rectcount];
2484  int num_rects = 0;
2485 
2486  QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
2487  QRect clip(d->polygonClipper.boundingRect());
2488  for (int i=0; i < path.elementCount(); i+=5) {
2489  int x = qRound(path.elementAt(i).x);
2490  int y = qRound(path.elementAt(i).y);
2491  int w = qRound(path.elementAt(i+1).x) - x;
2492  int h = qRound(path.elementAt(i+2).y) - y;
2493 
2494  QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
2495  rect = rect.intersected(clip);
2496  if (rect.isEmpty())
2497  continue;
2498 
2499  rects[num_rects].x = short(rect.x());
2500  rects[num_rects].y = short(rect.y());
2501  rects[num_rects].width = ushort(rect.width());
2502  rects[num_rects].height = ushort(rect.height());
2503  ++num_rects;
2504  if (num_rects == rectcount) {
2505  XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
2506  num_rects = 0;
2507  }
2508  }
2509  if (num_rects > 0)
2510  XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
2511 
2512 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
const T * constData() const
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling...
Definition: qpainter.cpp:3502
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
static const qreal aliasedCoordinateDelta
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
qreal y
the y coordinate of the element&#39;s position.
Definition: qpainterpath.h:80
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QPainter * painter() const
Returns the paint engine&#39;s painter.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
QGlyphSet * defaultGlyphs()
static const char * data(const QByteArray &arr)
int count() const
bool loadGlyphs(QGlyphSet *gs, const glyph_t *glyphs, int num_glyphs, const QFixedPoint *positions, GlyphFormat format=Format_Render)
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
unsigned long Picture
static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
unsigned short ushort
Definition: qglobal.h:995
Glyph * cachedGlyph(glyph_t g) const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal x
the x coordinate of the element&#39;s position.
Definition: qpainterpath.h:79
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QGlyphSet * loadTransformedGlyphSet(const QTransform &matrix)
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397
static QPainterPath path_for_glyphs(const QVarLengthArray< glyph_t > &glyphs, const QVarLengthArray< QFixedPoint > &positions, const QFontEngineFT *ft)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawImage()

void QX11PaintEngine::drawImage ( const QRectF r,
const QImage pm,
const QRectF sr,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
)
virtual

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

Reimplemented from QPaintEngine.

Definition at line 1893 of file qpaintengine_x11.cpp.

1894 {
1896 
1897  if (image.format() == QImage::Format_RGB32
1898  && d->pdev_depth >= 24 && image.depth() == 32
1899  && r.size() == sr.size())
1900  {
1901  int sx = qRound(sr.x());
1902  int sy = qRound(sr.y());
1903  int x = qRound(r.x());
1904  int y = qRound(r.y());
1905  int w = qRound(r.width());
1906  int h = qRound(r.height());
1907 
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);
1910  } else {
1911  QPaintEngine::drawImage(r, image, sr, flags);
1912  }
1913 }
double d
Definition: qnumeric_p.h:62
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
#define Q_D(Class)
Definition: qglobal.h:2482
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
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)
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
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...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawLines() [1/2]

void QX11PaintEngine::drawLines ( const QLine lines,
int  lineCount 
)
virtual

The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented from QPaintEngine.

Definition at line 676 of file qpaintengine_x11.cpp.

677 {
678  Q_ASSERT(lines);
679  Q_ASSERT(lineCount);
681  if (d->has_alpha_brush
682  || d->has_alpha_pen
683  || d->has_custom_pen
684  || (d->cpen.widthF() > 0 && d->has_complex_xform
685  && !d->has_non_scaling_xform)
686  || (d->render_hints & QPainter::Antialiasing)) {
687  for (int i = 0; i < lineCount; ++i) {
688  QPainterPath path(lines[i].p1());
689  path.lineTo(lines[i].p2());
690  drawPath(path);
691  }
692  return;
693  }
694 
695  if (d->has_pen) {
696  for (int i = 0; i < lineCount; ++i) {
697  QLineF linef;
698  if (d->txop == QTransform::TxNone) {
699  linef = lines[i];
700  } else {
701  linef = d->matrix.map(QLineF(lines[i]));
702  }
703  if (clipLine(&linef, d->polygonClipper.boundingRect())) {
704  int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
705  int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
706  int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
707  int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
708 
709  XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
710  }
711  }
712  }
713 }
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
qreal x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:304
qreal y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:309
static const qreal aliasedCoordinateDelta
static bool clipLine(QLineF *line, const QRect &rect)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
qreal y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:299
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
qreal x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:294
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawLines() [2/2]

void QX11PaintEngine::drawLines ( const QLineF lines,
int  lineCount 
)
virtual

The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented from QPaintEngine.

Definition at line 715 of file qpaintengine_x11.cpp.

716 {
717  Q_ASSERT(lines);
718  Q_ASSERT(lineCount);
720  if (d->has_alpha_brush
721  || d->has_alpha_pen
722  || d->has_custom_pen
723  || (d->cpen.widthF() > 0 && d->has_complex_xform
724  && !d->has_non_scaling_xform)
725  || (d->render_hints & QPainter::Antialiasing)) {
726  for (int i = 0; i < lineCount; ++i) {
727  QPainterPath path(lines[i].p1());
728  path.lineTo(lines[i].p2());
729  drawPath(path);
730  }
731  return;
732  }
733 
734  if (d->has_pen) {
735  for (int i = 0; i < lineCount; ++i) {
736  QLineF linef = d->matrix.map(lines[i]);
737  if (clipLine(&linef, d->polygonClipper.boundingRect())) {
738  int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
739  int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
740  int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
741  int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
742 
743  XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
744  }
745  }
746  }
747 }
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
qreal x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:304
qreal y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:309
static const qreal aliasedCoordinateDelta
static bool clipLine(QLineF *line, const QRect &rect)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
qreal y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:299
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
qreal x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:294
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawPath()

void QX11PaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

Definition at line 1778 of file qpaintengine_x11.cpp.

Referenced by drawEllipse(), drawLines(), drawPoints(), drawPolygon(), and drawRects().

1779 {
1781  if (path.isEmpty())
1782  return;
1783 
1784  if (d->has_brush)
1785  d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
1786  if (d->has_pen
1787  && ((X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
1788  || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate
1789  && !d->has_non_scaling_xform)
1790  || (d->cpen.style() == Qt::CustomDashLine))) {
1791  QPainterPathStroker stroker;
1792  if (d->cpen.style() == Qt::CustomDashLine) {
1793  stroker.setDashPattern(d->cpen.dashPattern());
1794  stroker.setDashOffset(d->cpen.dashOffset());
1795  } else {
1796  stroker.setDashPattern(d->cpen.style());
1797  }
1798  stroker.setCapStyle(d->cpen.capStyle());
1799  stroker.setJoinStyle(d->cpen.joinStyle());
1800  QPainterPath stroke;
1801  qreal width = d->cpen.widthF();
1802  QPolygonF poly;
1803  QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
1804  // necessary to get aliased alphablended primitives to be drawn correctly
1805  if (d->cpen.isCosmetic() || d->has_scaling_xform) {
1806  if (d->cpen.isCosmetic())
1807  stroker.setWidth(width == 0 ? 1 : width);
1808  else
1809  stroker.setWidth(width * d->xform_scale);
1810  stroker.d_ptr->stroker.setClipRect(deviceRect);
1811  stroke = stroker.createStroke(path * d->matrix);
1812  if (stroke.isEmpty())
1813  return;
1814  stroke.setFillRule(Qt::WindingFill);
1815  d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
1816  } else {
1817  stroker.setWidth(width);
1818  stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
1819  stroke = stroker.createStroke(path);
1820  if (stroke.isEmpty())
1821  return;
1822  stroke.setFillRule(Qt::WindingFill);
1823  d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, true);
1824  }
1825  } else if (d->has_pen) {
1826  // if we have a cosmetic pen - use XDrawLine() for speed
1827  QList<QPolygonF> polys = path.toSubpathPolygons(d->matrix);
1828  for (int i = 0; i < polys.size(); ++i)
1829  d->strokePolygon_dev(polys.at(i).data(), polys.at(i).size(), false);
1830  }
1831 }
void setDashOffset(qreal offset)
Sets the dash offset for the generated outlines to offset.
double d
Definition: qnumeric_p.h:62
bool isEmpty() const
Returns true if either there are no elements in this path, or if the only element is a MoveToElement;...
Definition: qpainterpath.h:392
void setClipRect(const QRectF &clip)
Definition: qstroker_p.h:165
double qreal
Definition: qglobal.h:1193
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
#define Q_D(Class)
Definition: qglobal.h:2482
void setDashPattern(Qt::PenStyle)
Sets the dash pattern for the generated outlines to style.
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
QScopedPointer< QPainterPathStrokerPrivate > d_ptr
Definition: qpainterpath.h:300
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< QPolygonF > toSubpathPolygons(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.

◆ drawPixmap()

void QX11PaintEngine::drawPixmap ( const QRectF r,
const QPixmap pm,
const QRectF sr 
)
virtual

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

Implements QPaintEngine.

Definition at line 1915 of file qpaintengine_x11.cpp.

1916 {
1918  QRectF sr = _sr;
1919  int x = qRound(r.x());
1920  int y = qRound(r.y());
1921  int sx = qRound(sr.x());
1922  int sy = qRound(sr.y());
1923  int sw = qRound(sr.width());
1924  int sh = qRound(sr.height());
1925 
1926  QPixmap pixmap = qt_toX11Pixmap(px);
1927  if(pixmap.isNull())
1928  return;
1929 
1930  if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
1931  || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
1932  QPixmap* p = const_cast<QPixmap *>(&pixmap);
1933  p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
1934  }
1935 
1936  QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
1937 
1938 #ifndef QT_NO_XRENDER
1939  ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data.data())->picture;
1940  if (src_pict && d->picture) {
1941  const int pDepth = pixmap.depth();
1942  if (pDepth == 1 && (d->has_alpha_pen)) {
1943  qt_render_bitmap(d->dpy, d->scrn, src_pict, d->picture,
1944  sx, sy, x, y, sw, sh, d->cpen);
1945  return;
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);
1949  return;
1950  }
1951  }
1952 #endif
1953 
1954  bool mono_src = pixmap.depth() == 1;
1955  bool mono_dst = d->pdev_depth == 1;
1956  bool restore_clip = false;
1957 
1958  if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) { // pixmap has a mask
1959  QBitmap comb(sw, sh);
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()) {
1966  int num;
1967  XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
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);
1971  }
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);
1978 
1979  XSetClipOrigin(d->dpy, d->gc, x, y);
1980  XSetClipMask(d->dpy, d->gc, comb.handle());
1981  restore_clip = true;
1982  }
1983 
1984  if (mono_src) {
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);
1990  int num;
1991  XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
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);
1995 
1996  XSetClipMask(d->dpy, d->gc, comb);
1997  XSetClipOrigin(d->dpy, d->gc, x, y);
1998  XFreePixmap(d->dpy, comb);
1999  } else {
2000  XSetClipMask(d->dpy, d->gc, pixmap.handle());
2001  XSetClipOrigin(d->dpy, d->gc, x - sx, y - sy);
2002  }
2003 
2004  if (mono_dst) {
2005  XSetForeground(d->dpy, d->gc, qGray(d->cpen.color().rgb()) > 127 ? 0 : 1);
2006  } else {
2008  XSetForeground(d->dpy, d->gc, cmap.pixel(d->cpen.color()));
2009  }
2010  XFillRectangle(d->dpy, d->hd, d->gc, x, y, sw, sh);
2011  restore_clip = true;
2012  } else if (mono_dst && !mono_src) {
2013  QBitmap bitmap(pixmap);
2014  XCopyArea(d->dpy, bitmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
2015  } else {
2016  XCopyArea(d->dpy, pixmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
2017  }
2018 
2019  if (d->pdev->devType() == QInternal::Pixmap) {
2020  const QPixmap *px = static_cast<const QPixmap*>(d->pdev);
2021  Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask;
2022  Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data.data())->x11_mask;
2023  if (dst_mask) {
2024  GC cgc = XCreateGC(d->dpy, dst_mask, 0, 0);
2025  if (src_mask) { // copy src mask into dst mask
2026  XCopyArea(d->dpy, src_mask, dst_mask, cgc, sx, sy, sw, sh, x, y);
2027  } else { // no src mask, but make sure the area copied is opaque in dest
2028  XSetBackground(d->dpy, cgc, 0);
2029  XSetForeground(d->dpy, cgc, 1);
2030  XFillRectangle(d->dpy, dst_mask, cgc, x, y, sw, sh);
2031  }
2032  XFreeGC(d->dpy, cgc);
2033  }
2034  }
2035 
2036  if (restore_clip) {
2037  XSetClipOrigin(d->dpy, d->gc, 0, 0);
2038  int num;
2039  XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
2040  if (num == 0)
2041  XSetClipMask(d->dpy, d->gc, XNone);
2042  else
2043  XSetClipRectangles(d->dpy, d->gc, 0, 0, rects, num, Unsorted);
2044  }
2045 }
double d
Definition: qnumeric_p.h:62
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
static QColormap instance(int screen=-1)
QExplicitlySharedDataPointer< QPixmapData > data
Definition: qpixmap.h:252
static QColor cmap[256]
Definition: qgl_mac.mm:760
Q_GUI_EXPORT void * qt_getClipRects(const QRegion &r, int &num)
#define Q_D(Class)
Definition: qglobal.h:2482
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
QPixmap qt_toX11Pixmap(const QPixmap &pixmap)
Definition: qpixmap_x11.cpp:93
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
uint pixel(const QColor &color) const
unsigned long Picture
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)
Definition: qrgb.h:75
int depth() const
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
struct _XGC * GC
Definition: qwindowdefs.h:117
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawPoints() [1/2]

void QX11PaintEngine::drawPoints ( const QPoint points,
int  pointCount 
)
virtual

Draws the first pointCount points in the buffer points.

The default implementation converts the first pointCount QPoints in points to QPointFs and calls the floating point version of drawPoints.

Reimplemented from QPaintEngine.

Definition at line 952 of file qpaintengine_x11.cpp.

953 {
954  Q_ASSERT(points);
955  Q_ASSERT(pointCount);
957 
958  if (!d->has_pen)
959  return;
960 
961  // use the same test here as in drawPath to ensure that we don't use the path fallback
962  // and end up in XDrawLines for pens with width <= 1
963  if (d->cpen.widthF() > 1.0f
964  || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
965  || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
966  {
967  Qt::PenCapStyle capStyle = d->cpen.capStyle();
968  if (capStyle == Qt::FlatCap) {
969  setCapStyle(CapProjecting, d->gc);
970  d->cpen.setCapStyle(Qt::SquareCap);
971  }
972  const QPoint *end = points + pointCount;
973  while (points < end) {
974  QPainterPath path;
975  path.moveTo(*points);
976  path.lineTo(points->x()+.005, points->y());
977  drawPath(path);
978  ++points;
979  }
980 
981  if (capStyle == Qt::FlatCap) {
982  setCapStyle(CapButt, d->gc);
983  d->cpen.setCapStyle(capStyle);
984  }
985  return;
986  }
987 
988  static const int BUF_SIZE = 1024;
989  XPoint xPoints[BUF_SIZE];
990  int i = 0, j = 0;
991  while (i < pointCount) {
992  while (i < pointCount && j < BUF_SIZE) {
993  const QPoint &xformed = d->matrix.map(points[i]);
994  int x = xformed.x();
995  int y = xformed.y();
996  if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
997  xPoints[j].x = x;
998  xPoints[j].y = y;
999  ++j;
1000  }
1001  ++i;
1002  }
1003  if (j)
1004  XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
1005 
1006  j = 0;
1007  }
1008 }
#define BUF_SIZE
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
PenCapStyle
Definition: qnamespace.h:1147
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
bool end()
Reimplement this function to finish painting on the current paint device.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
static void setCapStyle(int cap_style, GC gc)
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ drawPoints() [2/2]

void QX11PaintEngine::drawPoints ( const QPointF points,
int  pointCount 
)
virtual

Draws the first pointCount points in the buffer points.

Reimplemented from QPaintEngine.

Definition at line 1010 of file qpaintengine_x11.cpp.

1011 {
1012  Q_ASSERT(points);
1013  Q_ASSERT(pointCount);
1015 
1016  if (!d->has_pen)
1017  return;
1018 
1019  // use the same test here as in drawPath to ensure that we don't use the path fallback
1020  // and end up in XDrawLines for pens with width <= 1
1021  if (d->cpen.widthF() > 1.0f
1022  || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
1023  || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
1024  {
1025  Qt::PenCapStyle capStyle = d->cpen.capStyle();
1026  if (capStyle == Qt::FlatCap) {
1027  setCapStyle(CapProjecting, d->gc);
1028  d->cpen.setCapStyle(Qt::SquareCap);
1029  }
1030 
1031  const QPointF *end = points + pointCount;
1032  while (points < end) {
1033  QPainterPath path;
1034  path.moveTo(*points);
1035  path.lineTo(points->x() + 0.005, points->y());
1036  drawPath(path);
1037  ++points;
1038  }
1039  if (capStyle == Qt::FlatCap) {
1040  setCapStyle(CapButt, d->gc);
1041  d->cpen.setCapStyle(capStyle);
1042  }
1043  return;
1044  }
1045 
1046  static const int BUF_SIZE = 1024;
1047  XPoint xPoints[BUF_SIZE];
1048  int i = 0, j = 0;
1049  while (i < pointCount) {
1050  while (i < pointCount && j < BUF_SIZE) {
1051  const QPointF &xformed = d->matrix.map(points[i]);
1052  int x = qFloor(xformed.x());
1053  int y = qFloor(xformed.y());
1054 
1055  if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
1056  xPoints[j].x = x;
1057  xPoints[j].y = y;
1058  ++j;
1059  }
1060  ++i;
1061  }
1062  if (j)
1063  XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
1064 
1065  j = 0;
1066  }
1067 }
#define BUF_SIZE
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
int qFloor(qreal v)
Definition: qmath.h:73
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
PenCapStyle
Definition: qnamespace.h:1147
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
bool end()
Reimplement this function to finish painting on the current paint device.
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static void setCapStyle(int cap_style, GC gc)

◆ drawPolygon() [1/2]

void QX11PaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
)
virtual

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

Note
At least one of the drawPolygon() functions must be reimplemented.

Reimplemented from QPaintEngine.

Definition at line 1720 of file qpaintengine_x11.cpp.

1721 {
1723  if (d->use_path_fallback) {
1724  QPainterPath path(polygonPoints[0]);
1725  for (int i = 1; i < pointCount; ++i)
1726  path.lineTo(polygonPoints[i]);
1727  if (mode == PolylineMode) {
1728  QBrush oldBrush = d->cbrush;
1729  d->cbrush = QBrush(Qt::NoBrush);
1730  path.setFillRule(Qt::WindingFill);
1731  drawPath(path);
1732  d->cbrush = oldBrush;
1733  } else {
1734  path.setFillRule(mode == OddEvenMode ? Qt::OddEvenFill : Qt::WindingFill);
1735  path.closeSubpath();
1736  drawPath(path);
1737  }
1738  return;
1739  }
1740  if (mode != PolylineMode && d->has_brush)
1741  d->fillPolygon_translated(polygonPoints, pointCount, QX11PaintEnginePrivate::BrushGC, mode);
1742 
1743  if (d->has_pen)
1744  d->strokePolygon_translated(polygonPoints, pointCount, mode != PolylineMode);
1745 }
double d
Definition: qnumeric_p.h:62
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
#define Q_D(Class)
Definition: qglobal.h:2482
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.

◆ drawPolygon() [2/2]

void QX11PaintEngine::drawPolygon ( const QPoint points,
int  pointCount,
PolygonDrawMode  mode 
)
inlinevirtual

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Note
At least one of the drawPolygon() functions must be reimplemented.

Reimplemented from QPaintEngine.

Definition at line 109 of file qpaintengine_x11_p.h.

110  { QPaintEngine::drawPolygon(points, pointCount, mode); }
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...

◆ drawRects() [1/2]

void QX11PaintEngine::drawRects ( const QRect rects,
int  rectCount 
)
virtual

The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented from QPaintEngine.

Definition at line 825 of file qpaintengine_x11.cpp.

Referenced by drawEllipse().

826 {
828  Q_ASSERT(rects);
829  Q_ASSERT(rectCount);
830 
831  if (d->has_alpha_pen
832  || d->has_complex_xform
833  || d->has_custom_pen
834  || (d->render_hints & QPainter::Antialiasing))
835  {
836  for (int i = 0; i < rectCount; ++i) {
837  QPainterPath path;
838  path.addRect(rects[i]);
839  drawPath(path);
840  }
841  return;
842  }
843 
844  QRect clip(d->polygonClipper.boundingRect());
845  QPoint offset(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
846 #if !defined(QT_NO_XRENDER)
847  ::Picture pict = d->picture;
848 
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)))
851  {
852  XRenderColor xc;
853  if (!d->has_texture && !d->has_pattern)
854  xc = X11->preMultiply(d->cbrush.color());
855 
856  for (int i = 0; i < rectCount; ++i) {
857  QRect r(rects[i]);
858  if (d->txop == QTransform::TxTranslate)
859  r.translate(offset);
860 
861  if (r.width() == 0 || r.height() == 0) {
862  if (d->has_pen) {
863  const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
864  XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
865  }
866  continue;
867  }
868 
869  r = r.intersected(clip);
870  if (r.isEmpty())
871  continue;
872  if (d->has_texture || d->has_pattern) {
873  XRenderComposite(d->dpy, d->composition_mode, d->current_brush, 0, pict,
874  qRound(r.x() - d->bg_origin.x()), qRound(r.y() - d->bg_origin.y()),
875  0, 0, r.x(), r.y(), r.width(), r.height());
876  } else {
877  XRenderFillRectangle(d->dpy, d->composition_mode, pict, &xc, r.x(), r.y(), r.width(), r.height());
878  }
879  if (d->has_pen)
880  XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
881  }
882  } else
883 #endif // !QT_NO_XRENDER
884  {
885  if (d->has_brush && d->has_pen) {
886  for (int i = 0; i < rectCount; ++i) {
887  QRect r(rects[i]);
888  if (d->txop == QTransform::TxTranslate)
889  r.translate(offset);
890 
891  if (r.width() == 0 || r.height() == 0) {
892  const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
893  XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
894  continue;
895  }
896 
897  r = r.intersected(clip);
898  if (r.isEmpty())
899  continue;
900  d->setupAdaptedOrigin(r.topLeft());
901  XFillRectangle(d->dpy, d->hd, d->gc_brush, r.x(), r.y(), r.width(), r.height());
902  XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
903  }
904  d->resetAdaptedOrigin();
905  } else {
906  QVarLengthArray<XRectangle> xrects(rectCount);
907  int numClipped = rectCount;
908  for (int i = 0; i < rectCount; ++i) {
909  QRect r(rects[i]);
910  if (d->txop == QTransform::TxTranslate)
911  r.translate(offset);
912 
913  if (r.width() == 0 || r.height() == 0) {
914  --numClipped;
915  if (d->has_pen) {
916  const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
917  XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
918  }
919  continue;
920  }
921 
922  r = r.intersected(clip);
923  if (r.isEmpty()) {
924  --numClipped;
925  continue;
926  }
927  xrects[i].x = short(r.x());
928  xrects[i].y = short(r.y());
929  xrects[i].width = ushort(r.width());
930  xrects[i].height = ushort(r.height());
931  }
932  if (numClipped) {
933  d->setupAdaptedOrigin(rects[0].topLeft());
934  if (d->has_brush)
935  XFillRectangles(d->dpy, d->hd, d->gc_brush, xrects.data(), numClipped);
936  else if (d->has_pen)
937  XDrawRectangles(d->dpy, d->hd, d->gc, xrects.data(), numClipped);
938  d->resetAdaptedOrigin();
939  }
940  }
941  }
942 }
double d
Definition: qnumeric_p.h:62
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPoint p1() const
Returns the line&#39;s start point.
Definition: qline.h:132
QPoint p2() const
Returns the line&#39;s end point.
Definition: qline.h:137
static bool complexPictOp(int op)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
static QLine clipStraightLine(const QRect &clip, const QLine &l)
unsigned long Picture
unsigned short ushort
Definition: qglobal.h:995
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QFactoryLoader * l
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawRects() [2/2]

void QX11PaintEngine::drawRects ( const QRectF rects,
int  rectCount 
)
virtual

Draws the first rectCount rectangles in the buffer rects.

The default implementation of this function calls drawPath() or drawPolygon() depending on the feature set of the paint engine.

Reimplemented from QPaintEngine.

Definition at line 768 of file qpaintengine_x11.cpp.

769 {
771  Q_ASSERT(rects);
772  Q_ASSERT(rectCount);
773 
774  if (rectCount != 1
775  || d->has_pen
776  || d->has_alpha_brush
777  || d->has_complex_xform
778  || d->has_custom_pen
779  || d->cbrush.style() != Qt::SolidPattern
780 #if !defined(QT_NO_XRENDER)
781  || complexPictOp(d->composition_mode)
782 #endif
783  )
784  {
785  QPaintEngine::drawRects(rects, rectCount);
786  return;
787  }
788 
789  QPoint alignedOffset;
790  if (d->txop == QTransform::TxTranslate) {
791  QPointF offset(d->matrix.dx(), d->matrix.dy());
792  alignedOffset = offset.toPoint();
793  if (offset != QPointF(alignedOffset)) {
794  QPaintEngine::drawRects(rects, rectCount);
795  return;
796  }
797  }
798 
799  const QRectF& r = rects[0];
800  QRect alignedRect = r.toAlignedRect();
801  if (r != QRectF(alignedRect)) {
802  QPaintEngine::drawRects(rects, rectCount);
803  return;
804  }
805  alignedRect.translate(alignedOffset);
806 
807  QRect clip(d->polygonClipper.boundingRect());
808  alignedRect = alignedRect.intersected(clip);
809  if (alignedRect.isEmpty())
810  return;
811 
812  // simple-case:
813  // the rectangle is pixel-aligned
814  // the fill brush is just a solid non-alpha color
815  // the painter transform is only integer translation
816  // ignore: antialiasing and just XFillRectangles directly
817  XRectangle xrect;
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);
823 }
double d
Definition: qnumeric_p.h:62
QRect toAlignedRect() const
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle...
Definition: qrect.cpp:2817
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static bool complexPictOp(int op)
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
unsigned short ushort
Definition: qglobal.h:995
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
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...
Definition: qrect.h:312

◆ drawTextItem()

void QX11PaintEngine::drawTextItem ( const QPointF p,
const QTextItem textItem 
)
virtual

This function draws the text item textItem at position p.

The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented from QPaintEngine.

Definition at line 2253 of file qpaintengine_x11.cpp.

2254 {
2255  const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
2256 
2257  switch(ti.fontEngine->type()) {
2259  case QFontEngine::Box:
2260  d_func()->drawBoxTextItem(p, ti);
2261  break;
2262  case QFontEngine::XLFD:
2263  drawXLFD(p, ti);
2264  break;
2265 #ifndef QT_NO_FONTCONFIG
2266  case QFontEngine::Freetype:
2267  drawFreetype(p, ti);
2268  break;
2269 #endif
2270  default:
2271  Q_ASSERT(false);
2272  }
2273 }
QFontEngine * fontEngine
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual Type type() const =0
Internal QTextItem.
void drawXLFD(const QPointF &p, const QTextItemInt &si)
void drawFreetype(const QPointF &p, const QTextItemInt &si)

◆ drawTiledPixmap()

void QX11PaintEngine::drawTiledPixmap ( const QRectF rect,
const QPixmap pixmap,
const QPointF p 
)
virtual

Reimplement this function to draw the pixmap in the given rect, starting at the given p.

The pixmap will be drawn repeatedly until the rect is filled.

Reimplemented from QPaintEngine.

Definition at line 2119 of file qpaintengine_x11.cpp.

2120 {
2121  int x = qRound(r.x());
2122  int y = qRound(r.y());
2123  int w = qRound(r.width());
2124  int h = qRound(r.height());
2125  int sx = qRound(p.x());
2126  int sy = qRound(p.y());
2127 
2128  bool mono_src = pixmap.depth() == 1;
2130 
2131  if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
2132  || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
2133  QPixmap* p = const_cast<QPixmap *>(&pixmap);
2134  p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
2135  }
2136 
2137  QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
2138 
2139 #ifndef QT_NO_XRENDER
2140  if (X11->use_xrender && d->picture && pixmap.x11PictureHandle()) {
2141 #if 0
2142  // ### Qt 5: enable this
2143  XRenderPictureAttributes attrs;
2144  attrs.repeat = true;
2145  XRenderChangePicture(d->dpy, pixmap.x11PictureHandle(), CPRepeat, &attrs);
2146 
2147  if (mono_src) {
2148  qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
2149  sx, sy, x, y, w, h, d->cpen);
2150  } else {
2151  XRenderComposite(d->dpy, d->composition_mode,
2152  pixmap.x11PictureHandle(), XNone, d->picture,
2153  sx, sy, 0, 0, x, y, w, h);
2154  }
2155 #else
2156  const int numTiles = (w / pixmap.width()) * (h / pixmap.height());
2157  if (numTiles < 100) {
2158  // this is essentially qt_draw_tile(), inlined for
2159  // the XRenderComposite call
2160  int yPos, xPos, drawH, drawW, yOff, xOff;
2161  yPos = y;
2162  yOff = sy;
2163  while(yPos < y + h) {
2164  drawH = pixmap.height() - yOff; // Cropping first row
2165  if (yPos + drawH > y + h) // Cropping last row
2166  drawH = y + h - yPos;
2167  xPos = x;
2168  xOff = sx;
2169  while(xPos < x + w) {
2170  drawW = pixmap.width() - xOff; // Cropping first column
2171  if (xPos + drawW > x + w) // Cropping last column
2172  drawW = x + w - xPos;
2173  if (mono_src) {
2174  qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
2175  xOff, yOff, xPos, yPos, drawW, drawH, d->cpen);
2176  } else {
2177  XRenderComposite(d->dpy, d->composition_mode,
2178  pixmap.x11PictureHandle(), XNone, d->picture,
2179  xOff, yOff, 0, 0, xPos, yPos, drawW, drawH);
2180  }
2181  xPos += drawW;
2182  xOff = 0;
2183  }
2184  yPos += drawH;
2185  yOff = 0;
2186  }
2187  } else {
2188  w = qMin(w, d->pdev->width() - x);
2189  h = qMin(h, d->pdev->height() - y);
2190  if (w <= 0 || h <= 0)
2191  return;
2192 
2193  const int pw = w + sx;
2194  const int ph = h + sy;
2195  QPixmap pm(pw, ph);
2196  if (pixmap.hasAlpha() || mono_src)
2197  pm.fill(Qt::transparent);
2198 
2199  const int mode = pixmap.hasAlpha() ? PictOpOver : PictOpSrc;
2200  const ::Picture pmPicture = pm.x11PictureHandle();
2201 
2202  // first tile
2203  XRenderComposite(d->dpy, mode,
2204  pixmap.x11PictureHandle(), XNone, pmPicture,
2205  0, 0, 0, 0, 0, 0, qMin(pw, pixmap.width()), qMin(ph, pixmap.height()));
2206 
2207  // first row of tiles
2208  int xPos = pixmap.width();
2209  const int sh = qMin(ph, pixmap.height());
2210  while (xPos < pw) {
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);
2215  xPos *= 2;
2216  }
2217 
2218  // remaining rows
2219  int yPos = pixmap.height();
2220  const int sw = pw;
2221  while (yPos < ph) {
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);
2226  yPos *= 2;
2227  }
2228 
2229  // composite
2230  if (mono_src)
2231  qt_render_bitmap(d->dpy, d->scrn, pmPicture, d->picture,
2232  sx, sy, x, y, w, h, d->cpen);
2233  else
2234  XRenderComposite(d->dpy, d->composition_mode,
2235  pmPicture, XNone, d->picture,
2236  sx, sy, 0, 0, x, y, w, h);
2237  }
2238 #endif
2239  } else
2240 #endif // !QT_NO_XRENDER
2241  if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
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);
2248  } else {
2249  qt_draw_tile(this, x, y, w, h, pixmap, sx, sy);
2250  }
2251 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QExplicitlySharedDataPointer< QPixmapData > data
Definition: qpixmap.h:252
void qt_draw_tile(QPaintEngine *, qreal, qreal, qreal, qreal, const QPixmap &, qreal, qreal)
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
unsigned long Picture
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)
bool hasAlpha() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false...
Definition: qpixmap.cpp:1938
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ drawXLFD()

void QX11PaintEngine::drawXLFD ( const QPointF p,
const QTextItemInt si 
)
protected

Definition at line 2275 of file qpaintengine_x11.cpp.

Referenced by drawTextItem().

2276 {
2278 
2279  if (d->txop > QTransform::TxTranslate) {
2280  // XServer or font don't support server side transformations, need to do it by hand
2282  return;
2283  }
2284 
2285  if (!ti.glyphs.numGlyphs)
2286  return;
2287 
2289  QVarLengthArray<glyph_t> glyphs;
2290  QTransform matrix = d->matrix;
2291  matrix.translate(p.x(), p.y());
2292  ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
2293  if (glyphs.size() == 0)
2294  return;
2295 
2296  QFontEngineXLFD *xlfd = static_cast<QFontEngineXLFD *>(ti.fontEngine);
2297  Qt::HANDLE font_id = xlfd->fontStruct()->fid;
2298 
2299  XSetFont(d->dpy, d->gc, font_id);
2300 
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) {
2306  XChar2b ch;
2307  ch.byte1 = glyphs[i] >> 8;
2308  ch.byte2 = glyphs[i] & 0xff;
2309  XDrawString16(d->dpy, d->hd, d->gc, xp, yp, &ch, 1);
2310  }
2311  }
2312 }
double d
Definition: qnumeric_p.h:62
static const qreal aliasedCoordinateDelta
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
void * HANDLE
Definition: qnamespace.h:1671
XFontStruct * fontStruct() const
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ end()

bool QX11PaintEngine::end ( )
virtual

Reimplement this function to finish painting on the current paint device.

Return true if painting was finished successfully; otherwise return false.

See also
begin() isActive()

Implements QPaintEngine.

Definition at line 573 of file qpaintengine_x11.cpp.

Referenced by drawPoints(), and qt_x11_drawImage().

574 {
576 
577 #if !defined(QT_NO_XRENDER)
578  if (d->picture) {
579  // reset clipping/subwindow mode on our render picture
580  XRenderPictureAttributes attrs;
581  attrs.subwindow_mode = ClipByChildren;
582  attrs.clip_mask = XNone;
583  XRenderChangePicture(d->dpy, d->picture, CPClipMask|CPSubwindowMode, &attrs);
584  }
585 #endif
586 
587  if (d->gc_brush && d->pdev->painters < 2) {
588  XFreeGC(d->dpy, d->gc_brush);
589  d->gc_brush = 0;
590  }
591 
592  if (d->gc && d->pdev->painters < 2) {
593  XFreeGC(d->dpy, d->gc);
594  d->gc = 0;
595  }
596 
597  // Restore system clip for alien widgets painting outside the paint event.
598  if (d->pdev->devType() == QInternal::Widget && !static_cast<QWidget *>(d->pdev)->internalWinId())
600 
601  return true;
602 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.

◆ handle()

Qt::HANDLE QX11PaintEngine::handle ( ) const
virtual

Definition at line 2108 of file qpaintengine_x11.cpp.

Referenced by qt_mac_qd_context().

2109 {
2110  Q_D(const QX11PaintEngine);
2111  Q_ASSERT(isActive());
2112  Q_ASSERT(d->hd);
2113  return d->hd;
2114 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154

◆ supportedRenderHints()

QPainter::RenderHints QX11PaintEngine::supportedRenderHints ( ) const

Definition at line 1069 of file qpaintengine_x11.cpp.

1070 {
1071 #if !defined(QT_NO_XRENDER)
1072  if (X11->use_xrender)
1073  return QPainter::Antialiasing;
1074 #endif
1075  return QFlag(0);
1076 }
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289

◆ type()

Type QX11PaintEngine::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 120 of file qpaintengine_x11_p.h.

◆ updateBrush()

void QX11PaintEngine::updateBrush ( const QBrush brush,
const QPointF pt 
)

Definition at line 1323 of file qpaintengine_x11.cpp.

Referenced by begin(), and updateState().

1324 {
1326  d->cbrush = brush;
1327  d->bg_origin = origin;
1328  d->adapted_brush_origin = false;
1329 #if !defined(QT_NO_XRENDER)
1330  d->current_brush = 0;
1331 #endif
1332  if (d->opacity < 1.0) {
1333  QColor c = d->cbrush.color();
1334  c.setAlpha(qRound(c.alpha()*d->opacity));
1335  d->cbrush.setColor(c);
1336  }
1337 
1338  int s = FillSolid;
1339  int bs = d->cbrush.style();
1340  d->has_brush = (bs != Qt::NoBrush);
1341  d->has_pattern = bs >= Qt::Dense1Pattern && bs <= Qt::DiagCrossPattern;
1342  d->has_texture = bs == Qt::TexturePattern;
1343  d->has_alpha_brush = brush.color().alpha() != 255;
1344  d->has_alpha_texture = d->has_texture && d->cbrush.texture().hasAlphaChannel();
1345 
1346  ulong mask = GCForeground | GCBackground | GCGraphicsExposures
1347  | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle;
1348  XGCValues vals;
1349  vals.graphics_exposures = false;
1350  if (d->pdev_depth == 1) {
1351  vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1;
1352  vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
1353  } else if (X11->use_xrender && d->pdev->devType() == QInternal::Pixmap
1354  && d->pdev_depth == 32) {
1355  vals.foreground = d->cbrush.color().rgba();
1356  vals.background = QColor(Qt::transparent).rgba();
1357  } else {
1359  vals.foreground = cmap.pixel(d->cbrush.color());
1360  vals.background = cmap.pixel(QColor(Qt::transparent));
1361 
1362  if (!X11->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) {
1363  QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn);
1364  mask |= GCStipple;
1365  vals.stipple = pattern.handle();
1366  s = FillStippled;
1367  d->adapted_brush_origin = true;
1368  }
1369  }
1370  vals.cap_style = CapButt;
1371  vals.join_style = JoinMiter;
1372  vals.line_style = LineSolid;
1373 
1374  if (d->has_pattern || d->has_texture) {
1375  if (bs == Qt::TexturePattern) {
1376  d->brush_pm = qt_toX11Pixmap(d->cbrush.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);
1382  QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
1383  if (data->mask_picture)
1384  XRenderChangePicture(d->dpy, data->mask_picture, CPRepeat, &attrs);
1385  }
1386 #endif
1387  } else {
1388  d->brush_pm = qt_toX11Pixmap(qt_pixmapForBrush(bs, true));
1389  }
1390  d->brush_pm.x11SetScreen(d->scrn);
1391  if (d->brush_pm.depth() == 1) {
1392  mask |= GCStipple;
1393  vals.stipple = d->brush_pm.handle();
1394  s = FillStippled;
1395 #if !defined(QT_NO_XRENDER)
1396  if (X11->use_xrender) {
1397  d->bitmap_texture = QPixmap(d->brush_pm.size());
1398  d->bitmap_texture.fill(Qt::transparent);
1399  d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture);
1400  d->bitmap_texture.x11SetScreen(d->scrn);
1401 
1402  ::Picture src = X11->getSolidFill(d->scrn, d->cbrush.color());
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());
1407 
1408  XRenderPictureAttributes attrs;
1409  attrs.repeat = true;
1410  XRenderChangePicture(d->dpy, d->bitmap_texture.x11PictureHandle(), CPRepeat, &attrs);
1411 
1412  d->current_brush = d->bitmap_texture.x11PictureHandle();
1413  }
1414 #endif
1415  } else {
1416  mask |= GCTile;
1417 #ifndef QT_NO_XRENDER
1418  if (d->pdev_depth == 32 && d->brush_pm.depth() != 32) {
1419  d->brush_pm.detach();
1420  QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
1421  brushData->convertToARGB32();
1422  }
1423 #endif
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());
1427  s = FillTiled;
1428 #if !defined(QT_NO_XRENDER)
1429  d->current_brush = d->cbrush.texture().x11PictureHandle();
1430 #endif
1431  }
1432 
1433  mask |= GCTileStipXOrigin | GCTileStipYOrigin;
1434  vals.ts_x_origin = qRound(origin.x());
1435  vals.ts_y_origin = qRound(origin.y());
1436  }
1437 #if !defined(QT_NO_XRENDER)
1438  else if (d->has_alpha_brush) {
1439  d->current_brush = X11->getSolidFill(d->scrn, d->cbrush.color());
1440  }
1441 #endif
1442 
1443  vals.fill_style = s;
1444  XChangeGC(d->dpy, d->gc_brush, mask, &vals);
1445  if (!d->has_clipping) {
1446  QRegion sysClip = systemClip();
1447  if (!sysClip.isEmpty())
1448  x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip);
1449  else
1450  x11ClearClipRegion(d->dpy, d->gc_brush, 0, d->picture);
1451  }
1452 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QColormap instance(int screen=-1)
unsigned char c[8]
Definition: qnumeric_p.h:62
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
static QColor cmap[256]
Definition: qgl_mac.mm:760
Qt::HANDLE handle() const
Returns the pixmap&#39;s handle to the device context.
Definition: qpixmap.cpp:1299
#define Q_D(Class)
Definition: qglobal.h:2482
QPixmap qt_toX11Pixmap(const QPixmap &pixmap)
Definition: qpixmap_x11.cpp:93
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
void convertToARGB32(bool preserveContents=true)
static const char * data(const QByteArray &arr)
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
unsigned long ulong
Definition: qglobal.h:997
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
uint pixel(const QColor &color) const
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
Definition: qbrush.cpp:99
unsigned long Picture
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
static void x11SetClipRegion(Display *dpy, GC gc, GC gc2, Picture picture, const QRegion &r)
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
static QPixmap qt_patternForAlpha(uchar alpha, int screen)
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
QRegion systemClip() const
Returns the system clip.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
static void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, Picture picture)
friend class QPixmap

◆ updateClipRegion_dev()

void QX11PaintEngine::updateClipRegion_dev ( const QRegion region,
Qt::ClipOperation  op 
)

Definition at line 2064 of file qpaintengine_x11.cpp.

Referenced by updateState().

2065 {
2067  QRegion sysClip = systemClip();
2068  if (op == Qt::NoClip) {
2069  d->has_clipping = false;
2070  d->crgn = sysClip;
2071  if (!sysClip.isEmpty()) {
2072  x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, sysClip);
2073  } else {
2074  x11ClearClipRegion(d->dpy, d->gc, d->gc_brush, d->picture);
2075  }
2076  return;
2077  }
2078 
2079  switch (op) {
2080  case Qt::IntersectClip:
2081  if (d->has_clipping) {
2082  d->crgn &= clipRegion;
2083  break;
2084  }
2085  // fall through
2086  case Qt::ReplaceClip:
2087  if (!sysClip.isEmpty())
2088  d->crgn = clipRegion.intersected(sysClip);
2089  else
2090  d->crgn = clipRegion;
2091  break;
2092  case Qt::UniteClip:
2093  d->crgn |= clipRegion;
2094  if (!sysClip.isEmpty())
2095  d->crgn = d->crgn.intersected(sysClip);
2096  break;
2097  default:
2098  break;
2099  }
2100  d->has_clipping = true;
2101  x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, d->crgn);
2102 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static void x11SetClipRegion(Display *dpy, GC gc, GC gc2, Picture picture, const QRegion &r)
QRegion systemClip() const
Returns the system clip.
static void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, Picture picture)

◆ updateFont()

void QX11PaintEngine::updateFont ( const QFont font)

Definition at line 2104 of file qpaintengine_x11.cpp.

Referenced by updateState().

2105 {
2106 }

◆ updateMatrix()

void QX11PaintEngine::updateMatrix ( const QTransform matrix)

Definition at line 2047 of file qpaintengine_x11.cpp.

Referenced by updateState().

2048 {
2050  d->txop = mtx.type();
2051  d->matrix = mtx;
2052 
2053  d->has_complex_xform = (d->txop > QTransform::TxTranslate);
2054 
2055  extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
2056  bool scaling = qt_scaleForTransform(d->matrix, &d->xform_scale);
2057  d->has_scaling_xform = scaling && d->xform_scale != 1.0;
2058  d->has_non_scaling_xform = scaling && d->xform_scale == 1.0;
2059 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
#define Q_D(Class)
Definition: qglobal.h:2482
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ updatePen()

void QX11PaintEngine::updatePen ( const QPen pen)

Definition at line 1184 of file qpaintengine_x11.cpp.

Referenced by begin(), and updateState().

1185 {
1187  d->cpen = pen;
1188  int cp = CapButt;
1189  int jn = JoinMiter;
1190  int ps = pen.style();
1191 
1192  if (d->opacity < 1.0) {
1193  QColor c = d->cpen.color();
1194  c.setAlpha(qRound(c.alpha()*d->opacity));
1195  d->cpen.setColor(c);
1196  }
1197 
1198  d->has_pen = (ps != Qt::NoPen);
1199  d->has_alpha_pen = (pen.color().alpha() != 255);
1200 
1201  switch (pen.capStyle()) {
1202  case Qt::SquareCap:
1203  cp = CapProjecting;
1204  break;
1205  case Qt::RoundCap:
1206  cp = CapRound;
1207  break;
1208  case Qt::FlatCap:
1209  default:
1210  cp = CapButt;
1211  break;
1212  }
1213  switch (pen.joinStyle()) {
1214  case Qt::BevelJoin:
1215  jn = JoinBevel;
1216  break;
1217  case Qt::RoundJoin:
1218  jn = JoinRound;
1219  break;
1220  case Qt::MiterJoin:
1221  default:
1222  jn = JoinMiter;
1223  break;
1224  }
1225 
1226  d->adapted_pen_origin = false;
1227 
1228  char dashes[10]; // custom pen dashes
1229  int dash_len = 0; // length of dash list
1230  int xStyle = LineSolid;
1231 
1232  /*
1233  We are emulating Windows here. Windows treats cpen.width() == 1
1234  (or 0) as a very special case. The fudge variable unifies this
1235  case with the general case.
1236  */
1237  qreal pen_width = pen.widthF();
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;
1242 
1243  d->has_custom_pen = false;
1244 
1245  switch (ps) {
1246  case Qt::NoPen:
1247  case Qt::SolidLine:
1248  xStyle = LineSolid;
1249  break;
1250  case Qt::DashLine:
1251  dashes[0] = dash;
1252  dashes[1] = space;
1253  dash_len = 2;
1254  xStyle = LineOnOffDash;
1255  break;
1256  case Qt::DotLine:
1257  dashes[0] = dot;
1258  dashes[1] = space;
1259  dash_len = 2;
1260  xStyle = LineOnOffDash;
1261  break;
1262  case Qt::DashDotLine:
1263  dashes[0] = dash;
1264  dashes[1] = space;
1265  dashes[2] = dot;
1266  dashes[3] = space;
1267  dash_len = 4;
1268  xStyle = LineOnOffDash;
1269  break;
1270  case Qt::DashDotDotLine:
1271  dashes[0] = dash;
1272  dashes[1] = space;
1273  dashes[2] = dot;
1274  dashes[3] = space;
1275  dashes[4] = dot;
1276  dashes[5] = space;
1277  dash_len = 6;
1278  xStyle = LineOnOffDash;
1279  break;
1280  case Qt::CustomDashLine:
1281  d->has_custom_pen = true;
1282  break;
1283  }
1284 
1285  ulong mask = GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth
1286  | GCCapStyle | GCJoinStyle | GCLineStyle;
1287  XGCValues vals;
1288  vals.graphics_exposures = false;
1289  if (d->pdev_depth == 1) {
1290  vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1;
1291  vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
1292  } else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32
1293  && X11->use_xrender) {
1294  vals.foreground = pen.color().rgba();
1295  vals.background = QColor(Qt::transparent).rgba();
1296  } else {
1298  vals.foreground = cmap.pixel(pen.color());
1299  vals.background = cmap.pixel(QColor(Qt::transparent));
1300  }
1301 
1302 
1303  vals.line_width = qRound(pen.widthF());
1304  vals.cap_style = cp;
1305  vals.join_style = jn;
1306  vals.line_style = xStyle;
1307 
1308  XChangeGC(d->dpy, d->gc, mask, &vals);
1309 
1310  if (dash_len) { // make dash list
1311  XSetDashes(d->dpy, d->gc, 0, dashes, dash_len);
1312  }
1313 
1314  if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region
1315  QRegion sysClip = systemClip();
1316  if (!sysClip.isEmpty())
1317  x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip);
1318  else
1319  x11ClearClipRegion(d->dpy, d->gc, 0, d->picture);
1320  }
1321 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
static QColormap instance(int screen=-1)
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
static QColor cmap[256]
Definition: qgl_mac.mm:760
QColor color() const
Returns the color of this pen&#39;s brush.
Definition: qpen.cpp:771
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
unsigned long ulong
Definition: qglobal.h:997
uint pixel(const QColor &color) const
#define rgb(r, g, b)
Definition: qcolor_p.cpp:130
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
static void x11SetClipRegion(Display *dpy, GC gc, GC gc2, Picture picture, const QRegion &r)
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition: qcolor.cpp:1094
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
static qreal dot(const QPointF &a, const QPointF &b)
QRegion systemClip() const
Returns the system clip.
QRgb rgb() const
Returns the RGB value of the color.
Definition: qcolor.cpp:1051
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
static void x11ClearClipRegion(Display *dpy, GC gc, GC gc2, Picture picture)

◆ updateRenderHints()

void QX11PaintEngine::updateRenderHints ( QPainter::RenderHints  hints)

Definition at line 1170 of file qpaintengine_x11.cpp.

Referenced by updateState().

1171 {
1173  d->render_hints = hints;
1174 
1175 #if !defined(QT_NO_XRENDER)
1176  if (X11->use_xrender && d->picture) {
1177  XRenderPictureAttributes attrs;
1178  attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp;
1179  XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs);
1180  }
1181 #endif
1182 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ updateState()

void QX11PaintEngine::updateState ( const QPaintEngineState state)
virtual

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState::state() function to find out which properties that must be updated, then use the corresponding GetFunction{get function} to retrieve the current values for the given properties.

See also
QPaintEngineState

Implements QPaintEngine.

Definition at line 1078 of file qpaintengine_x11.cpp.

Referenced by QPaintEngine::syncState().

1079 {
1081  QPaintEngine::DirtyFlags flags = state.state();
1082 
1083 
1084  if (flags & DirtyOpacity) {
1085  d->opacity = state.opacity();
1086  // Force update pen/brush as to get proper alpha colors propagated
1087  flags |= DirtyPen;
1088  flags |= DirtyBrush;
1089  }
1090 
1091  if (flags & DirtyTransform) updateMatrix(state.transform());
1092  if (flags & DirtyPen) updatePen(state.pen());
1093  if (flags & (DirtyBrush | DirtyBrushOrigin)) updateBrush(state.brush(), state.brushOrigin());
1094  if (flags & DirtyFont) updateFont(state.font());
1095 
1096  if (state.state() & DirtyClipEnabled) {
1097  if (state.isClipEnabled()) {
1098  QPolygonF clip_poly_dev(d->matrix.map(painter()->clipPath().toFillPolygon()));
1099  QPolygonF clipped_poly_dev;
1100  d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1101  updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
1102  } else {
1104  }
1105  }
1106 
1107  if (flags & DirtyClipPath) {
1108  QPolygonF clip_poly_dev(d->matrix.map(state.clipPath().toFillPolygon()));
1109  QPolygonF clipped_poly_dev;
1110  d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1111  updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon(), state.clipPath().fillRule()),
1112  state.clipOperation());
1113  } else if (flags & DirtyClipRegion) {
1114  extern QPainterPath qt_regionToPath(const QRegion &region);
1115  QPainterPath clip_path = qt_regionToPath(state.clipRegion());
1116  QPolygonF clip_poly_dev(d->matrix.map(clip_path.toFillPolygon()));
1117  QPolygonF clipped_poly_dev;
1118  d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
1119  updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), state.clipOperation());
1120  }
1121  if (flags & DirtyHints) updateRenderHints(state.renderHints());
1122  if (flags & DirtyCompositionMode) {
1123  int function = GXcopy;
1125  switch (state.compositionMode()) {
1127  function = GXor;
1128  break;
1130  function = GXand;
1131  break;
1133  function = GXxor;
1134  break;
1136  function = GXnor;
1137  break;
1139  function = GXnand;
1140  break;
1142  function = GXequiv;
1143  break;
1145  function = GXcopyInverted;
1146  break;
1148  function = GXandReverse;
1149  break;
1151  function = GXandInverted;
1152  break;
1153  default:
1154  function = GXcopy;
1155  }
1156  }
1157 #if !defined(QT_NO_XRENDER)
1158  else {
1159  d->composition_mode =
1161  }
1162 #endif
1163  XSetFunction(X11->display, d->gc, function);
1164  XSetFunction(X11->display, d->gc_brush, function);
1165  }
1166  d->decidePathFallback();
1167  d->decideCoordAdjust();
1168 }
double d
Definition: qnumeric_p.h:62
void updateMatrix(const QTransform &matrix)
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
Definition: qpaintengine.h:292
qreal opacity() const
Returns the opacity in the current paint engine state.
Definition: qpainter.cpp:9529
static int qpainterOpToXrender(QPainter::CompositionMode mode)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
void updateRenderHints(QPainter::RenderHints hints)
void updateClipRegion_dev(const QRegion &region, Qt::ClipOperation op)
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
Definition: qpainter.cpp:9473
#define Q_D(Class)
Definition: qglobal.h:2482
QPolygon toPolygon() const
Creates and returns a QPolygon by converting each QPointF to a QPoint.
Definition: qpolygon.cpp:772
void updatePen(const QPen &pen)
QPainter * painter() const
Returns the paint engine&#39;s painter.
QBrush brush() const
Returns the brush in the current paint engine state.
Definition: qpainter.cpp:9273
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.
Definition: qpainter.cpp:9396
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
Definition: qpainter.cpp:9287
QFont font() const
Returns the font in the current paint engine state.
Definition: qpainter.cpp:9331
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
Definition: qpainter.cpp:9503
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Definition: qpainter.cpp:9457
Qt::FillRule fillRule() const
Returns the painter path&#39;s currently set fill rule.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
Definition: qpainter.cpp:9488
void updateFont(const QFont &font)
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
Definition: qregion.cpp:1160
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
Definition: qpainter.cpp:9443
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
void updateBrush(const QBrush &brush, const QPointF &pt)

Friends and Related Functions

◆ QFontEngineBox

friend class QFontEngineBox
friend

Definition at line 133 of file qpaintengine_x11_p.h.

◆ QPixmap

friend class QPixmap
friend

Definition at line 132 of file qpaintengine_x11_p.h.

Referenced by updateBrush().

◆ qt_x11_get_brush_gc

Q_GUI_EXPORT GC qt_x11_get_brush_gc ( QPainter p)
friend

Returns the X11 specific brush GC for the painter p.

Note that QPainter::begin() must be called before this function returns a valid GC.

Definition at line 115 of file qpaintengine_x11.cpp.

116 {
117  if (p && p->paintEngine()
118  && p->paintEngine()->isActive()
119  && p->paintEngine()->type() == QPaintEngine::X11) {
120  return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc_brush;
121  }
122  return 0;
123 }
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991

◆ qt_x11_get_pen_gc

Q_GUI_EXPORT GC qt_x11_get_pen_gc ( QPainter p)
friend

Returns the X11 specific pen GC for the painter p.

Note that QPainter::begin() must be called before this function returns a valid GC.

Definition at line 100 of file qpaintengine_x11.cpp.

101 {
102  if (p && p->paintEngine()
103  && p->paintEngine()->isActive()
104  && p->paintEngine()->type() == QPaintEngine::X11) {
105  return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc;
106  }
107  return 0;
108 }
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991

The documentation for this class was generated from the following files: