Qt 4.8
Public Functions | Public Variables | List of all members
QAlphaPaintEnginePrivate Class Reference

#include <qpaintengine_alpha_p.h>

Inheritance diagram for QAlphaPaintEnginePrivate:
QPaintEnginePrivate QPdfBaseEnginePrivate QWin32PrintEnginePrivate QPdfEnginePrivate QPSPrintEnginePrivate

Public Functions

void addAlphaRect (const QRectF &rect)
 
QRectF addPenWidth (const QPainterPath &path)
 
void drawAlphaImage (const QRectF &rect)
 
bool fullyContained (const QRectF &rect) const
 
 QAlphaPaintEnginePrivate ()
 
void resetState (QPainter *p)
 
QRect toRect (const QRectF &rect) const
 
 ~QAlphaPaintEnginePrivate ()
 
- Public Functions inherited from QPaintEnginePrivate
void drawBoxTextItem (const QPointF &p, const QTextItemInt &ti)
 
 QPaintEnginePrivate ()
 
void setSystemTransform (const QTransform &xform)
 
void setSystemViewport (const QRegion &region)
 
virtual void systemStateChanged ()
 
void transformSystemClip ()
 
virtual ~QPaintEnginePrivate ()
 

Public Variables

bool m_advancedBrush
 
bool m_advancedPen
 
bool m_alphaBrush
 
bool m_alphaOpacity
 
bool m_alphaPen
 
QRegion m_alphargn
 
QRegion m_cliprgn
 
bool m_complexTransform
 
bool m_continueCall
 
bool m_emulateProjectiveTransforms
 
bool m_hasalpha
 
int m_pass
 
QPaintDevicem_pdev
 
QPen m_pen
 
QPicturem_pic
 
QPaintEnginem_picengine
 
QPainterm_picpainter
 
QPaintEngine::PaintEngineFeatures m_savedcaps
 
QTransform m_transform
 
- Public Variables inherited from QPaintEnginePrivate
QWidgetcurrentClipWidget
 
uint hasSystemTransform: 1
 
uint hasSystemViewport: 1
 
QPaintDevicepdev
 
QPaintEngineq_ptr
 
QRegion systemClip
 
QRect systemRect
 
QTransform systemTransform
 
QRegion systemViewport
 

Detailed Description

Definition at line 91 of file qpaintengine_alpha_p.h.

Constructors and Destructors

◆ QAlphaPaintEnginePrivate()

QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate ( )

◆ ~QAlphaPaintEnginePrivate()

QAlphaPaintEnginePrivate::~QAlphaPaintEnginePrivate ( )

Definition at line 398 of file qpaintengine_alpha.cpp.

399 {
400  delete m_picpainter;
401  delete m_pic;
402 }

Functions

◆ addAlphaRect()

void QAlphaPaintEnginePrivate::addAlphaRect ( const QRectF rect)

Definition at line 437 of file qpaintengine_alpha.cpp.

438 {
439  m_alphargn |= toRect(rect);
440 }
QRect toRect(const QRectF &rect) const

◆ addPenWidth()

QRectF QAlphaPaintEnginePrivate::addPenWidth ( const QPainterPath path)

Definition at line 404 of file qpaintengine_alpha.cpp.

