Qt 4.8
Public Functions | Protected Functions | Private Functions | List of all members
QVGPaintEngine Class Reference

#include <qpaintengine_vg_p.h>

Inheritance diagram for QVGPaintEngine:
QPaintEngineEx 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 beginNativePainting ()
 
void brushChanged ()
 
void brushOriginChanged ()
 
void clip (const QVectorPath &path, Qt::ClipOperation op)
 
void clip (const QRect &rect, Qt::ClipOperation op)
 
void clip (const QRegion &region, Qt::ClipOperation op)
 
void clip (const QPainterPath &path, Qt::ClipOperation op)
 
void clipEnabledChanged ()
 
void compositionModeChanged ()
 
QPainterStatecreateState (QPainterState *orig) const
 
void draw (const QVectorPath &path)
 
bool drawCachedGlyphs (int numGlyphs, const glyph_t *glyphs, const QFont &font, QFontEngine *fontEngine, const QPointF &p, const QFixedPoint *positions)
 
void drawEllipse (const QRectF &r)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
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 rectangle using the given conversion flags flags, to convert it to a pixmap. More...
 
void drawImage (const QPointF &pos, const QImage &image)
 
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 drawPixmap (const QPointF &pos, const QPixmap &pm)
 
void drawPixmapFragments (const QPainter::PixmapFragment *drawingData, int dataCount, const QPixmap &pixmap, QFlags< QPainter::PixmapFragmentHint > hints)
 
