Qt 4.8
qpaintengine.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include "qpaintengine.h"
42 #include "qpaintengine_p.h"
43 #include "qpainter_p.h"
44 #include "qpolygon.h"
45 #include "qbitmap.h"
46 #include "qapplication.h"
47 #include <qdebug.h>
48 #include <qmath.h>
49 #include <private/qtextengine_p.h>
50 #include <qvarlengtharray.h>
51 #include <private/qfontengine_p.h>
52 #include <private/qpaintengineex_p.h>
53 
54 
56 
91 {
92  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
93  return ti->descent.toReal();
94 }
95 
105 {
106  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
107  return ti->ascent.toReal();
108 }
109 
119 {
120  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
121  return ti->width.toReal();
122 }
123 
132 QTextItem::RenderFlags QTextItem::renderFlags() const
133 {
134  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
135  return ti->flags;
136 }
137 
147 {
148  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
149  return QString(ti->chars, ti->num_chars);
150 }
151 
161 {
162  const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
163  return ti->f ? *ti->f : QApplication::font();
164 }
165 
166 
336 {
337  Q_ASSERT(state);
338  updateState(*state);
339 
340  if (isExtended())
341  static_cast<QPaintEngineEx *>(this)->sync();
342 }
343 
345 struct QT_Point {
346  int x;
347  int y;
348 };
349 
360 void QPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
361 {
362  Q_ASSERT_X(qt_polygon_recursion != this, "QPaintEngine::drawPolygon",
363  "At least one drawPolygon function must be implemented");
364  qt_polygon_recursion = this;
365  Q_ASSERT(sizeof(QT_Point) == sizeof(QPoint));
366  QVarLengthArray<QT_Point> p(pointCount);
367  for (int i = 0; i < pointCount; ++i) {
368  p[i].x = qRound(points[i].x());
369  p[i].y = qRound(points[i].y());
370  }
371  drawPolygon((QPoint *)p.data(), pointCount, mode);
372  qt_polygon_recursion = 0;
373 }
374 
375 struct QT_PointF {
378 };
390 void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
391 {
392  Q_ASSERT_X(qt_polygon_recursion != this, "QPaintEngine::drawPolygon",
393  "At least one drawPolygon function must be implemented");
394  qt_polygon_recursion = this;
395  Q_ASSERT(sizeof(QT_PointF) == sizeof(QPointF));
396  QVarLengthArray<QT_PointF> p(pointCount);
397  for (int i=0; i<pointCount; ++i) {
398  p[i].x = points[i].x();
399  p[i].y = points[i].y();
400  }
401  drawPolygon((QPointF *)p.data(), pointCount, mode);
402  qt_polygon_recursion = 0;
403 }
404 
479 void QPaintEngine::drawPoints(const QPointF *points, int pointCount)
480 {
481  QPainter *p = painter();
482  if (!p)
483  return;
484 
485  qreal penWidth = p->pen().widthF();
486  if (penWidth == 0)
487  penWidth = 1;
488 
489  bool ellipses = p->pen().capStyle() == Qt::RoundCap;
490 
491  p->save();
492 
493  QTransform transform;
494  if (p->pen().isCosmetic()) {
495  transform = p->transform();
496  p->setTransform(QTransform());
497  }
498 
499  p->setBrush(p->pen().brush());
500  p->setPen(Qt::NoPen);
501 
502  for (int i=0; i<pointCount; ++i) {
503  QPointF pos = transform.map(points[i]);
504  QRectF rect(pos.x() - penWidth / 2, pos.y() - penWidth / 2, penWidth, penWidth);
505 
506  if (ellipses)
507  p->drawEllipse(rect);
508  else
509  p->drawRect(rect);
510  }
511 
512  p->restore();
513 }
514 
515 
523 void QPaintEngine::drawPoints(const QPoint *points, int pointCount)
524 {
525  Q_ASSERT(sizeof(QT_PointF) == sizeof(QPointF));
526  QT_PointF fp[256];
527  while (pointCount) {
528  int i = 0;
529  while (i < pointCount && i < 256) {
530  fp[i].x = points[i].x();
531  fp[i].y = points[i].y();
532  ++i;
533  }
534  drawPoints((QPointF *)(void *)fp, i);
535  points += i;
536  pointCount -= i;
537  }
538 }
539 
552 {
553  QPainterPath path;
554  path.addEllipse(rect);
555  if (hasFeature(PainterPaths)) {
556  drawPath(path);
557  } else {
558  QPolygonF polygon = path.toFillPolygon();
559  drawPolygon(polygon.data(), polygon.size(), ConvexMode);
560  }
561 }
562 
568 {
569  drawEllipse(QRectF(rect));
570 }
571 
584 void qt_fill_tile(QPixmap *tile, const QPixmap &pixmap)
585 {
586  QPainter p(tile);
587  p.drawPixmap(0, 0, pixmap);
588  int x = pixmap.width();
589  while (x < tile->width()) {
590  p.drawPixmap(x, 0, *tile, 0, 0, x, pixmap.height());
591  x *= 2;
592  }
593  int y = pixmap.height();
594  while (y < tile->height()) {
595  p.drawPixmap(0, y, *tile, 0, 0, tile->width(), y);
596  y *= 2;
597  }
598 }
599 
601  const QPixmap &pixmap, qreal xOffset, qreal yOffset)
602 {
603  qreal yPos, xPos, drawH, drawW, yOff, xOff;
604  yPos = y;
605  yOff = yOffset;
606  while(yPos < y + h) {
607  drawH = pixmap.height() - yOff; // Cropping first row
608  if (yPos + drawH > y + h) // Cropping last row
609  drawH = y + h - yPos;
610  xPos = x;
611  xOff = xOffset;
612  while(xPos < x + w) {
613  drawW = pixmap.width() - xOff; // Cropping first column
614  if (xPos + drawW > x + w) // Cropping last column
615  drawW = x + w - xPos;
616  if (drawW > 0 && drawH > 0)
617  gc->drawPixmap(QRectF(xPos, yPos, drawW, drawH), pixmap, QRectF(xOff, yOff, drawW, drawH));
618  xPos += drawW;
619  xOff = 0;
620  }
621  yPos += drawH;
622  yOff = 0;
623  }
624 }
625 
626 
632 void QPaintEngine::drawTiledPixmap(const QRectF &rect, const QPixmap &pixmap, const QPointF &p)
633 {
634  int sw = pixmap.width();
635  int sh = pixmap.height();
636 
637  if (sw*sh < 8192 && sw*sh < 16*rect.width()*rect.height()) {
638  int tw = sw, th = sh;
639  while (tw*th < 32678 && tw < rect.width()/2)
640  tw *= 2;
641  while (tw*th < 32678 && th < rect.height()/2)
642  th *= 2;
643  QPixmap tile;
644  if (pixmap.depth() == 1) {
645  tile = QBitmap(tw, th);
646  } else {
647  tile = QPixmap(tw, th);
648  if (pixmap.hasAlphaChannel())
649  tile.fill(Qt::transparent);
650  }
651  qt_fill_tile(&tile, pixmap);
652  qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), tile, p.x(), p.y());
653  } else {
654  qt_draw_tile(this, rect.x(), rect.y(), rect.width(), rect.height(), pixmap, p.x(), p.y());
655  }
656 }
657 
670 void QPaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
671  Qt::ImageConversionFlags flags)
672 {
673  QRectF baseSize(0, 0, image.width(), image.height());
674  QImage im = image;
675  if (baseSize != sr)
676  im = im.copy(qFloor(sr.x()), qFloor(sr.y()),
677  qCeil(sr.width()), qCeil(sr.height()));
678  QPixmap pm = QPixmap::fromImage(im, flags);
679  drawPixmap(r, pm, QRectF(QPointF(0, 0), pm.size()));
680 }
681 
758 QPaintEngine::QPaintEngine(PaintEngineFeatures caps)
759  : state(0),
760  gccaps(caps),
761  active(0),
762  selfDestruct(false),
763  extended(false),
764  d_ptr(new QPaintEnginePrivate)
765 {
766  d_ptr->q_ptr = this;
767 }
768 
773 QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps)
774  : state(0),
775  gccaps(caps),
776  active(0),
777  selfDestruct(false),
778  extended(false),
779  d_ptr(&dptr)
780 {
781  d_ptr->q_ptr = this;
782 }
783 
788 {
789 }
790 
795 {
796  return state ? state->painter() : 0;
797 }
798 
804 {
805  if (hasFeature(PainterPaths)) {
806  qWarning("QPaintEngine::drawPath: Must be implemented when feature PainterPaths is set");
807  }
808 }
809 
816 void QPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
817 {
818  const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
819 
820  QPainterPath path;
821 #ifndef Q_WS_MAC
823 #endif
824  if (ti.glyphs.numGlyphs)
825  ti.fontEngine->addOutlineToPath(0, 0, ti.glyphs, &path, ti.flags);
826  if (!path.isEmpty()) {
827  painter()->save();
829  bool((painter()->renderHints() & QPainter::TextAntialiasing)
830  && !(painter()->font().styleStrategy() & QFont::NoAntialias)));
831  painter()->translate(p.x(), p.y());
832  painter()->fillPath(path, state->pen().brush());
833  painter()->restore();
834  }
835 }
836 
842 void QPaintEngine::drawLines(const QLineF *lines, int lineCount)
843 {
844  for (int i=0; i<lineCount; ++i) {
845  QPointF pts[2] = { lines[i].p1(), lines[i].p2() };
846 
847  if (pts[0] == pts[1]) {
848  if (state->pen().capStyle() != Qt::FlatCap)
849  drawPoints(pts, 1);
850  continue;
851  }
852 
853  drawPolygon(pts, 2, PolylineMode);
854  }
855 }
856 
867 void QPaintEngine::drawLines(const QLine *lines, int lineCount)
868 {
869  struct PointF {
870  qreal x;
871  qreal y;
872  };
873  struct LineF {
874  PointF p1;
875  PointF p2;
876  };
877  Q_ASSERT(sizeof(PointF) == sizeof(QPointF));
878  Q_ASSERT(sizeof(LineF) == sizeof(QLineF));
879  LineF fl[256];
880  while (lineCount) {
881  int i = 0;
882  while (i < lineCount && i < 256) {
883  fl[i].p1.x = lines[i].x1();
884  fl[i].p1.y = lines[i].y1();
885  fl[i].p2.x = lines[i].x2();
886  fl[i].p2.y = lines[i].y2();
887  ++i;
888  }
889  drawLines((QLineF *)(void *)fl, i);
890  lines += i;
891  lineCount -= i;
892  }
893 }
894 
895 
906 void QPaintEngine::drawRects(const QRect *rects, int rectCount)
907 {
908  struct RectF {
909  qreal x;
910  qreal y;
911  qreal w;
912  qreal h;
913  };
914  Q_ASSERT(sizeof(RectF) == sizeof(QRectF));
915  RectF fr[256];
916  while (rectCount) {
917  int i = 0;
918  while (i < rectCount && i < 256) {
919  fr[i].x = rects[i].x();
920  fr[i].y = rects[i].y();
921  fr[i].w = rects[i].width();
922  fr[i].h = rects[i].height();
923  ++i;
924  }
925  drawRects((QRectF *)(void *)fr, i);
926  rects += i;
927  rectCount -= i;
928  }
929 }
930 
936 void QPaintEngine::drawRects(const QRectF *rects, int rectCount)
937 {
938  if (hasFeature(PainterPaths) &&
939  !state->penNeedsResolving() &&
941  for (int i=0; i<rectCount; ++i) {
942  QPainterPath path;
943  path.addRect(rects[i]);
944  if (path.isEmpty())
945  continue;
946  drawPath(path);
947  }
948  } else {
949  for (int i=0; i<rectCount; ++i) {
950  QRectF rf = rects[i];
951  QPointF pts[4] = { QPointF(rf.x(), rf.y()),
952  QPointF(rf.x() + rf.width(), rf.y()),
953  QPointF(rf.x() + rf.width(), rf.y() + rf.height()),
954  QPointF(rf.x(), rf.y() + rf.height()) };
955  drawPolygon(pts, 4, ConvexMode);
956  }
957  }
958 }
959 
965 {
966  d_func()->pdev = device;
967 }
968 
974 {
975  return d_func()->pdev;
976 }
977 
978 #ifdef Q_WS_WIN
979 
989 {
990  return 0;
991 }
992 
993 
1004 {
1005 }
1006 
1007 #endif
1008 
1022 {
1023  return QPoint();
1024 }
1025 
1039 {
1040  Q_D(QPaintEngine);
1041  d->systemClip = region;
1042  // Be backward compatible and only call d->systemStateChanged()
1043  // if we currently have a system transform/viewport set.
1044  if (d->hasSystemTransform || d->hasSystemViewport) {
1045  d->transformSystemClip();
1046  d->systemStateChanged();
1047  }
1048 }
1049 
1062 {
1063  return d_func()->systemClip;
1064 }
1065 
1076 {
1077  if (isActive()) {
1078  qWarning("QPaintEngine::setSystemRect: Should not be changed while engine is active");
1079  return;
1080  }
1081  d_func()->systemRect = rect;
1082 }
1083 
1094 {
1095  return d_func()->systemRect;
1096 }
1097 
1099 {
1100  if (!ti.glyphs.numGlyphs)
1101  return;
1102 
1103  // any fixes here should probably also be done in QFontEngineBox::draw
1104  const int size = qRound(ti.fontEngine->ascent());
1106  QVarLengthArray<glyph_t> glyphs;
1107  QTransform matrix = QTransform::fromTranslate(p.x(), p.y() - size);
1108  ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
1109  if (glyphs.size() == 0)
1110  return;
1111 
1112  QSize s(size - 3, size - 3);
1113 
1114  QPainter *painter = q_func()->state->painter();
1115  painter->save();
1116  painter->setBrush(Qt::NoBrush);
1117  QPen pen = painter->pen();
1119  painter->setPen(pen);
1120  for (int k = 0; k < positions.size(); k++)
1121  painter->drawRect(QRectF(positions[k].toPointF(), s));
1122  painter->restore();
1123 }
1124 
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
virtual QFixed lineThickness() const
double d
Definition: qnumeric_p.h:62
QFontEngine * fontEngine
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
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition: qpixmap.cpp:2197
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Definition: qimage.cpp:1410
double qreal
Definition: qglobal.h:1193
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int width() const
Returns the width of the pixmap.
Definition: qpixmap.cpp:630
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
QSize size() const
Returns the size of the pixmap.
Definition: qpixmap.cpp:661
void syncState()
Updates all dirty states in this engine.
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:57
bool brushNeedsResolving() const
Returns whether the coordinate of the fill have been specified as bounded by the current rendering op...
Definition: qpainter.cpp:9411
int qCeil(qreal v)
Definition: qmath.h:63
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
const QChar * chars
PaintEngineFeatures gccaps
Definition: qpaintengine.h:240
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPaintEngineState * state
Definition: qpaintengine.h:239
int qFloor(qreal v)
Definition: qmath.h:73
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
QPointF p1() const
Returns the line&#39;s start point.
Definition: qline.h:314
RenderFlags flags
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
void qt_draw_tile(QPaintEngine *gc, qreal x, qreal y, qreal w, qreal h, const QPixmap &pixmap, qreal xOffset, qreal yOffset)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
bool isExtended() const
Returns true if the paint engine is a QPaintEngineEx derivative.
Definition: qpaintengine.h:234
int depth() const
Returns the depth of the pixmap.
Definition: qpixmap.cpp:695
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QString text() const
Returns the text that should be drawn.
bool penNeedsResolving() const
Returns whether the coordinate of the stroke have been specified as bounded by the current rendering ...
Definition: qpainter.cpp:9428
#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
int y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:117
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
static QFont font()
Returns the default application font.
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
void setFillRule(Qt::FillRule fillRule)
Sets the fill rule of the painter path to the given fillRule.
QGlyphLayout glyphs
QRect systemRect() const
Retrieves the rect for drawing within the backing store.
The QBitmap class provides monochrome (1-bit depth) pixmaps.
Definition: qbitmap.h:55
virtual HDC getDC() const
Empty default implementation.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
QPainter * painter() const
Returns the paint engine&#39;s painter.
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
Definition: qpainter.cpp:4464
bool isActive() const
Returns true if the paint engine is actively drawing; otherwise returns false.
Definition: qpaintengine.h:154
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPolygonF toFillPolygon(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
Definition: qpainter.cpp:3456
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition: qpen.cpp:840
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
virtual QFixed ascent() const =0
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
Q_CORE_EXPORT void qWarning(const char *,...)
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
Internal QTextItem.
qreal ascent() const
Corresponds to the ascent of the piece of text that is drawn.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:122
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
RenderFlags renderFlags() const
Returns the render flags used.
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...
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
virtual void releaseDC(HDC hdc) const
Empty default implementation.
qreal descent() const
Corresponds to the descent of the piece of text that is drawn.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
void setSystemClip(const QRegion &baseClip)
Sets the system clip for this engine.
virtual void drawLines(const QLine *lines, int lineCount)
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floa...
qreal width() const
Specifies the total width of the text to be drawn.
QPainter * painter() const
Returns a pointer to the painter currently updating the paint engine.
Definition: qpainter.cpp:9514
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
Definition: qpixmap.cpp:1080
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
QScopedPointer< QPaintEnginePrivate > d_ptr
Definition: qpaintengine.h:246
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
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...
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Definition: qpen.cpp:690
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
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal toReal() const
Definition: qfixed_p.h:77
void setSystemRect(const QRect &rect)
Sets the target rect for drawing within the backing store.
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
virtual ~QPaintEngine()
Destroys the paint engine.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition: qpainter.h:650
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
static void drawPoints(const T *points, int n, const QTransform &transform, IDirectFBSurface *surface)
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
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
Definition: qpainter.cpp:5619
int height() const
Returns the height of the pixmap.
Definition: qpixmap.cpp:645
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
static QPaintEngine * qt_polygon_recursion
int y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:127
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QPen pen() const
Returns the pen in the current paint engine state.
Definition: qpainter.cpp:9259
The QTextItem class provides all the information required to draw text in a custom paint engine...
Definition: qpaintengine.h:68
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
void drawBoxTextItem(const QPointF &p, const QTextItemInt &ti)
void qt_fill_tile(QPixmap *tile, const QPixmap &pixmap)
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
Definition: qpixmap.cpp:1965
int x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:112
const QFont * f
virtual QPoint coordinateOffset() const
Returns the offset from the painters origo to the engines origo.
void setPaintDevice(QPaintDevice *device)
QRegion systemClip() const
Returns the system clip.
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QFont font() const
Returns the font that should be used to draw the text.
virtual 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...
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
int size() const
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false...
Definition: qpaintengine.h:229
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
QPaintEngine * q_ptr