405 {
406  QPainterPath tmp = path;
407 
408  if (m_pen.style() == Qt::NoPen)
409  return (path.controlPointRect() * m_transform).boundingRect();
410  if (m_pen.isCosmetic())
411  tmp = path * m_transform;
412 
413  QPainterPathStroker stroker;
414  if (m_pen.widthF() == 0.0f)
415  stroker.setWidth(1.0);
416  else
417  stroker.setWidth(m_pen.widthF());
418  stroker.setJoinStyle(m_pen.joinStyle());
419  stroker.setCapStyle(m_pen.capStyle());
420  tmp = stroker.createStroke(tmp);
421  if (m_pen.isCosmetic())
422  return tmp.controlPointRect();
423 
424  return (tmp.controlPointRect() * m_transform).boundingRect();
425 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
static const QRectF boundingRect(const QPointF *points, int pointCount)
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Definition: qpen.cpp:840
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Definition: qpainterpath.h:264
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.

◆ drawAlphaImage()

void QAlphaPaintEnginePrivate::drawAlphaImage ( const QRectF rect)

Definition at line 442 of file qpaintengine_alpha.cpp.

443 {
445 
446  qreal dpiX = qMax(m_pdev->logicalDpiX(), 300);
447  qreal dpiY = qMax(m_pdev->logicalDpiY(), 300);
448  qreal xscale = (dpiX / m_pdev->logicalDpiX());
449  qreal yscale = (dpiY / m_pdev->logicalDpiY());
450 
451  QTransform picscale;
452  picscale.scale(xscale, yscale);
453 
454  const int tileSize = 2048;
455  QSize size((int(rect.width() * xscale)), int(rect.height() * yscale));
456  int divw = (size.width() / tileSize);
457  int divh = (size.height() / tileSize);
458  divw += 1;
459  divh += 1;
460 
461  int incx = int(rect.width() / divw);
462  int incy = int(rect.height() / divh);
463 
464  for (int y=0; y<divh; ++y) {
465  int ypos = int((incy * y) + rect.y());
466  int height = int((y == (divh - 1)) ? (rect.height() - (incy * y)) : incy) + 1;
467 
468  for (int x=0; x<divw; ++x) {
469  int xpos = int((incx * x) + rect.x());
470  int width = int((x == (divw - 1)) ? (rect.width() - (incx * x)) : incx) + 1;
471 
472  QSize imgsize((int)(width * xscale), (int)(height * yscale));
473  QImage img(imgsize, QImage::Format_RGB32);
474  img.fill(0xffffffff);
475 
476  QPainter imgpainter(&img);
477  imgpainter.setTransform(picscale);
478  QPointF picpos(qreal(-xpos), qreal(-ypos));
479  imgpainter.drawPicture(picpos, *m_pic);
480  imgpainter.end();
481 
482  q->painter()->setTransform(QTransform());
483  QRect r(xpos, ypos, width, height);
484  q->painter()->drawImage(r, img);
485  }
486  }
487 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
double qreal
Definition: qglobal.h:1193
int logicalDpiY() const
Definition: qpaintdevice.h:96
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
int logicalDpiX() const
Definition: qpaintdevice.h:95
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
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
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
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
static const int tileSize
Definition: qmemrotate.cpp:47
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ fullyContained()

bool QAlphaPaintEnginePrivate::fullyContained ( const QRectF rect) const

Definition at line 489 of file qpaintengine_alpha.cpp.

490 {
491  QRegion r(toRect(rect));
492  return (m_cliprgn.intersected(r) == r);
493 }
QRegion intersected(const QRegion &r) const
Returns a region which is the intersection of this region and r.
Definition: qregion.h:112
QRect toRect(const QRectF &rect) const
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68

◆ resetState()

void QAlphaPaintEnginePrivate::resetState ( QPainter p)

Definition at line 495 of file qpaintengine_alpha.cpp.

496 {
497  p->setPen(QPen());
498  p->setBrush(QBrush());
499  p->setBrushOrigin(0,0);
500  p->setBackground(QBrush());
501  p->setFont(QFont());
502  p->setTransform(QTransform());
503  // The view transform is already recorded and included in the
504  // picture we're about to replay. If we don't turn if off,
505  // the view matrix will be applied twice.
506  p->setViewTransformEnabled(false);
509  p->setClipping(false);
510  p->setOpacity(1.0f);
511 }
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9547
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setBrushOrigin(int x, int y)
Sets the brush&#39;s origin to point (x, y).
Definition: qpainter.h:825
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false...
Definition: qpainter.cpp:7906
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
Definition: qpainter.cpp:2917
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
Definition: qpainter.cpp:2517
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
Definition: qpainter.cpp:3365
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
Definition: qpainter.cpp:2139
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
Definition: qpainter.cpp:4258
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ toRect()

QRect QAlphaPaintEnginePrivate::toRect ( const QRectF rect) const

Definition at line 427 of file qpaintengine_alpha.cpp.

Referenced by addAlphaRect(), and fullyContained().

428 {
429  QRect r;
430  r.setLeft(int(rect.left()));
431  r.setTop(int(rect.top()));
432  r.setRight(int(rect.right() + 1));
433  r.setBottom(int(rect.bottom() + 1));
434  return r;
435 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528

Properties

◆ m_advancedBrush

bool QAlphaPaintEnginePrivate::m_advancedBrush

Definition at line 114 of file qpaintengine_alpha_p.h.

◆ m_advancedPen

bool QAlphaPaintEnginePrivate::m_advancedPen

Definition at line 113 of file qpaintengine_alpha_p.h.

◆ m_alphaBrush

bool QAlphaPaintEnginePrivate::m_alphaBrush

Definition at line 111 of file qpaintengine_alpha_p.h.

◆ m_alphaOpacity

bool QAlphaPaintEnginePrivate::m_alphaOpacity

Definition at line 112 of file qpaintengine_alpha_p.h.

◆ m_alphaPen

bool QAlphaPaintEnginePrivate::m_alphaPen

Definition at line 110 of file qpaintengine_alpha_p.h.

◆ m_alphargn

QRegion QAlphaPaintEnginePrivate::m_alphargn

Definition at line 106 of file qpaintengine_alpha_p.h.

Referenced by addAlphaRect().

◆ m_cliprgn

QRegion QAlphaPaintEnginePrivate::m_cliprgn

Definition at line 107 of file qpaintengine_alpha_p.h.

Referenced by fullyContained().

◆ m_complexTransform

bool QAlphaPaintEnginePrivate::m_complexTransform

Definition at line 115 of file qpaintengine_alpha_p.h.

◆ m_continueCall

bool QAlphaPaintEnginePrivate::m_continueCall

Definition at line 117 of file qpaintengine_alpha_p.h.

◆ m_emulateProjectiveTransforms

bool QAlphaPaintEnginePrivate::m_emulateProjectiveTransforms

Definition at line 116 of file qpaintengine_alpha_p.h.

◆ m_hasalpha

bool QAlphaPaintEnginePrivate::m_hasalpha

Definition at line 109 of file qpaintengine_alpha_p.h.

◆ m_pass

int QAlphaPaintEnginePrivate::m_pass

Definition at line 98 of file qpaintengine_alpha_p.h.

◆ m_pdev

QPaintDevice* QAlphaPaintEnginePrivate::m_pdev

Definition at line 104 of file qpaintengine_alpha_p.h.

Referenced by drawAlphaImage().

◆ m_pen

QPen QAlphaPaintEnginePrivate::m_pen

Definition at line 120 of file qpaintengine_alpha_p.h.

Referenced by addPenWidth().

◆ m_pic

QPicture* QAlphaPaintEnginePrivate::m_pic

Definition at line 99 of file qpaintengine_alpha_p.h.

Referenced by drawAlphaImage(), and ~QAlphaPaintEnginePrivate().

◆ m_picengine

QPaintEngine* QAlphaPaintEnginePrivate::m_picengine

Definition at line 100 of file qpaintengine_alpha_p.h.

◆ m_picpainter

QPainter* QAlphaPaintEnginePrivate::m_picpainter

Definition at line 101 of file qpaintengine_alpha_p.h.

Referenced by ~QAlphaPaintEnginePrivate().

◆ m_savedcaps

QPaintEngine::PaintEngineFeatures QAlphaPaintEnginePrivate::m_savedcaps

Definition at line 103 of file qpaintengine_alpha_p.h.

◆ m_transform

QTransform QAlphaPaintEnginePrivate::m_transform

Definition at line 119 of file qpaintengine_alpha_p.h.

Referenced by addPenWidth().


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