void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
void drawPoints (const QPoint *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
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 drawRoundedRect (const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
 
void drawStaticTextItem (QStaticTextItem *staticTextItem)
 
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...
 
void endNativePainting ()
 
void fill (const QVectorPath &path, const QBrush &brush)
 
void fillRect (const QRectF &rect, const QBrush &brush)
 
void fillRect (const QRectF &rect, const QColor &color)
 
void fillRegion (const QRegion &region, const QColor &color, const QSize &surfaceSize)
 
void opacityChanged ()
 
void penChanged ()
 
QPixmapFilterpixmapFilter (int type, const QPixmapFilter *prototype)
 
 QVGPaintEngine ()
 
void renderHintsChanged ()
 
void setState (QPainterState *s)
 
QVGPainterStatestate ()
 
const QVGPainterStatestate () const
 
void stroke (const QVectorPath &path, const QPen &pen)
 
bool supportsTransformations (qreal, const QTransform &) const
 
void transformChanged ()
 
Type type () const
 Reimplement this function to return the paint engine Type. More...
 
QVGPaintEnginePrivatevgPrivate ()
 
 ~QVGPaintEngine ()
 
- Public Functions inherited from QPaintEngineEx
virtual void drawPixmapFragments (const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
virtual void drawPixmapFragments (const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
 
virtual uint flags () const
 
 QPaintEngineEx ()
 
QPainterStatestate ()
 
const QPainterStatestate () const
 
virtual void sync ()
 
virtual void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
- 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

 QVGPaintEngine (QVGPaintEnginePrivate &data)
 
- Protected Functions inherited from QPaintEngineEx
 QPaintEngineEx (QPaintEngineExPrivate &data)
 
- Protected Functions inherited from QPaintEngine
 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 

Private Functions

bool canVgWritePixels (const QImage &image) const
 
bool clearRect (const QRectF &rect, const QColor &color)
 
QRegion defaultClipRegion ()
 
bool isDefaultClipRect (const QRect &rect)
 
bool isDefaultClipRegion (const QRegion &region)
 
void restoreState (QPaintEngine::DirtyFlags dirty)
 
void updateScissor ()
 

Additional Inherited Members

- Public Types inherited from QPaintEngineEx
enum  Flags { DoNotEmulate = 0x01, IsEmulationEngine = 0x02 }
 
- 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 78 of file qpaintengine_vg_p.h.

Constructors and Destructors

◆ QVGPaintEngine() [1/2]

QVGPaintEngine::QVGPaintEngine ( )

Definition at line 1470 of file qpaintengine_vg.cpp.

◆ ~QVGPaintEngine()

QVGPaintEngine::~QVGPaintEngine ( )

Definition at line 1480 of file qpaintengine_vg.cpp.

1481 {
1482 }

◆ QVGPaintEngine() [2/2]

QVGPaintEngine::QVGPaintEngine ( QVGPaintEnginePrivate data)
protected

Definition at line 1475 of file qpaintengine_vg.cpp.

1476  : QPaintEngineEx(data)
1477 {
1478 }

Functions

◆ begin()

bool QVGPaintEngine::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 1539 of file qpaintengine_vg.cpp.

1540 {
1541  Q_UNUSED(pdev);
1543 
1544  // Initialize the VG painting objects if we haven't done it yet.
1545  if (!d->penPaint)
1546  d->initObjects();
1547 
1548  // The initial clip region is the entire device area.
1549  QVGPainterState *s = state();
1551 
1552  // Initialize the VG state for this paint operation.
1554  d->dirty = 0;
1555  d->rawVG = false;
1556  return true;
1557 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void restoreState(QPaintEngine::DirtyFlags dirty)
QRegion defaultClipRegion()
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QVGPainterState * state()

◆ beginNativePainting()

void QVGPaintEngine::beginNativePainting ( )
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3853 of file qpaintengine_vg.cpp.

3854 {
3856 
3857  // About to enter raw VG mode: flush pending changes and make
3858  // sure that all matrices are set to the current transformation.
3859  QVGPainterState *s = this->state();
3860  d->ensurePen(s->pen);
3861  d->ensureBrush(s->brush);
3862  d->ensurePathTransform();
3863  d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, d->imageTransform);
3864 #if !defined(QVG_NO_DRAW_GLYPHS)
3865  d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, d->pathTransform);
3866 #endif
3867  vgSeti(VG_SCISSORING, VG_FALSE);
3868  vgSeti(VG_MASKING, VG_FALSE);
3869  d->rawVG = true;
3870 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ brushChanged()

void QVGPaintEngine::brushChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2418 of file qpaintengine_vg.cpp.

2419 {
2421  d->dirty |= QPaintEngine::DirtyBrush;
2422 
2423  d->hasExtendedRadialGradientPen = d->needsEmulation(state()->brush);
2424 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QVGPainterState * state()

◆ brushOriginChanged()

void QVGPaintEngine::brushOriginChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2426 of file qpaintengine_vg.cpp.

2427 {
2430  d->brushOrigin = state()->brushOrigin;
2431  d->forcePenChange = true;
2432  d->forceBrushChange = true;
2433 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QPointF brushOrigin
Definition: qpainter_p.h:149
QVGPainterState * state()

◆ canVgWritePixels()

bool QVGPaintEngine::canVgWritePixels ( const QImage image) const
private

Definition at line 3303 of file qpaintengine_vg.cpp.

Referenced by drawImage().

3304 {
3305  Q_D(const QVGPaintEngine);
3306 
3307  // qt_vg_image_to_vg_format returns VG_sARGB_8888 as
3308  // fallback case if no matching VG format is found.
3309  // If given image format is not Format_ARGB32 and returned
3310  // format is VG_sARGB_8888, it means that no match was
3311  // found. In that case vgWritePixels cannot be used.
3312  // Also 1-bit formats cannot be used directly either.
3313  if ((image.format() != QImage::Format_ARGB32
3314  && qt_vg_image_to_vg_format(image.format()) == VG_sARGB_8888)
3315  || image.depth() == 1) {
3316  return false;
3317  }
3318 
3319  // vgWritePixels ignores masking, blending and xforms so we can only use it if
3320  // ALL of the following conditions are true:
3321  // - It is a simple translate, or a scale of -1 on the y-axis (inverted)
3322  // - The opacity is totally opaque
3323  // - The composition mode is "source" OR "source over" provided the image is opaque
3324  return ( d->imageTransform.type() <= QTransform::TxScale
3325  && d->imageTransform.m11() == 1.0 && qAbs(d->imageTransform.m22()) == 1.0)
3326  && d->opacity == 1.0f
3327  && (d->blendMode == VG_BLEND_SRC || (d->blendMode == VG_BLEND_SRC_OVER &&
3328  !image.hasAlphaChannel()));
3329 }
double d
Definition: qnumeric_p.h:62
VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
Definition: qimage.cpp:6495
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_D(Class)
Definition: qglobal.h:2482
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620

◆ clearRect()

bool QVGPaintEngine::clearRect ( const QRectF rect,
const QColor color 
)
private

Definition at line 2564 of file qpaintengine_vg.cpp.

Referenced by fillRect().

2565 {
2567  QVGPainterState *s = state();
2568  if (!s->clipEnabled || s->clipOperation == Qt::NoClip) {
2569  QRect r = d->transform.mapRect(rect).toRect();
2570  int height = paintDevice()->height();
2571  if (d->clearColor != color || d->clearOpacity != s->opacity) {
2572  VGfloat values[4];
2573  values[0] = color.redF();
2574  values[1] = color.greenF();
2575  values[2] = color.blueF();
2576  values[3] = color.alphaF() * s->opacity;
2577  vgSetfv(VG_CLEAR_COLOR, 4, values);
2578  d->clearColor = color;
2579  d->clearOpacity = s->opacity;
2580  }
2581  vgClear(r.x(), height - r.y() - r.height(),
2582  r.width(), r.height());
2583  return true;
2584  }
2585  return false;
2586 }
double d
Definition: qnumeric_p.h:62
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
int height() const
Definition: qpaintdevice.h:92
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
Qt::ClipOperation clipOperation
Definition: qpainter_p.h:157
quint16 values[128]
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
uint clipEnabled
Definition: qpainter_p.h:169
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QVGPainterState * state()

◆ clip() [1/4]

void QVGPaintEngine::clip ( const QVectorPath path,
Qt::ClipOperation  op 
)
virtual

Implements QPaintEngineEx.

Definition at line 1795 of file qpaintengine_vg.cpp.

Referenced by clip(), and clipTransformIsSimple().

1796 {
1798 
1799  d->dirty |= QPaintEngine::DirtyClipRegion;
1800 
1801  if (op == Qt::NoClip) {
1802  d->maskValid = false;
1803  d->maskIsSet = true;
1804  d->scissorMask = false;
1805  d->maskRect = QRect();
1806  vgSeti(VG_MASKING, VG_FALSE);
1807  return;
1808  }
1809 
1810  // We don't have vgRenderToMask(), so handle simple QRectF's only.
1811  if (path.shape() == QVectorPath::RectangleHint &&
1812  path.elementCount() == 4 && clipTransformIsSimple(d->transform)) {
1813  // Clipping region that resulted from QPainter::setClipRect(QRectF).
1814  // Convert it into a QRect and apply.
1815  const qreal *points = path.points();
1816  QRectF rect(points[0], points[1], points[2] - points[0],
1817  points[5] - points[1]);
1818  clip(rect.toRect(), op);
1819  return;
1820  }
1821 
1822 #if !defined(QVG_NO_RENDER_TO_MASK)
1823  QPaintDevice *pdev = paintDevice();
1824  int width = pdev->width();
1825  int height = pdev->height();
1826 
1827  if (op == Qt::ReplaceClip) {
1828  vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, width, height);
1829  d->maskRect = QRect();
1830  } else if (!d->maskValid) {
1831  d->ensureMask(this, width, height);
1832  }
1833 
1834  d->ensurePathTransform();
1835  VGPath vgpath = d->vectorPathToVGPath(path);
1836  switch (op) {
1837  case Qt::ReplaceClip:
1838  case Qt::UniteClip:
1839  vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK);
1840  break;
1841 
1842  case Qt::IntersectClip:
1843  vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK);
1844  break;
1845 
1846  default: break;
1847  }
1848  vgDestroyPath(vgpath);
1849 
1850  vgSeti(VG_MASKING, VG_TRUE);
1851  d->maskValid = true;
1852  d->maskIsSet = false;
1853  d->scissorMask = false;
1854 #endif
1855 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int elementCount() const
int height() const
Definition: qpaintdevice.h:92
void clip(const QVectorPath &path, Qt::ClipOperation op)
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Definition: qpaintdevice.h:91
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static bool clipTransformIsSimple(const QTransform &transform)
const qreal * points() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Hint shape() const

◆ clip() [2/4]

void QVGPaintEngine::clip ( const QRect rect,
Qt::ClipOperation  op 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1857 of file qpaintengine_vg.cpp.

1858 {
1860 
1861  d->dirty |= QPaintEngine::DirtyClipRegion;
1862 
1863  // If we have a non-simple transform, then use path-based clipping.
1864  if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) {
1865  QPaintEngineEx::clip(rect, op);
1866  return;
1867  }
1868 
1869  switch (op) {
1870  case Qt::NoClip:
1871  {
1872  d->maskValid = false;
1873  d->maskIsSet = true;
1874  d->scissorMask = false;
1875  d->maskRect = QRect();
1876  vgSeti(VG_MASKING, VG_FALSE);
1877  }
1878  break;
1879 
1880  case Qt::ReplaceClip:
1881  {
1882  QRect r = d->transform.mapRect(rect);
1883  if (isDefaultClipRect(r)) {
1884  // Replacing the clip with a full-window region is the
1885  // same as turning off clipping.
1886  if (d->maskValid)
1887  vgSeti(VG_MASKING, VG_FALSE);
1888  d->maskValid = false;
1889  d->maskIsSet = true;
1890  d->scissorMask = false;
1891  d->maskRect = QRect();
1892  } else {
1893  // Special case: if the intersection of the system
1894  // clip and "r" is a single rectangle, then use the
1895  // scissor for clipping. We try to avoid allocating a
1896  // QRegion copy on the heap for the test if we can.
1897  QRegion clip = d->systemClip; // Reference-counted, no alloc.
1898  QRect clipRect;
1899  if (clip.rectCount() == 1) {
1900  clipRect = clip.boundingRect().intersected(r);
1901  } else if (clip.isEmpty()) {
1902  clipRect = r;
1903  } else {
1904  clip = clip.intersect(r);
1905  if (clip.rectCount() != 1) {
1906  d->maskValid = false;
1907  d->maskIsSet = false;
1908  d->scissorMask = false;
1909  d->maskRect = QRect();
1910  d->modifyMask(this, VG_FILL_MASK, r);
1911  break;
1912  }
1913  clipRect = clip.boundingRect();
1914  }
1915  d->maskValid = false;
1916  d->maskIsSet = false;
1917  d->scissorMask = true;
1918  d->maskRect = clipRect;
1919  vgSeti(VG_MASKING, VG_FALSE);
1920  updateScissor();
1921  }
1922  }
1923  break;
1924 
1925  case Qt::IntersectClip:
1926  {
1927  QRect r = d->transform.mapRect(rect);
1928  if (!d->maskValid) {
1929  // Mask has not been used yet, so intersect with
1930  // the previous scissor-based region in maskRect.
1931  if (d->scissorMask)
1932  r = r.intersect(d->maskRect);
1933  if (isDefaultClipRect(r)) {
1934  // The clip is the full window, so turn off clipping.
1935  d->maskIsSet = true;
1936  d->maskRect = QRect();
1937  } else {
1938  // Activate the scissor on a smaller maskRect.
1939  d->maskIsSet = false;
1940  d->maskRect = r;
1941  }
1942  d->scissorMask = true;
1943  updateScissor();
1944  } else if (d->maskIsSet && isDefaultClipRect(r)) {
1945  // Intersecting a full-window clip with a full-window
1946  // region is the same as turning off clipping.
1947  if (d->maskValid)
1948  vgSeti(VG_MASKING, VG_FALSE);
1949  d->maskValid = false;
1950  d->maskIsSet = true;
1951  d->scissorMask = false;
1952  d->maskRect = QRect();
1953  } else {
1954  d->modifyMask(this, VG_INTERSECT_MASK, r);
1955  }
1956  }
1957  break;
1958 
1959  case Qt::UniteClip:
1960  {
1961  // If we already have a full-window clip, then uniting a
1962  // region with it will do nothing. Otherwise union.
1963  if (!(d->maskIsSet))
1964  d->modifyMask(this, VG_UNION_MASK, d->transform.mapRect(rect));
1965  }
1966  break;
1967  }
1968 }
double d
Definition: qnumeric_p.h:62
bool isDefaultClipRect(const QRect &rect)
QRect intersect(const QRect &r) const
Use intersected(rectangle) instead.
Definition: qrect.h:476
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
Definition: qrect.h:481
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
void clip(const QVectorPath &path, Qt::ClipOperation op)
#define Q_D(Class)
Definition: qglobal.h:2482
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QRegion intersect(const QRegion &r) const
Use intersected(r) instead.
Definition: qregion.cpp:4249
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
static bool clipTransformIsSimple(const QTransform &transform)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clip() [3/4]

void QVGPaintEngine::clip ( const QRegion region,
Qt::ClipOperation  op 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1970 of file qpaintengine_vg.cpp.

1971 {
1973 
1974  // Use the QRect case if the region consists of a single rectangle.
1975  if (region.rectCount() == 1) {
1976  clip(region.boundingRect(), op);
1977  return;
1978  }
1979 
1980  d->dirty |= QPaintEngine::DirtyClipRegion;
1981 
1982  // If we have a non-simple transform, then use path-based clipping.
1983  if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) {
1984  QPaintEngineEx::clip(region, op);
1985  return;
1986  }
1987 
1988  switch (op) {
1989  case Qt::NoClip:
1990  {
1991  d->maskValid = false;
1992  d->maskIsSet = true;
1993  d->scissorMask = false;
1994  d->maskRect = QRect();
1995  vgSeti(VG_MASKING, VG_FALSE);
1996  }
1997  break;
1998 
1999  case Qt::ReplaceClip:
2000  {
2001  QRegion r = d->transform.map(region);
2002  if (isDefaultClipRegion(r)) {
2003  // Replacing the clip with a full-window region is the
2004  // same as turning off clipping.
2005  if (d->maskValid)
2006  vgSeti(VG_MASKING, VG_FALSE);
2007  d->maskValid = false;
2008  d->maskIsSet = true;
2009  d->scissorMask = false;
2010  d->maskRect = QRect();
2011  } else {
2012  // Special case: if the intersection of the system
2013  // clip and the region is a single rectangle, then
2014  // use the scissor for clipping.
2015  QRegion clip = d->systemClip;
2016  if (clip.isEmpty())
2017  clip = r;
2018  else
2019  clip = clip.intersect(r);
2020  if (clip.rectCount() == 1) {
2021  d->maskValid = false;
2022  d->maskIsSet = false;
2023  d->scissorMask = true;
2024  d->maskRect = clip.boundingRect();
2025  vgSeti(VG_MASKING, VG_FALSE);
2026  updateScissor();
2027  } else {
2028  d->maskValid = false;
2029  d->maskIsSet = false;
2030  d->scissorMask = false;
2031  d->maskRect = QRect();
2032  d->modifyMask(this, VG_FILL_MASK, r);
2033  }
2034  }
2035  }
2036  break;
2037 
2038  case Qt::IntersectClip:
2039  {
2040  if (region.rectCount() != 1) {
2041  // If there is more than one rectangle, then intersecting
2042  // the rectangles one by one in modifyMask() will not give
2043  // the desired result. So fall back to path-based clipping.
2044  QPaintEngineEx::clip(region, op);
2045  return;
2046  }
2047  QRegion r = d->transform.map(region);
2048  if (d->maskIsSet && isDefaultClipRegion(r)) {
2049  // Intersecting a full-window clip with a full-window
2050  // region is the same as turning off clipping.
2051  if (d->maskValid)
2052  vgSeti(VG_MASKING, VG_FALSE);
2053  d->maskValid = false;
2054  d->maskIsSet = true;
2055  d->scissorMask = false;
2056  d->maskRect = QRect();
2057  } else {
2058  d->modifyMask(this, VG_INTERSECT_MASK, r);
2059  }
2060  }
2061  break;
2062 
2063  case Qt::UniteClip:
2064  {
2065  // If we already have a full-window clip, then uniting a
2066  // region with it will do nothing. Otherwise union.
2067  if (!(d->maskIsSet))
2068  d->modifyMask(this, VG_UNION_MASK, d->transform.map(region));
2069  }
2070  break;
2071  }
2072 }
double d
Definition: qnumeric_p.h:62
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
void clip(const QVectorPath &path, Qt::ClipOperation op)
#define Q_D(Class)
Definition: qglobal.h:2482
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QRegion intersect(const QRegion &r) const
Use intersected(r) instead.
Definition: qregion.cpp:4249
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isDefaultClipRegion(const QRegion &region)
static bool clipTransformIsSimple(const QTransform &transform)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clip() [4/4]

void QVGPaintEngine::clip ( const QPainterPath path,
Qt::ClipOperation  op 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2117 of file qpaintengine_vg.cpp.

2118 {
2119 #if !defined(QVG_NO_RENDER_TO_MASK)
2121 
2122  // If the path is a simple rectangle, then use clip(QRect) instead.
2123  QRectF simpleRect;
2124  if (qt_vg_pathToRect(path, &simpleRect)) {
2125  clip(simpleRect.toRect(), op);
2126  return;
2127  }
2128 
2129  d->dirty |= QPaintEngine::DirtyClipRegion;
2130 
2131  if (op == Qt::NoClip) {
2132  d->maskValid = false;
2133  d->maskIsSet = true;
2134  d->scissorMask = false;
2135  d->maskRect = QRect();
2136  vgSeti(VG_MASKING, VG_FALSE);
2137  return;
2138  }
2139 
2140  QPaintDevice *pdev = paintDevice();
2141  int width = pdev->width();
2142  int height = pdev->height();
2143 
2144  if (op == Qt::ReplaceClip) {
2145  vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, width, height);
2146  d->maskRect = QRect();
2147  } else if (!d->maskValid) {
2148  d->ensureMask(this, width, height);
2149  }
2150 
2151  d->ensurePathTransform();
2152  VGPath vgpath = d->painterPathToVGPath(path);
2153  switch (op) {
2154  case Qt::ReplaceClip:
2155  case Qt::UniteClip:
2156  vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK);
2157  break;
2158 
2159  case Qt::IntersectClip:
2160  vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK);
2161  break;
2162 
2163  default: break;
2164  }
2165  vgDestroyPath(vgpath);
2166 
2167  vgSeti(VG_MASKING, VG_TRUE);
2168  d->maskValid = true;
2169  d->maskIsSet = false;
2170  d->scissorMask = false;
2171 #else
2172  QPaintEngineEx::clip(path, op);
2173 #endif
2174 }
double d
Definition: qnumeric_p.h:62
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int height() const
Definition: qpaintdevice.h:92
void clip(const QVectorPath &path, Qt::ClipOperation op)
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Definition: qpaintdevice.h:91
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
static bool qt_vg_pathToRect(const QPainterPath &path, QRectF *rect)
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void clip(const QVectorPath &path, Qt::ClipOperation op)=0

◆ clipEnabledChanged()

void QVGPaintEngine::clipEnabledChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2380 of file qpaintengine_vg.cpp.

2381 {
2382 #if defined(QVG_SCISSOR_CLIP)
2383  vgSeti(VG_MASKING, VG_FALSE); // disable mask fallback
2384  updateScissor();
2385 #else
2387  QVGPainterState *s = state();
2389  if (s->clipEnabled && s->clipOperation != Qt::NoClip) {
2390  // Replay the entire clip stack to put the mask into the right state.
2391  d->maskValid = false;
2392  d->maskIsSet = true;
2393  d->scissorMask = false;
2394  d->maskRect = QRect();
2396  d->replayClipOperations();
2397  d->transform = s->transform();
2398  d->updateTransform(paintDevice());
2399  } else {
2400  vgSeti(VG_MASKING, VG_FALSE);
2401  d->maskValid = false;
2402  d->maskIsSet = false;
2403  d->scissorMask = false;
2404  d->maskRect = QRect();
2405  }
2406 #endif
2407 }
double d
Definition: qnumeric_p.h:62
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::ClipOperation clipOperation
Definition: qpainter_p.h:157
uint clipEnabled
Definition: qpainter_p.h:169
QRegion defaultClipRegion()
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QVGPainterState * state()

◆ compositionModeChanged()

void QVGPaintEngine::compositionModeChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2444 of file qpaintengine_vg.cpp.

2445 {
2448 
2449  VGint vgMode = VG_BLEND_SRC_OVER;
2450 
2451  switch (state()->composition_mode) {
2453  vgMode = VG_BLEND_SRC_OVER;
2454  break;
2456  vgMode = VG_BLEND_DST_OVER;
2457  break;
2459  vgMode = VG_BLEND_SRC;
2460  break;
2462  vgMode = VG_BLEND_SRC_IN;
2463  break;
2465  vgMode = VG_BLEND_DST_IN;
2466  break;
2468  vgMode = VG_BLEND_ADDITIVE;
2469  break;
2471  vgMode = VG_BLEND_MULTIPLY;
2472  break;
2474  vgMode = VG_BLEND_SCREEN;
2475  break;
2477  vgMode = VG_BLEND_DARKEN;
2478  break;
2480  vgMode = VG_BLEND_LIGHTEN;
2481  break;
2482  default:
2483  if (d->hasAdvancedBlending) {
2484  switch (state()->composition_mode) {
2487  break;
2490  break;
2493  break;
2496  break;
2499  break;
2502  break;
2505  break;
2508  break;
2511  break;
2514  break;
2517  break;
2520  break;
2521  default: break; // Fall back to VG_BLEND_SRC_OVER.
2522  }
2523  }
2524  if (vgMode == VG_BLEND_SRC_OVER)
2525  qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode;
2526  break;
2527  }
2528 
2529  d->setBlendMode(VGBlendMode(vgMode));
2530 }
double d
Definition: qnumeric_p.h:62
QPainter::CompositionMode composition_mode
Definition: qpainter_p.h:174
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
QVGPainterState * state()

◆ createState()

QPainterState * QVGPaintEngine::createState ( QPainterState orig) const
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1484 of file qpaintengine_vg.cpp.

1485 {
1486  if (!orig) {
1487  return new QVGPainterState();
1488  } else {
1489  Q_D(const QVGPaintEngine);
1490  QVGPaintEnginePrivate *d2 = const_cast<QVGPaintEnginePrivate*>(d);
1491  QVGPainterState *origState = static_cast<QVGPainterState *>(orig);
1492  origState->savedDirty = d2->dirty;
1493  d2->dirty = 0;
1494  return new QVGPainterState(*origState);
1495  }
1496 }
double d
Definition: qnumeric_p.h:62
QPaintEngine::DirtyFlags savedDirty
#define Q_D(Class)
Definition: qglobal.h:2482
QPaintEngine::DirtyFlags dirty

◆ defaultClipRegion()

QRegion QVGPaintEngine::defaultClipRegion ( )
private

Definition at line 2349 of file qpaintengine_vg.cpp.

Referenced by begin(), clipEnabledChanged(), and clipTransformIsSimple().

2350 {
2351  // The default clip region for a paint device is the whole drawing area.
2352  QPaintDevice *pdev = paintDevice();
2353  return QRegion(0, 0, pdev->width(), pdev->height());
2354 }
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int height() const
Definition: qpaintdevice.h:92
int width() const
Definition: qpaintdevice.h:91
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68

◆ draw()

void QVGPaintEngine::draw ( const QVectorPath path)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1566 of file qpaintengine_vg.cpp.

1567 {
1569  if (d->needsEmulation()) {
1570  QPaintEngineEx::draw(path);
1571  return;
1572  }
1573  QVGPainterState *s = state();
1574  VGPath vgpath = d->vectorPathToVGPath(path);
1575  if (!path.hasWindingFill())
1576  d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
1577  else
1578  d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
1579  vgDestroyPath(vgpath);
1580 }
double d
Definition: qnumeric_p.h:62
virtual void draw(const QVectorPath &path)
#define Q_D(Class)
Definition: qglobal.h:2482
bool hasWindingFill() const
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ drawCachedGlyphs()

bool QVGPaintEngine::drawCachedGlyphs ( int  numGlyphs,
const glyph_t glyphs,
const QFont font,
QFontEngine fontEngine,
const QPointF p,
const QFixedPoint positions 
)

Definition at line 3743 of file qpaintengine_vg.cpp.

3746  {
3747 #if !defined(QVG_NO_DRAW_GLYPHS)
3749 
3750  // Find the glyph cache for this font.
3751  QVGFontCache::ConstIterator it = d->fontCache.constFind(fontEngine);
3752  QVGFontGlyphCache *glyphCache;
3753  if (it != d->fontCache.constEnd()) {
3754  glyphCache = it.value();
3755  } else {
3756 #ifdef Q_OS_SYMBIAN
3757  glyphCache = new QSymbianVGFontGlyphCache();
3758 #else
3759  glyphCache = new QVGFontGlyphCache();
3760 #endif
3761  if (glyphCache->font == VG_INVALID_HANDLE) {
3762  qWarning("QVGPaintEngine::drawTextItem: OpenVG fonts are not supported by the OpenVG engine");
3763  delete glyphCache;
3764  return false;
3765  }
3766  glyphCache->setScaleFromText(font, fontEngine);
3767  d->fontCache.insert(fontEngine, glyphCache);
3768  if (!d->fontEngineCleaner)
3769  d->fontEngineCleaner = new QVGFontEngineCleaner(d);
3770  QObject::connect(fontEngine, SIGNAL(destroyed()),
3771  d->fontEngineCleaner, SLOT(fontEngineDestroyed()));
3772  }
3773 
3774  // Set the transformation to use for drawing the current glyphs.
3775  QTransform glyphTransform(d->pathTransform);
3776  if (d->transform.type() <= QTransform::TxTranslate) {
3777  // Prevent blurriness of unscaled, unrotated text by forcing integer coordinates.
3778  glyphTransform.translate(
3779  floor(p.x() + glyphTransform.dx() + aliasedCoordinateDelta) - glyphTransform.dx(),
3780  floor(p.y() - glyphTransform.dy() + aliasedCoordinateDelta) + glyphTransform.dy());
3781  } else {
3782  glyphTransform.translate(p.x(), p.y());
3783  }
3784 #if defined(QVG_NO_IMAGE_GLYPHS)
3785  glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY);
3786 #endif
3787 
3788  // Some glyph caches can create the VGImage upright
3789  if (glyphCache->invertedGlyphs)
3790  glyphTransform.scale(1, -1);
3791 
3792  d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, glyphTransform);
3793 
3794  // Add the glyphs from the text item into the glyph cache.
3795  glyphCache->cacheGlyphs(d, fontEngine, glyphs, numGlyphs);
3796 
3797  // Create the array of adjustments between glyphs
3798  QVarLengthArray<VGfloat> adjustments_x(numGlyphs);
3799  QVarLengthArray<VGfloat> adjustments_y(numGlyphs);
3800  for (int i = 1; i < numGlyphs; ++i) {
3801  adjustments_x[i-1] = (positions[i].x - positions[i-1].x).round().toReal();
3802  adjustments_y[i-1] = (positions[i].y - positions[i-1].y).round().toReal();
3803  }
3804 
3805  // Set the glyph drawing origin.
3806  VGfloat origin[2];
3807  origin[0] = positions[0].x.round().toReal();
3808  origin[1] = positions[0].y.round().toReal();
3809  vgSetfv(VG_GLYPH_ORIGIN, 2, origin);
3810 
3811  // Fast anti-aliasing for paths, better for images.
3812 #if !defined(QVG_NO_IMAGE_GLYPHS)
3813  d->setImageQuality(VG_IMAGE_QUALITY_BETTER);
3814  d->setImageMode(VG_DRAW_IMAGE_STENCIL);
3815 #else
3816  d->setRenderingQuality(VG_RENDERING_QUALITY_FASTER);
3817 #endif
3818 
3819  // Draw the glyphs. We need to fill with the brush associated with
3820  // the Qt pen, not the Qt brush.
3821  d->ensureBrush(state()->pen.brush());
3822  vgDrawGlyphs(glyphCache->font, numGlyphs, (VGuint*)glyphs,
3823  adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE);
3824  return true;
3825 #else
3826  Q_UNUSED(numGlyphs);
3827  Q_UNUSED(glyphs);
3828  Q_UNUSED(font);
3829  Q_UNUSED(fontEngine);
3830  Q_UNUSED(p);
3831  Q_UNUSED(positions);
3832  return false;
3833 #endif
3834 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QFixed y
Definition: qfixed_p.h:191
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QFixed round() const
Definition: qfixed_p.h:80
Q_CORE_EXPORT void qWarning(const char *,...)
QFixed x
Definition: qfixed_p.h:190
T floor(const T &a)
qreal toReal() const
Definition: qfixed_p.h:77
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QBrush brush
Definition: qpainter_p.h:153
static const qreal aliasedCoordinateDelta
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QVGPainterState * state()

◆ drawEllipse() [1/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2851 of file qpaintengine_vg.cpp.

Referenced by drawEllipse().

2852 {
2853  // Based on the description of vguEllipse() in the OpenVG specification.
2854  // We don't use vguEllipse(), to avoid unnecessary library dependencies.
2856  if (d->needsEmulation()) {
2858  return;
2859  }
2860  if (d->simpleTransform) {
2861  QVGPainterState *s = state();
2862  VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
2863  VG_PATH_DATATYPE_F,
2864  1.0f, // scale
2865  0.0f, // bias
2866  4, // segmentCapacityHint
2867  12, // coordCapacityHint
2868  VG_PATH_CAPABILITY_ALL);
2869  static VGubyte segments[4] = {
2870  VG_MOVE_TO_ABS,
2871  VG_SCCWARC_TO_REL,
2872  VG_SCCWARC_TO_REL,
2873  VG_CLOSE_PATH
2874  };
2875  VGfloat coords[12];
2876  VGfloat halfwid = r.width() / 2;
2877  VGfloat halfht = r.height() / 2;
2878  coords[0] = r.x() + r.width();
2879  coords[1] = r.y() + halfht;
2880  coords[2] = halfwid;
2881  coords[3] = halfht;
2882  coords[4] = 0.0f;
2883  coords[5] = -r.width();
2884  coords[6] = 0.0f;
2885  coords[7] = halfwid;
2886  coords[8] = halfht;
2887  coords[9] = 0.0f;
2888  coords[10] = r.width();
2889  coords[11] = 0.0f;
2890  vgAppendPathData(path, 4, segments, coords);
2891  d->draw(path, s->pen, s->brush);
2892  vgDestroyPath(path);
2893  } else {
2894  // The projective transform version of an ellipse is difficult.
2895  // Generate a QVectorPath containing cubic curves and transform that.
2897  }
2898 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QBrush brush
Definition: qpainter_p.h:153
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
QVGPainterState * state()

◆ drawEllipse() [2/2]

void QVGPaintEngine::drawEllipse ( const QRect r)
virtual

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

Reimplemented from QPaintEngineEx.

Definition at line 2900 of file qpaintengine_vg.cpp.

2901 {
2902  drawEllipse(QRectF(r));
2903 }
void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511

◆ drawImage() [1/2]

void QVGPaintEngine::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.

Implements QPaintEngineEx.

Definition at line 3384 of file qpaintengine_vg.cpp.

Referenced by drawPixmap().

3386 {
3388  if (image.isNull())
3389  return;
3390  VGImage vgImg;
3391  if (d->simpleTransform || d->opacity == 1.0f)
3392  vgImg = toVGImageSubRect(image, sr.toRect(), flags);
3393  else
3394  vgImg = toVGImageWithOpacitySubRect(image, d->opacity, sr.toRect());
3395  if (vgImg != VG_INVALID_HANDLE) {
3396  if (r.size() == sr.size()) {
3397  drawVGImage(d, r.topLeft(), vgImg);
3398  } else {
3399  drawVGImage(d, r, vgImg, sr.size().toSize(),
3400  QRectF(QPointF(0, 0), sr.size()));
3401  }
3402  } else {
3403  if (canVgWritePixels(image) && (r.size() == sr.size()) && !flags) {
3404  // Optimization for straight blits, no blending
3405  int x = sr.x();
3406  int y = sr.y();
3407  int bpp = image.depth() >> 3; // bytes
3408  int offset = 0;
3409  int bpl = image.bytesPerLine();
3410  if (d->imageTransform.m22() < 0) {
3411  // inverted
3412  offset = ((y + sr.height()) * bpl) - ((image.width() - x) * bpp);
3413  bpl = -bpl;
3414  } else {
3415  offset = (y * bpl) + (x * bpp);
3416  }
3417  const uchar *bits = image.constBits() + offset;
3418 
3419  QPointF mapped = d->imageTransform.map(r.topLeft());
3420  vgWritePixels(bits, bpl, qt_vg_image_to_vg_format(image.format()),
3421  mapped.x(), mapped.y() - sr.height(), r.width(), r.height());
3422  return;
3423  } else {
3424  // Monochrome images need to use the vgChildImage() path.
3425  vgImg = toVGImage(image, flags);
3426  if (vgImg == VG_INVALID_HANDLE)
3427  drawImageTiled(d, r, image, sr);
3428  else
3429  drawVGImage(d, r, vgImg, image.size(), sr);
3430  }
3431  }
3432  vgDestroyImage(vgImg);
3433 }
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
VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
bool canVgWritePixels(const QImage &image) const
QSize toSize() const
Returns an integer based copy of this size.
Definition: qsize.h:355
static VGImage toVGImageWithOpacitySubRect(const QImage &image, qreal opacity, const QRect &sr)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
virtual uint flags() const
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
unsigned char uchar
Definition: qglobal.h:994
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
QRect toRect() const
Returns a QRect based on the values of this rectangle.
Definition: qrect.h:845
static VGImage toVGImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
static VGImage toVGImageSubRect(const QImage &image, const QRect &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static void drawVGImage(QVGPaintEnginePrivate *d, const QRectF &r, VGImage vgImg, const QSize &imageSize, const QRectF &sr)
static void drawImageTiled(QVGPaintEnginePrivate *d, const QRectF &r, const QImage &image, const QRectF &sr=QRectF())

◆ drawImage() [2/2]

void QVGPaintEngine::drawImage ( const QPointF pos,
const QImage image 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3435 of file qpaintengine_vg.cpp.

3436 {
3438  if (image.isNull())
3439  return;
3440  VGImage vgImg;
3441  if (canVgWritePixels(image)) {
3442  // Optimization for straight blits, no blending
3443  bool inverted = (d->imageTransform.m22() < 0);
3444  const uchar *bits = inverted ? image.constBits() + image.byteCount() - image.bytesPerLine() : image.constBits();
3445  int bpl = inverted ? -image.bytesPerLine() : image.bytesPerLine();
3446 
3447  QPointF mapped = d->imageTransform.map(pos);
3448  vgWritePixels(bits, bpl, qt_vg_image_to_vg_format(image.format()),
3449  mapped.x(), mapped.y() - image.height(), image.width(), image.height());
3450  return;
3451  } else if (d->simpleTransform || d->opacity == 1.0f) {
3452  vgImg = toVGImage(image);
3453  } else {
3454  vgImg = toVGImageWithOpacity(image, d->opacity);
3455  }
3456  if (vgImg == VG_INVALID_HANDLE)
3457  drawImageTiled(d, QRectF(pos, image.size()), image);
3458  else
3459  drawVGImage(d, pos, vgImg);
3460  vgDestroyImage(vgImg);
3461 }
double d
Definition: qnumeric_p.h:62
VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
bool canVgWritePixels(const QImage &image) const
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int byteCount() const
Returns the number of bytes occupied by the image data.
Definition: qimage.cpp:1800
static VGImage toVGImageWithOpacity(const QImage &image, qreal opacity)
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
#define Q_D(Class)
Definition: qglobal.h:2482
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
QFuture< T > mapped(const Sequence &sequence, MapFunction function)
unsigned char uchar
Definition: qglobal.h:994
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
const uchar * constBits() const
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1985
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
static VGImage toVGImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static void drawVGImage(QVGPaintEnginePrivate *d, const QRectF &r, VGImage vgImg, const QSize &imageSize, const QRectF &sr)
static void drawImageTiled(QVGPaintEnginePrivate *d, const QRectF &r, const QImage &image, const QRectF &sr=QRectF())

◆ drawLines() [1/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2787 of file qpaintengine_vg.cpp.

2788 {
2789 #if !defined(QVG_NO_MODIFY_PATH)
2791  if (d->needsEmulation()) {
2792  QPaintEngineEx::drawLines(lines, lineCount);
2793  return;
2794  }
2795  QVGPainterState *s = state();
2796  for (int i = 0; i < lineCount; ++i, ++lines) {
2797  VGfloat coords[4];
2798  if (d->simpleTransform) {
2799  coords[0] = lines->x1();
2800  coords[1] = lines->y1();
2801  coords[2] = lines->x2();
2802  coords[3] = lines->y2();
2803  } else {
2804  QPointF p1 = d->transform.map(QPointF(lines->x1(), lines->y1()));
2805  QPointF p2 = d->transform.map(QPointF(lines->x2(), lines->y2()));
2806  coords[0] = p1.x();
2807  coords[1] = p1.y();
2808  coords[2] = p2.x();
2809  coords[3] = p2.y();
2810  }
2811  vgModifyPathCoords(d->linePath, 0, 2, coords);
2812  d->stroke(d->linePath, s->pen);
2813  }
2814 #else
2815  QPaintEngineEx::drawLines(lines, lineCount);
2816 #endif
2817 }
double d
Definition: qnumeric_p.h:62
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
int y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:117
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
int x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:122
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 y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
int y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:127
int x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:112
QVGPainterState * state()

◆ drawLines() [2/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2819 of file qpaintengine_vg.cpp.

2820 {
2821 #if !defined(QVG_NO_MODIFY_PATH)
2823  if (d->needsEmulation()) {
2824  QPaintEngineEx::drawLines(lines, lineCount);
2825  return;
2826  }
2827  QVGPainterState *s = state();
2828  for (int i = 0; i < lineCount; ++i, ++lines) {
2829  VGfloat coords[4];
2830  if (d->simpleTransform) {
2831  coords[0] = lines->x1();
2832  coords[1] = lines->y1();
2833  coords[2] = lines->x2();
2834  coords[3] = lines->y2();
2835  } else {
2836  QPointF p1 = d->transform.map(lines->p1());
2837  QPointF p2 = d->transform.map(lines->p2());
2838  coords[0] = p1.x();
2839  coords[1] = p1.y();
2840  coords[2] = p2.x();
2841  coords[3] = p2.y();
2842  }
2843  vgModifyPathCoords(d->linePath, 0, 2, coords);
2844  d->stroke(d->linePath, s->pen);
2845  }
2846 #else
2847  QPaintEngineEx::drawLines(lines, lineCount);
2848 #endif
2849 }
double d
Definition: qnumeric_p.h:62
qreal x2() const
Returns the x-coordinate of the line&#39;s end point.
Definition: qline.h:304
QPointF p1() const
Returns the line&#39;s start point.
Definition: qline.h:314
qreal y2() const
Returns the y-coordinate of the line&#39;s end point.
Definition: qline.h:309
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal y1() const
Returns the y-coordinate of the line&#39;s start point.
Definition: qline.h:299
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...
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
qreal x1() const
Returns the x-coordinate of the line&#39;s start point.
Definition: qline.h:294
QVGPainterState * state()

◆ drawPath()

void QVGPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngineEx.

Definition at line 2905 of file qpaintengine_vg.cpp.

2906 {
2907  // Shortcut past the QPainterPath -> QVectorPath conversion,
2908  // converting the QPainterPath directly into a VGPath.
2910  if (d->needsEmulation()) {
2912  return;
2913  }
2914  QVGPainterState *s = state();
2915  VGPath vgpath = d->painterPathToVGPath(path);
2916  if (path.fillRule() == Qt::OddEvenFill)
2917  d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
2918  else
2919  d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
2920  vgDestroyPath(vgpath);
2921 }
double d
Definition: qnumeric_p.h:62
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::FillRule fillRule() const
Returns the painter path&#39;s currently set fill rule.
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ drawPixmap() [1/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 3331 of file qpaintengine_vg.cpp.

3332 {
3333  QPixmapData *pd = pm.pixmapData();
3334  if (!pd)
3335  return; // null QPixmap
3336  if (pd->classId() == QPixmapData::OpenVGClass) {
3338  QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
3339  if (!vgpd->isValid())
3340  return;
3341  if (d->simpleTransform)
3342  drawVGImage(d, r, vgpd->toVGImage(), vgpd->size(), sr);
3343  else
3344  drawVGImage(d, r, vgpd->toVGImage(d->opacity), vgpd->size(), sr);
3345 
3346  if (vgpd->vgImage != VG_INVALID_HANDLE)
3347  return;
3348 
3349  vgpd->source.beginDataAccess();
3350  drawImage(r, vgpd->source.imageRef(), sr, Qt::AutoColor);
3351  vgpd->source.endDataAccess(true);
3352  } else {
3353  drawImage(r, *(pd->buffer()), sr, Qt::AutoColor);
3354  }
3355 }
QSize size() const
double d
Definition: qnumeric_p.h:62
void beginDataAccess() const
#define Q_D(Class)
Definition: qglobal.h:2482
void endDataAccess(bool readOnly=false) const
virtual VGImage toVGImage()
ClassId classId() const
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...
QVolatileImage source
bool isValid() const
virtual QImage * buffer()
static void drawVGImage(QVGPaintEnginePrivate *d, const QRectF &r, VGImage vgImg, const QSize &imageSize, const QRectF &sr)
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.
QPixmapData * pixmapData() const
Definition: qpixmap.cpp:2277

◆ drawPixmap() [2/2]

void QVGPaintEngine::drawPixmap ( const QPointF pos,
const QPixmap pm 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3357 of file qpaintengine_vg.cpp.

3358 {
3359  QPixmapData *pd = pm.pixmapData();
3360  if (!pd)
3361  return; // null QPixmap
3362  if (pd->classId() == QPixmapData::OpenVGClass) {
3364  QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
3365  if (!vgpd->isValid())
3366  return;
3367  if (d->simpleTransform)
3368  drawVGImage(d, pos, vgpd->toVGImage());
3369  else
3370  drawVGImage(d, pos, vgpd->toVGImage(d->opacity));
3371 
3372  if (vgpd->vgImage != VG_INVALID_HANDLE)
3373  return;
3374 
3375  vgpd->source.beginDataAccess();
3376  drawImage(pos, vgpd->source.imageRef());
3377  vgpd->source.endDataAccess(true);
3378  } else {
3379  drawImage(pos, *(pd->buffer()));
3380  }
3381 }
double d
Definition: qnumeric_p.h:62
void beginDataAccess() const
#define Q_D(Class)
Definition: qglobal.h:2482
void endDataAccess(bool readOnly=false) const
virtual VGImage toVGImage()
ClassId classId() const
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...
QVolatileImage source
bool isValid() const
virtual QImage * buffer()
static void drawVGImage(QVGPaintEnginePrivate *d, const QRectF &r, VGImage vgImg, const QSize &imageSize, const QRectF &sr)
QImage & imageRef()
Returns a reference to the image that is potentially using some native buffer internally.
QPixmapData * pixmapData() const
Definition: qpixmap.cpp:2277

◆ drawPixmapFragments()

void QVGPaintEngine::drawPixmapFragments ( const QPainter::PixmapFragment drawingData,
int  dataCount,
const QPixmap pixmap,
QFlags< QPainter::PixmapFragmentHint hints 
)

Definition at line 3476 of file qpaintengine_vg.cpp.

3478 {
3479 #if !defined(QT_SHIVAVG)
3481 
3482  // If the pixmap is not VG, or the transformation is projective,
3483  // then fall back to the default implementation.
3484  QPixmapData *pd = pixmap.pixmapData();
3485  if (!pd)
3486  return; // null QPixmap
3487  if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) {
3488  QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
3489  return;
3490  }
3491 
3492  // Bail out if nothing to do.
3493  if (dataCount <= 0)
3494  return;
3495 
3496  // Bail out if we don't have a usable VGImage for the pixmap.
3497  QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
3498  if (!vgpd->isValid())
3499  return;
3500  VGImage vgImg = vgpd->toVGImage();
3501  if (vgImg == VG_INVALID_HANDLE)
3502  return;
3503 
3504  // We cache the results of any vgChildImage() calls because the
3505  // same child is very likely to be used over and over in particle
3506  // systems. However, performance is even better if vgChildImage()
3507  // isn't needed at all, so use full source rects where possible.
3508  QVarLengthArray<VGImage> cachedImages;
3509  QVarLengthArray<QRect> cachedSources;
3510 
3511  // Select the opacity paint object.
3512  if ((hints & QPainter::OpaqueHint) != 0 && d->opacity == 1.0f) {
3513  d->setImageMode(VG_DRAW_IMAGE_NORMAL);
3514  } else {
3515  hints = 0;
3516  if (d->fillPaint != d->opacityPaint) {
3517  vgSetPaint(d->opacityPaint, VG_FILL_PATH);
3518  d->fillPaint = d->opacityPaint;
3519  }
3520  }
3521 
3522  for (int i = 0; i < dataCount; ++i) {
3523  QTransform transform(d->imageTransform);
3524  transform.translate(drawingData[i].x, drawingData[i].y);
3525  transform.rotate(drawingData[i].rotation);
3526 
3527  VGImage child;
3528  QSize imageSize = vgpd->size();
3529  QRectF sr(drawingData[i].sourceLeft, drawingData[i].sourceTop,
3530  drawingData[i].width, drawingData[i].height);
3531  if (sr.topLeft().isNull() && sr.size() == imageSize) {
3532  child = vgImg;
3533  } else {
3534  // Look for a previous child with the same source rectangle
3535  // to avoid constantly calling vgChildImage()/vgDestroyImage().
3536  QRect src = sr.toRect();
3537  int j;
3538  for (j = 0; j < cachedSources.size(); ++j) {
3539  if (cachedSources[j] == src)
3540  break;
3541  }
3542  if (j < cachedSources.size()) {
3543  child = cachedImages[j];
3544  } else {
3545  child = vgChildImage
3546  (vgImg, src.x(), src.y(), src.width(), src.height());
3547  cachedImages.append(child);
3548  cachedSources.append(src);
3549  }
3550  }
3551 
3552  VGfloat scaleX = drawingData[i].scaleX;
3553  VGfloat scaleY = drawingData[i].scaleY;
3554  transform.translate(-0.5 * scaleX * sr.width(),
3555  -0.5 * scaleY * sr.height());
3556  transform.scale(scaleX, scaleY);
3557  d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
3558 
3559  if ((hints & QPainter::OpaqueHint) == 0) {
3560  qreal opacity = d->opacity * drawingData[i].opacity;
3561  if (opacity != 1.0f) {
3562  if (d->paintOpacity != opacity) {
3563  VGfloat values[4];
3564  values[0] = 1.0f;
3565  values[1] = 1.0f;
3566  values[2] = 1.0f;
3567  values[3] = opacity;
3568  d->paintOpacity = opacity;
3569  vgSetParameterfv
3570  (d->opacityPaint, VG_PAINT_COLOR, 4, values);
3571  }
3572  d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
3573  } else {
3574  d->setImageMode(VG_DRAW_IMAGE_NORMAL);
3575  }
3576  }
3577 
3578  vgDrawImage(child);
3579  }
3580 
3581  // Destroy the cached child sub-images.
3582  for (int i = 0; i < cachedImages.size(); ++i)
3583  vgDestroyImage(cachedImages[i]);
3584 #else
3585  QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
3586 #endif
3587 }
QSize size() const
double d
Definition: qnumeric_p.h:62
qreal scaleY
the vertical scale of the target rectangle.
Definition: qpainter.h:112
double qreal
Definition: qglobal.h:1193
virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
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
qreal opacity
the opacity of the target rectangle, where 0.0 is fully transparent and 1.0 is fully opaque...
Definition: qpainter.h:114
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual VGImage toVGImage()
ClassId classId() const
quint16 values[128]
bool isValid() const
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
qreal scaleX
the horizontal scale of the target rectangle.
Definition: qpainter.h:111
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QPixmapData * pixmapData() const
Definition: qpixmap.cpp:2277

◆ drawPoints() [1/2]

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

Draws the first pointCount points in the buffer points.

Reimplemented from QPaintEngineEx.

Definition at line 2923 of file qpaintengine_vg.cpp.

2924 {
2925 #if !defined(QVG_NO_MODIFY_PATH)
2927 
2928  if (d->needsPenEmulation()) {
2929  QPaintEngineEx::drawPoints(points, pointCount);
2930  return;
2931  }
2932 
2933  // Set up a new pen if necessary.
2934  QPen pen = state()->pen;
2935  if (pen.style() == Qt::NoPen)
2936  return;
2937  if (pen.capStyle() == Qt::FlatCap)
2939 
2940  for (int i = 0; i < pointCount; ++i, ++points) {
2941  VGfloat coords[4];
2942  if (d->simpleTransform) {
2943  coords[0] = points->x();
2944  coords[1] = points->y();
2945  coords[2] = coords[0];
2946  coords[3] = coords[1];
2947  } else {
2948  QPointF p = d->transform.map(*points);
2949  coords[0] = p.x();
2950  coords[1] = p.y();
2951  coords[2] = coords[0];
2952  coords[3] = coords[1];
2953  }
2954  vgModifyPathCoords(d->linePath, 0, 2, coords);
2955  d->stroke(d->linePath, pen);
2956  }
2957 #else
2958  QPaintEngineEx::drawPoints(points, pointCount);
2959 #endif
2960 }
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
double d
Definition: qnumeric_p.h:62
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#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
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
QVGPainterState * state()

◆ drawPoints() [2/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2962 of file qpaintengine_vg.cpp.

2963 {
2964 #if !defined(QVG_NO_MODIFY_PATH)
2966 
2967  if (d->needsEmulation()) {
2968  QPaintEngineEx::drawPoints(points, pointCount);
2969  return;
2970  }
2971 
2972  // Set up a new pen if necessary.
2973  QPen pen = state()->pen;
2974  if (pen.style() == Qt::NoPen)
2975  return;
2976  if (pen.capStyle() == Qt::FlatCap)
2978 
2979  for (int i = 0; i < pointCount; ++i, ++points) {
2980  VGfloat coords[4];
2981  if (d->simpleTransform) {
2982  coords[0] = points->x();
2983  coords[1] = points->y();
2984  coords[2] = coords[0];
2985  coords[3] = coords[1];
2986  } else {
2987  QPointF p = d->transform.map(QPointF(*points));
2988  coords[0] = p.x();
2989  coords[1] = p.y();
2990  coords[2] = coords[0];
2991  coords[3] = coords[1];
2992  }
2993  vgModifyPathCoords(d->linePath, 0, 2, coords);
2994  d->stroke(d->linePath, pen);
2995  }
2996 #else
2997  QPaintEngineEx::drawPoints(points, pointCount);
2998 #endif
2999 }
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
double d
Definition: qnumeric_p.h:62
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#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
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
QVGPainterState * state()

◆ drawPolygon() [1/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 3001 of file qpaintengine_vg.cpp.

3002 {
3004 
3005  if (d->needsEmulation()) {
3006  QPaintEngineEx::drawPolygon(points, pointCount, mode);
3007  return;
3008  }
3009 
3010  QVGPainterState *s = state();
3011  VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
3012  VG_PATH_DATATYPE_F,
3013  1.0f, // scale
3014  0.0f, // bias
3015  pointCount + 1, // segmentCapacityHint
3016  pointCount * 2, // coordCapacityHint
3017  VG_PATH_CAPABILITY_ALL);
3020  for (int i = 0; i < pointCount; ++i, ++points) {
3021  if (d->simpleTransform) {
3022  coords.append(points->x());
3023  coords.append(points->y());
3024  } else {
3025  QPointF temp = d->transform.map(*points);
3026  coords.append(temp.x());
3027  coords.append(temp.y());
3028  }
3029  if (i == 0)
3030  segments.append(VG_MOVE_TO_ABS);
3031  else
3032  segments.append(VG_LINE_TO_ABS);
3033  }
3034  if (mode != QPaintEngine::PolylineMode)
3035  segments.append(VG_CLOSE_PATH);
3036  vgAppendPathData(path, segments.count(),
3037  segments.constData(), coords.constData());
3038  switch (mode) {
3040  d->draw(path, s->pen, s->brush, VG_NON_ZERO);
3041  break;
3042 
3044  d->stroke(path, s->pen);
3045  break;
3046 
3047  default:
3048  d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
3049  break;
3050  }
3051  vgDestroyPath(path);
3052 }
double d
Definition: qnumeric_p.h:62
const T * constData() const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
int count() const
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ drawPolygon() [2/2]

void QVGPaintEngine::drawPolygon ( const QPoint 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.

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 QPaintEngineEx.

Definition at line 3054 of file qpaintengine_vg.cpp.

3055 {
3057 
3058  if (d->needsEmulation()) {
3059  QPaintEngineEx::drawPolygon(points, pointCount, mode);
3060  return;
3061  }
3062 
3063  QVGPainterState *s = state();
3064  VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
3065  VG_PATH_DATATYPE_F,
3066  1.0f, // scale
3067  0.0f, // bias
3068  pointCount + 1, // segmentCapacityHint
3069  pointCount * 2, // coordCapacityHint
3070  VG_PATH_CAPABILITY_ALL);
3073  for (int i = 0; i < pointCount; ++i, ++points) {
3074  if (d->simpleTransform) {
3075  coords.append(points->x());
3076  coords.append(points->y());
3077  } else {
3078  QPointF temp = d->transform.map(QPointF(*points));
3079  coords.append(temp.x());
3080  coords.append(temp.y());
3081  }
3082  if (i == 0)
3083  segments.append(VG_MOVE_TO_ABS);
3084  else
3085  segments.append(VG_LINE_TO_ABS);
3086  }
3087  if (mode != QPaintEngine::PolylineMode)
3088  segments.append(VG_CLOSE_PATH);
3089  vgAppendPathData(path, segments.count(),
3090  segments.constData(), coords.constData());
3091  switch (mode) {
3093  d->draw(path, s->pen, s->brush, VG_NON_ZERO);
3094  break;
3095 
3097  d->stroke(path, s->pen);
3098  break;
3099 
3100  default:
3101  d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
3102  break;
3103  }
3104  vgDestroyPath(path);
3105 }
double d
Definition: qnumeric_p.h:62
const T * constData() const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
int count() const
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...
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QBrush brush
Definition: qpainter_p.h:153
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QVGPainterState * state()

◆ drawRects() [1/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2700 of file qpaintengine_vg.cpp.

2701 {
2702 #if !defined(QVG_NO_MODIFY_PATH)
2704  if (d->needsEmulation()) {
2705  QPaintEngineEx::drawRects(rects, rectCount);
2706  return;
2707  }
2708  QVGPainterState *s = state();
2709  for (int i = 0; i < rectCount; ++i, ++rects) {
2710  VGfloat coords[8];
2711  if (d->simpleTransform) {
2712  coords[0] = rects->x();
2713  coords[1] = rects->y();
2714  coords[2] = rects->x() + rects->width();
2715  coords[3] = coords[1];
2716  coords[4] = coords[2];
2717  coords[5] = rects->y() + rects->height();
2718  coords[6] = coords[0];
2719  coords[7] = coords[5];
2720  } else {
2721  QPointF tl = d->transform.map(QPointF(rects->x(), rects->y()));
2722  QPointF tr = d->transform.map(QPointF(rects->x() + rects->width(),
2723  rects->y()));
2724  QPointF bl = d->transform.map(QPointF(rects->x(),
2725  rects->y() + rects->height()));
2726  QPointF br = d->transform.map(QPointF(rects->x() + rects->width(),
2727  rects->y() + rects->height()));
2728  coords[0] = tl.x();
2729  coords[1] = tl.y();
2730  coords[2] = tr.x();
2731  coords[3] = tr.y();
2732  coords[4] = br.x();
2733  coords[5] = br.y();
2734  coords[6] = bl.x();
2735  coords[7] = bl.y();
2736  }
2737  vgModifyPathCoords(d->rectPath, 0, 4, coords);
2738  d->draw(d->rectPath, s->pen, s->brush);
2739  }
2740 #else
2741  QPaintEngineEx::drawRects(rects, rectCount);
2742 #endif
2743 }
double d
Definition: qnumeric_p.h:62
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
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
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QBrush brush
Definition: qpainter_p.h:153
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
QVGPainterState * state()

◆ drawRects() [2/2]

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 2745 of file qpaintengine_vg.cpp.

2746 {
2747 #if !defined(QVG_NO_MODIFY_PATH)
2749  if (d->needsEmulation()) {
2750  QPaintEngineEx::drawRects(rects, rectCount);
2751  return;
2752  }
2753  QVGPainterState *s = state();
2754  for (int i = 0; i < rectCount; ++i, ++rects) {
2755  VGfloat coords[8];
2756  if (d->simpleTransform) {
2757  coords[0] = rects->x();
2758  coords[1] = rects->y();
2759  coords[2] = rects->x() + rects->width();
2760  coords[3] = coords[1];
2761  coords[4] = coords[2];
2762  coords[5] = rects->y() + rects->height();
2763  coords[6] = coords[0];
2764  coords[7] = coords[5];
2765  } else {
2766  QPointF tl = d->transform.map(rects->topLeft());
2767  QPointF tr = d->transform.map(rects->topRight());
2768  QPointF bl = d->transform.map(rects->bottomLeft());
2769  QPointF br = d->transform.map(rects->bottomRight());
2770  coords[0] = tl.x();
2771  coords[1] = tl.y();
2772  coords[2] = tr.x();
2773  coords[3] = tr.y();
2774  coords[4] = br.x();
2775  coords[5] = br.y();
2776  coords[6] = bl.x();
2777  coords[7] = bl.y();
2778  }
2779  vgModifyPathCoords(d->rectPath, 0, 4, coords);
2780  d->draw(d->rectPath, s->pen, s->brush);
2781  }
2782 #else
2783  QPaintEngineEx::drawRects(rects, rectCount);
2784 #endif
2785 }
double d
Definition: qnumeric_p.h:62
QPointF bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:540
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
QPointF bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:542
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
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
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QBrush brush
Definition: qpainter_p.h:153
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 topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:541
QVGPainterState * state()

◆ drawRoundedRect()

void QVGPaintEngine::drawRoundedRect ( const QRectF rect,
qreal  xrad,
qreal  yrad,
Qt::SizeMode  mode 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2681 of file qpaintengine_vg.cpp.

2682 {
2684  if (d->needsEmulation()) {
2685  QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
2686  return;
2687  }
2688  if (d->simpleTransform) {
2689  QVGPainterState *s = state();
2690  VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
2691  d->draw(vgpath, s->pen, s->brush);
2692 #if defined(QVG_NO_MODIFY_PATH)
2693  vgDestroyPath(vgpath);
2694 #endif
2695  } else {
2696  QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
2697  }
2698 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ drawStaticTextItem()

void QVGPaintEngine::drawStaticTextItem ( QStaticTextItem staticTextItem)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3737 of file qpaintengine_vg.cpp.

3738 {
3739  drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->font, textItem->fontEngine(),
3740  QPointF(0, 0), textItem->glyphPositions);
3741 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font, QFontEngine *fontEngine, const QPointF &p, const QFixedPoint *positions)

◆ drawTextItem()

void QVGPaintEngine::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 3704 of file qpaintengine_vg.cpp.

3705 {
3706 #if !defined(QVG_NO_DRAW_GLYPHS)
3708  const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
3709 
3710  // If we are not using a simple transform, then fall back
3711  // to the default Qt path stroking algorithm.
3712  if (!d->simpleTransform) {
3713  QPaintEngineEx::drawTextItem(p, textItem);
3714  return;
3715  }
3716 
3717  if (d->needsPenEmulation()) {
3718  QPaintEngineEx::drawTextItem(p, textItem);
3719  return;
3720  }
3721 
3722  // Get the glyphs and positions associated with the text item.
3724  QVarLengthArray<glyph_t> glyphs;
3725  QTransform matrix;
3726  ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
3727 
3728  if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p, positions.data()))
3729  QPaintEngineEx::drawTextItem(p, textItem);
3730 #else
3731  // OpenGL 1.0 does not have support for VGFont and glyphs,
3732  // so fall back to the default Qt path stroking algorithm.
3733  QPaintEngineEx::drawTextItem(p, textItem);
3734 #endif
3735 }
double d
Definition: qnumeric_p.h:62
QFontEngine * fontEngine
RenderFlags flags
#define Q_D(Class)
Definition: qglobal.h:2482
QGlyphLayout glyphs
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)
Internal QTextItem.
QFont font() const
Returns the font that should be used to draw the text.
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font, QFontEngine *fontEngine, const QPointF &p, const QFixedPoint *positions)
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.

◆ drawTiledPixmap()

void QVGPaintEngine::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 QPaintEngineEx.

Definition at line 3464 of file qpaintengine_vg.cpp.

Referenced by drawImage().

3465 {
3466  QBrush brush(state()->pen.color(), pixmap);
3467  QTransform xform = QTransform::fromTranslate(r.x() - s.x(), r.y() - s.y());
3468  brush.setTransform(xform);
3469  fillRect(r, brush);
3470 }
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void fillRect(const QRectF &rect, const QBrush &brush)
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
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QVGPainterState * state()

◆ end()

bool QVGPaintEngine::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 1559 of file qpaintengine_vg.cpp.

1560 {
1561  vgSeti(VG_SCISSORING, VG_FALSE);
1562  vgSeti(VG_MASKING, VG_FALSE);
1563  return true;
1564 }

◆ endNativePainting()

void QVGPaintEngine::endNativePainting ( )
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3872 of file qpaintengine_vg.cpp.

3873 {
3875  // Exiting raw VG mode: force all state values to be
3876  // explicitly set on the VG engine to undo any changes
3877  // that were made by the raw VG function calls.
3878  QPaintEngine::DirtyFlags dirty = d->dirty;
3879  d->clearModes();
3880  d->forcePenChange = true;
3881  d->forceBrushChange = true;
3882  d->penType = (VGPaintType)0;
3883  d->brushType = (VGPaintType)0;
3884  d->clearColor = QColor();
3885  d->fillPaint = d->brushPaint;
3886  d->scissorDirty = true;
3888  d->dirty = dirty;
3889  d->rawVG = false;
3890  vgSetPaint(d->penPaint, VG_STROKE_PATH);
3891  vgSetPaint(d->brushPaint, VG_FILL_PATH);
3892 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void restoreState(QPaintEngine::DirtyFlags dirty)

◆ fill()

void QVGPaintEngine::fill ( const QVectorPath path,
const QBrush brush 
)
virtual

Implements QPaintEngineEx.

Definition at line 1584 of file qpaintengine_vg.cpp.

1585 {
1587  if (d->needsEmulation(brush)) {
1588  QPainter *p = painter();
1589  QBrush oldBrush = p->brush();
1590  p->setBrush(brush);
1592  p->setBrush(oldBrush);
1593  return;
1594  }
1595  VGPath vgpath = d->vectorPathToVGPath(path);
1596  if (!path.hasWindingFill())
1597  d->fill(vgpath, brush, VG_EVEN_ODD);
1598  else
1599  d->fill(vgpath, brush, VG_NON_ZERO);
1600  vgDestroyPath(vgpath);
1601 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
T * data() const
Returns the value of the pointer referenced by this object.
void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)
Definition: qpainter.cpp:9937
#define Q_D(Class)
Definition: qglobal.h:2482
QPainter * painter() const
Returns the paint engine&#39;s painter.
bool hasWindingFill() const
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
Q_GUI_EXPORT QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path)
QScopedPointer< QPainterPrivate > d_ptr
Definition: qpainter.h:546

◆ fillRect() [1/2]

void QVGPaintEngine::fillRect ( const QRectF rect,
const QBrush brush 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2588 of file qpaintengine_vg.cpp.

Referenced by drawTiledPixmap().

2589 {
2591 
2592  if (brush.style() == Qt::NoBrush)
2593  return;
2594 
2595  // Check to see if we can use vgClear() for faster filling.
2596  if (brush.style() == Qt::SolidPattern && brush.isOpaque() &&
2597  clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
2598  clearRect(rect, brush.color())) {
2599  return;
2600  }
2601 
2602  if (d->needsEmulation(brush)) {
2603  QPaintEngineEx::fillRect(rect, brush);
2604  return;
2605  }
2606 
2607 #if !defined(QVG_NO_MODIFY_PATH)
2608  VGfloat coords[8];
2609  if (d->simpleTransform) {
2610  coords[0] = rect.x();
2611  coords[1] = rect.y();
2612  coords[2] = rect.x() + rect.width();
2613  coords[3] = coords[1];
2614  coords[4] = coords[2];
2615  coords[5] = rect.y() + rect.height();
2616  coords[6] = coords[0];
2617  coords[7] = coords[5];
2618  } else {
2619  QPointF tl = d->transform.map(rect.topLeft());
2620  QPointF tr = d->transform.map(rect.topRight());
2621  QPointF bl = d->transform.map(rect.bottomLeft());
2622  QPointF br = d->transform.map(rect.bottomRight());
2623  coords[0] = tl.x();
2624  coords[1] = tl.y();
2625  coords[2] = tr.x();
2626  coords[3] = tr.y();
2627  coords[4] = br.x();
2628  coords[5] = br.y();
2629  coords[6] = bl.x();
2630  coords[7] = bl.y();
2631  }
2632  vgModifyPathCoords(d->rectPath, 0, 4, coords);
2633  d->fill(d->rectPath, brush);
2634 #else
2635  QPaintEngineEx::fillRect(rect, brush);
2636 #endif
2637 }
double d
Definition: qnumeric_p.h:62
QPointF bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:540
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
QPointF bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:542
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
virtual void fillRect(const QRectF &rect, const QBrush &brush)
bool clearRect(const QRectF &rect, const QColor &color)
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
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
Definition: qbrush.cpp:910
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
static bool clipTransformIsSimple(const QTransform &transform)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:541

◆ fillRect() [2/2]

void QVGPaintEngine::fillRect ( const QRectF rect,
const QColor color 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 2639 of file qpaintengine_vg.cpp.

2640 {
2642 
2643  // Check to see if we can use vgClear() for faster filling.
2644  if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 &&
2645  clearRect(rect, color)) {
2646  return;
2647  }
2648 
2649 #if !defined(QVG_NO_MODIFY_PATH)
2650  VGfloat coords[8];
2651  if (d->simpleTransform) {
2652  coords[0] = rect.x();
2653  coords[1] = rect.y();
2654  coords[2] = rect.x() + rect.width();
2655  coords[3] = coords[1];
2656  coords[4] = coords[2];
2657  coords[5] = rect.y() + rect.height();
2658  coords[6] = coords[0];
2659  coords[7] = coords[5];
2660  } else {
2661  QPointF tl = d->transform.map(rect.topLeft());
2662  QPointF tr = d->transform.map(rect.topRight());
2663  QPointF bl = d->transform.map(rect.bottomLeft());
2664  QPointF br = d->transform.map(rect.bottomRight());
2665  coords[0] = tl.x();
2666  coords[1] = tl.y();
2667  coords[2] = tr.x();
2668  coords[3] = tr.y();
2669  coords[4] = br.x();
2670  coords[5] = br.y();
2671  coords[6] = bl.x();
2672  coords[7] = bl.y();
2673  }
2674  vgModifyPathCoords(d->rectPath, 0, 4, coords);
2675  d->fill(d->rectPath, QBrush(color));
2676 #else
2677  QPaintEngineEx::fillRect(rect, QBrush(color));
2678 #endif
2679 }
double d
Definition: qnumeric_p.h:62
QPointF bottomRight() const
Returns the position of the rectangle&#39;s bottom-right corner.
Definition: qrect.h:540
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:539
QPointF bottomLeft() const
Returns the position of the rectangle&#39;s bottom-left corner.
Definition: qrect.h:542
#define Q_D(Class)
Definition: qglobal.h:2482
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
virtual void fillRect(const QRectF &rect, const QBrush &brush)
bool clearRect(const QRectF &rect, const QColor &color)
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
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
static bool clipTransformIsSimple(const QTransform &transform)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF topRight() const
Returns the position of the rectangle&#39;s top-right corner.
Definition: qrect.h:541

◆ fillRegion()

void QVGPaintEngine::fillRegion ( const QRegion region,
const QColor color,
const QSize surfaceSize 
)

Definition at line 3961 of file qpaintengine_vg.cpp.

Referenced by QVGWindowSurface::beginPaint(), and restoreState().

3962 {
3964  if (d->clearColor != color || d->clearOpacity != 1.0f) {
3965  VGfloat values[4];
3966  values[0] = color.redF();
3967  values[1] = color.greenF();
3968  values[2] = color.blueF();
3969  values[3] = color.alphaF();
3970  vgSetfv(VG_CLEAR_COLOR, 4, values);
3971  d->clearColor = color;
3972  d->clearOpacity = 1.0f;
3973  }
3974  if (region.rectCount() == 1) {
3975  QRect r = region.boundingRect();
3976  vgClear(r.x(), surfaceSize.height() - r.y() - r.height(),
3977  r.width(), r.height());
3978  } else {
3979  const QVector<QRect> rects = region.rects();
3980  for (int i = 0; i < rects.size(); ++i) {
3981  QRect r = rects.at(i);
3982  vgClear(r.x(), surfaceSize.height() - r.y() - r.height(),
3983  r.width(), r.height());
3984  }
3985  }
3986 }
double d
Definition: qnumeric_p.h:62
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_D(Class)
Definition: qglobal.h:2482
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
quint16 values[128]
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
int height() const
Returns the height.
Definition: qsize.h:129
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ isDefaultClipRect()

bool QVGPaintEngine::isDefaultClipRect ( const QRect rect)
private

Definition at line 2370 of file qpaintengine_vg.cpp.

Referenced by clip().

2371 {
2372  QPaintDevice *pdev = paintDevice();
2373  int width = pdev->width();
2374  int height = pdev->height();
2375 
2376  return (rect.x() == 0 && rect.y() == 0 &&
2377  rect.width() == width && rect.height() == height);
2378 }
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int height() const
Definition: qpaintdevice.h:92
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
int width() const
Definition: qpaintdevice.h:91
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

◆ isDefaultClipRegion()

bool QVGPaintEngine::isDefaultClipRegion ( const QRegion region)
private

Definition at line 2356 of file qpaintengine_vg.cpp.

Referenced by clip(), and updateScissor().

2357 {
2358  if (region.rectCount() != 1)
2359  return false;
2360 
2361  QPaintDevice *pdev = paintDevice();
2362  int width = pdev->width();
2363  int height = pdev->height();
2364 
2365  QRect rect = region.boundingRect();
2366  return (rect.x() == 0 && rect.y() == 0 &&
2367  rect.width() == width && rect.height() == height);
2368 }
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int height() const
Definition: qpaintdevice.h:92
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
int width() const
Definition: qpaintdevice.h:91
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
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ opacityChanged()

void QVGPaintEngine::opacityChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2435 of file qpaintengine_vg.cpp.

2436 {
2438  d->dirty |= QPaintEngine::DirtyOpacity;
2439  d->opacity = state()->opacity;
2440  d->forcePenChange = true;
2441  d->forceBrushChange = true;
2442 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QVGPainterState * state()

◆ penChanged()

void QVGPaintEngine::penChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2409 of file qpaintengine_vg.cpp.

2410 {
2412  d->dirty |= QPaintEngine::DirtyPen;
2413 
2414  d->hasExtendedRadialGradientPen =
2415  state()->pen.style() != Qt::NoPen && d->needsEmulation(state()->pen.brush());
2416 }
double d
Definition: qnumeric_p.h:62
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
#define Q_D(Class)
Definition: qglobal.h:2482
QBrush brush
Definition: qpainter_p.h:153
QVGPainterState * state()

◆ pixmapFilter()

QPixmapFilter * QVGPaintEngine::pixmapFilter ( int  type,
const QPixmapFilter prototype 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3894 of file qpaintengine_vg.cpp.

3895 {
3896 #if !defined(QT_SHIVAVG)
3898  switch (type) {
3900  if (!d->convolutionFilter)
3901  d->convolutionFilter.reset(new QVGPixmapConvolutionFilter);
3902  return d->convolutionFilter.data();
3904  if (!d->colorizeFilter)
3905  d->colorizeFilter.reset(new QVGPixmapColorizeFilter);
3906  return d->colorizeFilter.data();
3908  if (!d->dropShadowFilter)
3909  d->dropShadowFilter.reset(new QVGPixmapDropShadowFilter);
3910  return d->dropShadowFilter.data();
3912  if (!d->blurFilter)
3913  d->blurFilter.reset(new QVGPixmapBlurFilter);
3914  return d->blurFilter.data();
3915  default: break;
3916  }
3917 #endif
3918  return QPaintEngineEx::pixmapFilter(type, prototype);
3919 }
double d
Definition: qnumeric_p.h:62
Type type() const
Reimplement this function to return the paint engine Type.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QPixmapFilter * pixmapFilter(int, const QPixmapFilter *)

◆ renderHintsChanged()

void QVGPaintEngine::renderHintsChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2532 of file qpaintengine_vg.cpp.

2533 {
2535  d->dirty |= QPaintEngine::DirtyHints;
2536 
2537  QPainter::RenderHints hints = state()->renderHints;
2538 
2539  VGRenderingQuality rq =
2540  (hints & QPainter::Antialiasing)
2541  ? VG_RENDERING_QUALITY_BETTER
2542  : VG_RENDERING_QUALITY_NONANTIALIASED;
2543  VGImageQuality iq =
2545  ? VG_IMAGE_QUALITY_BETTER
2546  : VG_IMAGE_QUALITY_NONANTIALIASED;
2547 
2548  d->setRenderingQuality(rq);
2549  d->setImageQuality(iq);
2550 }
double d
Definition: qnumeric_p.h:62
QPainter::RenderHints renderHints
Definition: qpainter_p.h:158
#define Q_D(Class)
Definition: qglobal.h:2482
QVGPainterState * state()

◆ restoreState()

void QVGPaintEngine::restoreState ( QPaintEngine::DirtyFlags  dirty)
private

Definition at line 3921 of file qpaintengine_vg.cpp.

Referenced by begin().

3922 {
3924 
3925  // Restore the pen, brush, and other settings.
3926  if ((dirty & QPaintEngine::DirtyBrushOrigin) != 0)
3928  d->fillRule = 0;
3929  d->clearColor = QColor();
3930  if ((dirty & QPaintEngine::DirtyOpacity) != 0)
3931  opacityChanged();
3932  if ((dirty & QPaintEngine::DirtyTransform) != 0)
3933  transformChanged();
3934  if ((dirty & QPaintEngine::DirtyCompositionMode) != 0)
3936  if ((dirty & QPaintEngine::DirtyHints) != 0)
3938  if ((dirty & (QPaintEngine::DirtyClipRegion |
3941  d->maskValid = false;
3942  d->maskIsSet = false;
3943  d->scissorMask = false;
3944  d->maskRect = QRect();
3945  d->scissorDirty = true;
3947  }
3948 
3949 #if defined(QVG_SCISSOR_CLIP)
3950  if ((dirty & (QPaintEngine::DirtyClipRegion |
3953  updateScissor();
3954  }
3955 #else
3956  updateScissor();
3957 #endif
3958 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ setState()

void QVGPaintEngine::setState ( QPainterState s)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 3836 of file qpaintengine_vg.cpp.

3837 {
3840  QVGPainterState *ps = static_cast<QVGPainterState *>(s);
3841  if (ps->isNew) {
3842  // Newly created state object. The call to setState()
3843  // will either be followed by a call to begin(), or we are
3844  // setting the state as part of a save().
3845  ps->isNew = false;
3846  } else {
3847  // This state object was set as part of a restore().
3848  restoreState(d->dirty);
3849  d->dirty = ps->savedDirty;
3850  }
3851 }
double d
Definition: qnumeric_p.h:62
QPaintEngine::DirtyFlags savedDirty
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void setState(QPainterState *s)
void restoreState(QPaintEngine::DirtyFlags dirty)

◆ state() [1/2]

QVGPainterState* QVGPaintEngine::state ( )
inline

◆ state() [2/2]

const QVGPainterState* QVGPaintEngine::state ( ) const
inline

Definition at line 152 of file qpaintengine_vg_p.h.

152 { return static_cast<const QVGPainterState *>(QPaintEngineEx::state()); }
QPainterState * state()

◆ stroke()

void QVGPaintEngine::stroke ( const QVectorPath path,
const QPen pen 
)
virtual

Reimplemented from QPaintEngineEx.

Definition at line 1603 of file qpaintengine_vg.cpp.

1604 {
1606  if (d->needsEmulation(pen.brush())) {
1607  QPaintEngineEx::stroke(path, pen);
1608  return;
1609  }
1610  VGPath vgpath = d->vectorPathToVGPath(path);
1611  d->stroke(vgpath, pen);
1612  vgDestroyPath(vgpath);
1613 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void stroke(const QVectorPath &path, const QPen &pen)
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797

◆ supportsTransformations()

bool QVGPaintEngine::supportsTransformations ( qreal  ,
const QTransform  
) const
inlinevirtual

Reimplemented from QPaintEngineEx.

Definition at line 162 of file qpaintengine_vg_p.h.

162 { return true; }

◆ transformChanged()

void QVGPaintEngine::transformChanged ( )
virtual

Implements QPaintEngineEx.

Definition at line 2552 of file qpaintengine_vg.cpp.

2553 {
2555  QVGPainterState *s = state();
2556  d->dirty |= QPaintEngine::DirtyTransform;
2557  d->transform = s->transform();
2558  qreal oldPenScale = d->penScale;
2559  d->updateTransform(paintDevice());
2560  if (d->penScale != oldPenScale)
2561  d->forcePenChange = true;
2562 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
QTransform transform() const
Returns the matrix in the current paint engine state.
Definition: qpainter.cpp:9377
#define Q_D(Class)
Definition: qglobal.h:2482
QVGPainterState * state()

◆ type()

Type QVGPaintEngine::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 85 of file qpaintengine_vg_p.h.

Referenced by clipTransformIsSimple().

85 { return OpenVG; }

◆ updateScissor()

void QVGPaintEngine::updateScissor ( )
private

Definition at line 2242 of file qpaintengine_vg.cpp.

Referenced by clip(), clipEnabledChanged(), clipTransformIsSimple(), and QVGPaintEnginePrivate::ensureMask().

2243 {
2245 
2246  QRegion region = d->systemClip;
2247 
2248 #if defined(QVG_SCISSOR_CLIP)
2249  // Using the scissor to do clipping, so combine the systemClip
2250  // with the current painting clipRegion.
2251 
2252  if (d->maskValid) {
2253  vgSeti(VG_MASKING, VG_FALSE);
2254  d->maskValid = false;
2255  }
2256 
2257  QVGPainterState *s = state();
2258  if (s->clipEnabled) {
2259  if (region.isEmpty())
2260  region = s->clipRegion;
2261  else
2262  region = region.intersect(s->clipRegion);
2263  if (isDefaultClipRegion(region)) {
2264  // The scissor region is the entire drawing surface,
2265  // so there is no point doing any scissoring.
2266  vgSeti(VG_SCISSORING, VG_FALSE);
2267  d->scissorActive = false;
2268  d->scissorDirty = false;
2269  return;
2270  }
2271  } else
2272 #endif
2273  {
2274 #if !defined(QVG_SCISSOR_CLIP)
2275  // Combine the system clip with the simple mask rectangle.
2276  if (d->scissorMask) {
2277  if (region.isEmpty())
2278  region = d->maskRect;
2279  else
2280  region = region.intersect(d->maskRect);
2281  if (isDefaultClipRegion(region)) {
2282  // The scissor region is the entire drawing surface,
2283  // so there is no point doing any scissoring.
2284  vgSeti(VG_SCISSORING, VG_FALSE);
2285  d->scissorActive = false;
2286  d->scissorDirty = false;
2287  return;
2288  }
2289  } else
2290 #endif
2291 
2292  // Disable the scissor completely if the system clip is empty.
2293  if (region.isEmpty()) {
2294  vgSeti(VG_SCISSORING, VG_FALSE);
2295  d->scissorActive = false;
2296  d->scissorDirty = false;
2297  return;
2298  }
2299  }
2300 
2301  if (d->scissorActive && region == d->scissorRegion && !d->scissorDirty)
2302  return;
2303 
2304  QVector<QRect> rects = region.rects();
2305  int count = rects.count();
2306  if (count > d->maxScissorRects) {
2307 #if !defined(QVG_SCISSOR_CLIP)
2308  count = d->maxScissorRects;
2309 #else
2310  // Use masking
2311  int width = paintDevice()->width();
2312  int height = paintDevice()->height();
2313  vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK,
2314  0, 0, width, height);
2315  for (int i = 0; i < rects.size(); ++i) {
2316  vgMask(VG_INVALID_HANDLE, VG_FILL_MASK,
2317  rects[i].x(), height - rects[i].y() - rects[i].height(),
2318  rects[i].width(), rects[i].height());
2319  }
2320 
2321  vgSeti(VG_SCISSORING, VG_FALSE);
2322  vgSeti(VG_MASKING, VG_TRUE);
2323  d->maskValid = true;
2324  d->maskIsSet = false;
2325  d->scissorMask = false;
2326  d->scissorActive = false;
2327  d->scissorDirty = false;
2328  d->scissorRegion = region;
2329  return;
2330 #endif
2331  }
2332 
2333  QVarLengthArray<VGint> params(count * 4);
2334  int height = paintDevice()->height();
2335  for (int i = 0; i < count; ++i) {
2336  params[i * 4 + 0] = rects[i].x();
2337  params[i * 4 + 1] = height - rects[i].y() - rects[i].height();
2338  params[i * 4 + 2] = rects[i].width();
2339  params[i * 4 + 3] = rects[i].height();
2340  }
2341 
2342  vgSetiv(VG_SCISSOR_RECTS, count * 4, params.data());
2343  vgSeti(VG_SCISSORING, VG_TRUE);
2344  d->scissorDirty = false;
2345  d->scissorActive = true;
2346  d->scissorRegion = region;
2347 }
double d
Definition: qnumeric_p.h:62
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int height() const
Definition: qpaintdevice.h:92
#define Q_D(Class)
Definition: qglobal.h:2482
int width() const
Definition: qpaintdevice.h:91
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QRegion intersect(const QRegion &r) const
Use intersected(r) instead.
Definition: qregion.cpp:4249
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
bool isDefaultClipRegion(const QRegion &region)
uint clipEnabled
Definition: qpainter_p.h:169
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QVGPainterState * state()

◆ vgPrivate()

QVGPaintEnginePrivate* QVGPaintEngine::vgPrivate ( )
inline

Definition at line 159 of file qpaintengine_vg_p.h.

Referenced by qt_vg_drawVGImage(), qt_vg_drawVGImageStencil(), and QVGCompositionHelper::QVGCompositionHelper().

159 { Q_D(QVGPaintEngine); return d; }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

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