QRasterPaintEngine Class Reference

#include <qpaintengine_raster_p.h>

Inheritance diagram for QRasterPaintEngine:

Inheritance graph
[legend]
Collaboration diagram for QRasterPaintEngine:

Collaboration graph
[legend]
List of all members.

Detailed Description

The QRasterPaintEngine class enables acceleration of painting operations using the available hardware.

Since:
4.2
Note that this functionality is only available in Qtopia Core.

In Qtopia Core, painting is a pure software implementation. But starting with Qtopia Core 4.2, it is possible to add an accelerated graphics driver to take advantage of available hardware resources.

The painting operations can be accelerated by deriving from the QRasterPaintEngine and QCustomRasterPaintDevice classes. Note that there are several other issues to be aware of; see the {Adding an Accelerated Graphics Driver in Qtopia Core} documentation for details.

See also:
QCustomRasterPaintDevice, QPaintEngine

Definition at line 55 of file qpaintengine_raster_p.h.

Public Member Functions

 QRasterPaintEngine ()
 ~QRasterPaintEngine ()
bool begin (QPaintDevice *device)
bool end ()
void updateState (const QPaintEngineState &state)
void updateMatrix (const QMatrix &matrix)
void updateClipRegion (const QRegion &region, Qt::ClipOperation op)
void updateClipPath (const QPainterPath &path, Qt::ClipOperation op)
void drawPath (const QPainterPath &path)
void drawPolygon (const QPointF *points, int pointCount, PolygonDrawMode mode)
void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
void fillPath (const QPainterPath &path, QSpanData *fillData)
void drawEllipse (const QRectF &rect)
void drawRects (const QRect *rects, int rectCount)
void drawRects (const QRectF *rects, int rectCount)
void drawPixmap (const QRectF &r, const QPixmap &pm, const QRectF &sr)
void drawImage (const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags falgs=Qt::AutoColor)
void drawTiledPixmap (const QRectF &r, const QPixmap &pm, const QPointF &sr)
void drawTextItem (const QPointF &p, const QTextItem &textItem)
void drawLines (const QLine *line, int lineCount)
void drawLines (const QLineF *line, int lineCount)
void drawPoints (const QPointF *points, int pointCount)
void setFlushOnEnd (bool flush)
void flush (QPaintDevice *device, const QPoint &offset)
void releaseBuffer ()
QSize size () const
void saveBuffer (const QString &s) const
Type type () const
QPoint coordinateOffset () const

Protected Member Functions

 QRasterPaintEngine (QRasterPaintEnginePrivate &d)

Private Member Functions

void init ()

Related Functions

(Note that these are not member functions.)

 QSpan


Constructor & Destructor Documentation

QRasterPaintEngine::QRasterPaintEngine (  ) 

Creates a raster based paint engine with the complete set of {QPaintEngine::PaintEngineFeature}{paint engine features and capabilities}.

Definition at line 580 of file qpaintengine_raster.cpp.

References init().

00581     : QPaintEngine(*(new QRasterPaintEnginePrivate),
00582                    QPaintEngine::PaintEngineFeatures(AllFeatures)
00583         )
00584 {
00585     init();
00586 }

Here is the call graph for this function:

QRasterPaintEngine::~QRasterPaintEngine (  ) 

Destroys the paint engine.

Definition at line 638 of file qpaintengine_raster.cpp.

References d.

00639 {
00640     Q_D(QRasterPaintEngine);
00641 
00642 #if defined(Q_WS_WIN64)
00643     _aligned_free(d->rasterPoolBase);
00644 #else
00645     free(d->rasterPoolBase);
00646 #endif
00647 
00648     qt_ft_grays_raster.raster_done(*d->grayRaster);
00649     delete d->grayRaster;
00650 
00651     qt_ft_standard_raster.raster_done(*d->blackRaster);
00652     delete d->blackRaster;
00653 
00654 
00655     delete d->rasterBuffer;
00656     delete d->outlineMapper;
00657 #ifdef Q_WS_WIN
00658     delete d->fontRasterBuffer;
00659 #endif
00660 
00661     delete d->dashStroker;
00662 }

QRasterPaintEngine::QRasterPaintEngine ( QRasterPaintEnginePrivate d  )  [protected]

Definition at line 591 of file qpaintengine_raster.cpp.

References init().

00592     : QPaintEngine(dd, QPaintEngine::PaintEngineFeatures(AllFeatures))
00593 {
00594     init();
00595 }

Here is the call graph for this function:


Member Function Documentation

bool QRasterPaintEngine::begin ( QPaintDevice device  )  [virtual]

Implements QPaintEngine.

Definition at line 667 of file qpaintengine_raster.cpp.

References Qt::black, BOOL, Qt::color0, Qt::color1, QInternal::CustomRaster, d, data, QPaintDevice::depth(), QPaintDevice::devType(), QPaintEngine::DirtyBrushOrigin, QImage::Format_ARGB32, QImage::Format_ARGB32_Premultiplied, QImage::Format_Mono, QImage::Format_MonoLSB, QImage::Format_RGB16, QImage::Format_RGB32, QPaintEngine::gccaps, QPaintDevice::height(), image, QInternal::Image, QRegion::isEmpty(), Qt::NoBrush, Qt::NoClip, QPaintEngine::PaintOutsidePaintEvent, QInternal::Pixmap, QPaintEngine::PorterDuff, qInitDrawhelperAsm(), qWarning(), QPaintEngine::setActive(), QPaintEngine::setDirty(), QPaintEngine::systemClip(), QPainterPrivate::TxNone, updateClipPath(), updateClipRegion(), QInternal::Widget, and QPaintDevice::width().

00668 {
00669     Q_D(QRasterPaintEngine);
00670 
00671     // ####### move to QApp
00672     qInitDrawhelperAsm();
00673     d->deviceDepth = device->depth();
00674     d->antialiased = false;
00675     d->bilinear = false;
00676     d->mono_surface = false;
00677     d->fast_pen = true;
00678     d->int_xform = true;
00679     d->user_clip_enabled = false;
00680     d->opacity = 256;
00681 
00682     d->inverseScale = qreal(1);
00683 
00684 #if defined(Q_WS_WIN)
00685     d->clear_type_text = false;
00686     QT_WA({
00687         UINT result;
00688         BOOL ok;
00689         ok = SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
00690         if (ok)
00691             d->clear_type_text = (result == FE_FONTSMOOTHINGCLEARTYPE);
00692     }, {
00693         UINT result;
00694         BOOL ok;
00695         ok = SystemParametersInfoA(SPI_GETFONTSMOOTHINGTYPE, 0, &result, 0);
00696         if (ok)
00697             d->clear_type_text = (result == FE_FONTSMOOTHINGCLEARTYPE);
00698     });
00699 #endif
00700 
00701     d->rasterBuffer->init();
00702 
00703 #if defined(Q_WS_WIN)
00704     d->fontRasterBuffer->setupHDC(d->clear_type_text);
00705 #endif
00706 
00707     d->deviceRect = QRect(0, 0, device->width(), device->height());
00708 
00709 
00710     gccaps &= ~PorterDuff;
00711 
00712     // reset paintevent clip
00713     d->baseClip = QPainterPath();
00714     if (device->devType() == QInternal::Widget) {
00715         QRegion sysClip = systemClip();
00716         if (!sysClip.isEmpty()) {
00717             d->baseClip.addRegion(sysClip);
00718             d->deviceRect = sysClip.boundingRect();
00719             // Shift the baseclip to absolute
00720             d->baseClip = d->baseClip * QMatrix(1, 0, 0, 1,
00721                                                 -d->deviceRect.x(),
00722                                                 -d->deviceRect.y());
00723         }
00724         gccaps &= ~PaintOutsidePaintEvent;
00725     }
00726 #if defined(Q_WS_QWS)
00727     else if (device->devType() == QInternal::Pixmap) {
00728         // Only embedded uses system clipping on pixmaps
00729         QRegion sysClip = systemClip();
00730         if (!sysClip.isEmpty())
00731             d->baseClip.addRegion(sysClip);
00732     }
00733 #endif
00734     else {
00735         QRegion sysClip = systemClip();
00736         if (!sysClip.isEmpty()) {
00737             d->baseClip.addRegion(sysClip);
00738         }
00739     }
00740 
00741 #if defined(Q_WS_WIN) || defined(Q_WS_QWS)
00742     if (device->devType() == QInternal::Pixmap) {
00743         QPixmap *pixmap = static_cast<QPixmap *>(device);
00744         if (pixmap->isNull()) {
00745             qWarning("Cannot paint on a null pixmap");
00746             return false;
00747         }
00748         QPixmapData *data = static_cast<QPixmap *>(device)->data;
00749         device = &data->image;
00750     }
00751 #elif defined(Q_WS_MAC)
00752     if (device->devType() == QInternal::Pixmap) {
00753         QPixmap *pixmap = static_cast<QPixmap *>(device);
00754         if (pixmap->isNull()) {
00755             qWarning("Cannot paint on a null pixmap");
00756             return false;
00757         }
00758         d->rasterBuffer->prepare(pixmap);
00759     }
00760 #endif
00761 
00762     if (device->devType() == QInternal::Image) {
00763         QImage *image = static_cast<QImage *>(device);
00764         int format = image->format();
00765         d->flushOnEnd = false;
00766 
00767         d->rasterBuffer->prepare(image);
00768         if (format == QImage::Format_MonoLSB) {
00769             d->mono_surface = true;
00770         } else if (format == QImage::Format_Mono) {
00771             d->mono_surface = true;
00772         } else if (format == QImage::Format_RGB32) {
00773             ;
00774         } else if (format == QImage::Format_ARGB32_Premultiplied) {
00775             gccaps |= PorterDuff;
00776         } else if (format == QImage::Format_ARGB32) {
00777             gccaps |= PorterDuff;
00778 #ifdef Q_WS_QWS
00779         } else if (format == QImage::Format_RGB16) {
00780             ;
00781 #endif
00782         } else {
00783             qWarning("QRasterPaintEngine::begin: Unsupported image format (%d)", format);
00784             return false;
00785         }
00786 #ifdef Q_WS_QWS
00787     } else if (device->devType() == QInternal::CustomRaster) {
00788         QCustomRasterPaintDevice *dev = static_cast<QCustomRasterPaintDevice*>(device);
00789         d->rasterBuffer->prepare(dev);
00790 #endif
00791     } else {
00792         d->rasterBuffer->prepare(d->deviceRect.width(), d->deviceRect.height());
00793     }
00794 
00795     d->rasterBuffer->resetClip();
00796 
00797     d->matrix = QMatrix();
00798     d->txop = QPainterPrivate::TxNone;
00799 
00800     d->outlineMapper->setMatrix(d->matrix, d->txop);
00801     d->outlineMapper->m_clipper.setBoundingRect(d->deviceRect.adjusted(-10, -10, 10, 10));
00802 
00803     if (device->depth() == 1) {
00804         d->pen = QPen(Qt::color1);
00805         d->brush = QBrush(Qt::color0);
00806     } else {
00807         d->pen = QPen(Qt::black);
00808         d->brush = QBrush(Qt::NoBrush);
00809     }
00810 
00811     d->penData.init(d->rasterBuffer, this);
00812     d->penData.setup(d->pen.brush(), d->opacity);
00813     d->stroker = &d->basicStroker;
00814     d->basicStroker.setClipRect(d->deviceRect);
00815 
00816     d->brushData.init(d->rasterBuffer, this);
00817     d->brushData.setup(d->brush, d->opacity);
00818 
00819 #ifdef QT_EXPERIMENTAL_REGIONS
00820     updateClipRegion(QRegion(), Qt::NoClip);
00821 #else
00822     updateClipPath(QPainterPath(), Qt::NoClip);
00823 #endif
00824 
00825     setDirty(DirtyBrushOrigin);
00826 
00827     setActive(true);
00828     return true;
00829 }

Here is the call graph for this function:

bool QRasterPaintEngine::end (  )  [virtual]

Implements QPaintEngine.

Definition at line 834 of file qpaintengine_raster.cpp.

References d, flush(), and QPaintEngine::setActive().

Referenced by drawPoints().

00835 {
00836     Q_D(QRasterPaintEngine);
00837 
00838     if (d->flushOnEnd)
00839         flush(d->pdev, QPoint());
00840 
00841     if (d->rasterBuffer->disabled_clip) {
00842         delete d->rasterBuffer->disabled_clip;
00843         d->rasterBuffer->disabled_clip = 0;
00844     }
00845 
00846     setActive(false);
00847 
00848 #ifdef Q_WS_QWS
00849     qResetDrawhelper();
00850 #endif
00851 
00852     return true;
00853 }

Here is the call graph for this function:

void QRasterPaintEngine::updateState ( const QPaintEngineState state  )  [virtual]

Implements QPaintEngine.

Definition at line 1011 of file qpaintengine_raster.cpp.

References QPainter::Antialiasing, QPaintEngineState::brush(), QPaintEngineState::brushOrigin(), QPaintEngineState::clipOperation(), QPaintEngineState::clipPath(), QPaintEngineState::clipRegion(), QPaintEngineState::compositionMode(), Qt::CustomDashLine, d, QPaintEngine::DirtyBrush, QPaintEngine::DirtyBrushOrigin, QPaintEngine::DirtyClipEnabled, QPaintEngine::DirtyClipPath, QPaintEngine::DirtyClipRegion, QPaintEngine::DirtyCompositionMode, QPaintEngine::DirtyHints, QPaintEngine::DirtyOpacity, QPaintEngine::DirtyPen, QPaintEngine::DirtyTransform, QPainterPath::fillRule(), flags, QPaintEngineState::isClipEnabled(), QPaintEngineState::matrix(), Qt::NoClip, Qt::NoPen, QPaintEngineState::opacity(), QPaintEngineState::pen(), qRound(), QPaintEngineState::renderHints(), QPainter::SmoothPixmapTransform, Qt::SolidLine, QPaintEngineState::state(), QPaintEngine::state, QPainterPath::toFillPolygon(), QPolygonF::toPolygon(), QPainterPrivate::TxTranslate, updateClipPath(), updateClipRegion(), and updateMatrix().

01012 {
01013     Q_D(QRasterPaintEngine);
01014 
01015     QPaintEngine::DirtyFlags flags = state.state();
01016 
01017     bool update_fast_pen = false;
01018 
01019     if (flags & DirtyTransform) {
01020         update_fast_pen = true;
01021         updateMatrix(state.matrix());
01022     }
01023 
01024     if (flags & DirtyOpacity) {
01025         update_fast_pen = true;
01026         d->opacity = qRound(state.opacity() * 256.0);
01027         if (d->opacity > 256)
01028             d->opacity = 256;
01029         if (d->opacity < 0)
01030             d->opacity = 0;
01031 
01032         // Force update pen/brush as to get proper alpha colors propagated
01033         flags |= DirtyPen;
01034         flags |= DirtyBrush;
01035     }
01036 
01037     if (flags & DirtyPen) {
01038         update_fast_pen = true;
01039         d->pen = state.pen();
01040 
01041         if (d->pen.style() == Qt::CustomDashLine && d->pen.dashPattern().size() == 0)
01042             d->pen.setStyle(Qt::SolidLine);
01043 
01044         d->basicStroker.setJoinStyle(d->pen.joinStyle());
01045         d->basicStroker.setCapStyle(d->pen.capStyle());
01046         d->basicStroker.setMiterLimit(d->pen.miterLimit());
01047 
01048         qreal penWidth = d->pen.widthF();
01049         if (penWidth == 0)
01050             d->basicStroker.setStrokeWidth(1);
01051         else
01052             d->basicStroker.setStrokeWidth(penWidth);
01053 
01054         Qt::PenStyle pen_style = d->pen.style();
01055         if(pen_style == Qt::SolidLine) {
01056             d->stroker = &d->basicStroker;
01057         } else if (pen_style != Qt::NoPen) {
01058             if (!d->dashStroker)
01059                 d->dashStroker = new QDashStroker(&d->basicStroker);
01060             if (penWidth == 0) {
01061                 d->dashStroker->setClipRect(d->deviceRect);
01062             } else {
01063                 QRectF clipRect = d->matrix.inverted().mapRect(QRectF(d->deviceRect));
01064                 d->dashStroker->setClipRect(clipRect);
01065             }
01066             d->dashStroker->setDashPattern(d->pen.dashPattern());
01067             d->stroker = d->dashStroker;
01068         } else {
01069             d->stroker = 0;
01070         }
01071         d->penData.setup(pen_style == Qt::NoPen ? QBrush() : d->pen.brush(), d->opacity);
01072     }
01073 
01074     if (flags & (DirtyBrush|DirtyBrushOrigin)) {
01075         QBrush brush = state.brush();
01076         d->brush = brush;
01077         d->brushOffset = state.brushOrigin();
01078         d->brushData.setup(d->brush, d->opacity);
01079         d->brushData.setupMatrix((d->brushMatrix().inverted() * d->brush.matrix().inverted()).inverted(),
01080                                  d->txop, d->bilinear);
01081     }
01082 
01083     if (flags & (DirtyClipPath | DirtyClipRegion)) {
01084         d->user_clip_enabled = true;
01085         // If we're setting a clip, we kill the old clip
01086         if (d->rasterBuffer->disabled_clip) {
01087             delete d->rasterBuffer->disabled_clip;
01088             d->rasterBuffer->disabled_clip = 0;
01089         }
01090     }
01091 
01092     if (flags & DirtyClipPath) {
01093 #ifdef QT_EXPERIMENTAL_REGIONS
01094         QPolygon polygon = state.clipPath().toFillPolygon().toPolygon();
01095         updateClipRegion(QRegion(polygon, state.clipPath().fillRule()),
01096                          state.clipOperation());
01097 #else
01098         updateClipPath(state.clipPath(), state.clipOperation());
01099 
01100 #endif
01101     } else if (flags & DirtyClipRegion) {
01102         updateClipRegion(state.clipRegion(), state.clipOperation());
01103 
01104     } else if (flags & DirtyClipEnabled) {
01105 
01106         if (state.isClipEnabled() != d->user_clip_enabled) {
01107             d->user_clip_enabled = state.isClipEnabled();
01108 
01109             // The tricky case... When we disable clipping we still do
01110             // system clip so we need to rasterize the system clip and
01111             // replace the current clip with it. Since people might
01112             // choose to set clipping to true later on we have to the
01113             // current one (in disabled_clip).
01114             if (!d->baseClip.isEmpty()) {
01115                 if (!state.isClipEnabled()) { // save current clip for later
01116                     Q_ASSERT(!d->rasterBuffer->disabled_clip);
01117                     d->rasterBuffer->disabled_clip = d->rasterBuffer->clip;
01118                     d->rasterBuffer->clip = 0;
01119 #ifdef QT_EXPERIMENTAL_REGIONS
01120                     updateClipRegion(QRegion(), Qt::NoClip);
01121 #else
01122                     updateClipPath(QPainterPath(), Qt::NoClip);
01123 #endif
01124                 } else { // re-enable old clip
01125                     Q_ASSERT(d->rasterBuffer->disabled_clip);
01126                     d->rasterBuffer->resetClip();
01127                     d->rasterBuffer->clip = d->rasterBuffer->disabled_clip;
01128                     d->rasterBuffer->disabled_clip = 0;
01129                 }
01130             } else {
01131                 if (!state.isClipEnabled()) {
01132 #ifdef QT_EXPERIMENTAL_REGIONS
01133                     updateClipRegion(QRegion(), Qt::NoClip);
01134 #else
01135                     updateClipPath(QPainterPath(), Qt::NoClip);
01136 #endif
01137                 } else {
01138 #ifdef QT_EXPERIMENTAL_REGIONS
01139                     updateClipRegion(state.clipRegion(), state.clipOperation());
01140 #else
01141                     updateClipPath(state.clipPath(), state.clipOperation());
01142 #endif
01143                 }
01144             }
01145             d->penData.adjustSpanMethods();
01146             d->brushData.adjustSpanMethods();
01147         }
01148     }
01149 
01150     if (!d->mono_surface) {
01151         if (flags & DirtyHints) {
01152             update_fast_pen = true;
01153             d->antialiased = bool(state.renderHints() & QPainter::Antialiasing);
01154             d->bilinear = bool(state.renderHints() & QPainter::SmoothPixmapTransform);
01155             // propegate state to data's
01156             d->brushData.bilinear = d->penData.bilinear = d->bilinear;
01157             d->penData.adjustSpanMethods();
01158             d->brushData.adjustSpanMethods();
01159 
01160         }
01161 
01162         if (flags & DirtyCompositionMode) {
01163             d->rasterBuffer->compositionMode = state.compositionMode();
01164         }
01165     }
01166 
01167     if (update_fast_pen) {
01168         d->fast_pen = !d->antialiased
01169                       && (d->pen.widthF() == 0
01170                           || d->pen.widthF() <= 1 && d->txop <= QPainterPrivate::TxTranslate);
01171     }
01172 }

Here is the call graph for this function:

void QRasterPaintEngine::updateMatrix ( const QMatrix matrix  ) 

Definition at line 971 of file qpaintengine_raster.cpp.

References d, QMatrix::m11(), QMatrix::m12(), QMatrix::m21(), QMatrix::m22(), qMax(), QPainterPrivate::TxNone, QPainterPrivate::TxRotShear, QPainterPrivate::TxScale, and QPainterPrivate::TxTranslate.

Referenced by updateState().

00972 {
00973     Q_D(QRasterPaintEngine);
00974 
00975     d->matrix = matrix;
00976     d->int_xform = false;
00977     if (d->matrix.m12() != 0 || d->matrix.m21() != 0) {
00978         d->txop = QPainterPrivate::TxRotShear;
00979     } else if (d->matrix.m11() != 1 || d->matrix.m22() != 1) {
00980         d->txop = QPainterPrivate::TxScale;
00981         d->int_xform = qreal(int(d->matrix.dx())) == d->matrix.dx()
00982                             && qreal(int(d->matrix.dy())) == d->matrix.dy()
00983                             && qreal(int(d->matrix.m11())) == d->matrix.m11()
00984                             && qreal(int(d->matrix.m22())) == d->matrix.m22();
00985     } else if (d->matrix.dx() != 0 || d->matrix.dy() != 0) {
00986         d->txop = QPainterPrivate::TxTranslate;
00987         d->int_xform = qreal(int(d->matrix.dx())) == d->matrix.dx()
00988                             && qreal(int(d->matrix.dy())) == d->matrix.dy();
00989     } else {
00990         d->txop = QPainterPrivate::TxNone;
00991         d->int_xform = true;
00992     }
00993 
00994     // 1/10000 == 0.0001, so we have good enough res to cover curves
00995     // that span the entire widget...
00996     d->inverseScale = qMax(1 / qMax( qMax(qAbs(matrix.m11()), qAbs(matrix.m22())),
00997                                      qMax(qAbs(matrix.m12()), qAbs(matrix.m21())) ),
00998                            qreal(0.0001));
00999 
01000     d->outlineMapper->setMatrix(d->matrix, d->txop);
01001     QMatrix penMatrix = (d->matrix.inverted()*d->pen.brush().matrix().inverted()).inverted();
01002     d->penData.setupMatrix(penMatrix,
01003                            d->txop, d->bilinear);
01004     QMatrix brushMatrix = (d->brushMatrix().inverted() * d->brush.matrix().inverted()).inverted();
01005     d->brushData.setupMatrix(brushMatrix, d->txop, d->bilinear);
01006 }

Here is the call graph for this function:

void QRasterPaintEngine::updateClipRegion ( const QRegion region,
Qt::ClipOperation  op 
)

Definition at line 1177 of file qpaintengine_raster.cpp.

References d, Qt::IntersectClip, QRegion::isEmpty(), Qt::NoClip, p, qDebug(), Qt::ReplaceClip, QPaintEngine::systemClip(), Qt::UniteClip, and updateClipPath().

Referenced by begin(), and updateState().

01178 {
01179 #ifdef QT_DEBUG_DRAW
01180     qDebug() << " - QRasterPaintEngine::updateClipRegion() op=" << op << r;
01181 #endif
01182 
01183 #ifdef QT_EXPERIMENTAL_REGIONS
01184     Q_D(QRasterPaintEngine);
01185 
01186     switch (op) {
01187     case Qt::NoClip:
01188         d->clipRegion = d->deviceRect;
01189         break;
01190     case Qt::IntersectClip:
01191         d->clipRegion &= d->matrix.map(r);
01192         break;
01193     case Qt::ReplaceClip:
01194         if (r.isEmpty())
01195             d->clipRegion = d->deviceRect;
01196         else
01197             d->clipRegion = d->matrix.map(r);
01198         break;
01199     case Qt::UniteClip:
01200         d->clipRegion |= d->matrix.map(r);
01201         break;
01202     default:
01203         break;
01204     }
01205 
01206     const QRegion sysClip = systemClip();
01207     if (!sysClip.isEmpty())
01208         d->clipRegion &= sysClip;
01209 
01210     if (!d->clipRegion.isEmpty() && d->clipRegion.rects().count() == 1) {
01211         d->setSimpleClip(d->clipRegion.boundingRect());
01212         return;
01213     }
01214 #endif // QT_EXPERIMENTAL_REGIONS
01215 
01216     QPainterPath p;
01217     p.addRegion(r);
01218     updateClipPath(p, op);
01219 }

Here is the call graph for this function:

void QRasterPaintEngine::updateClipPath ( const QPainterPath path,
Qt::ClipOperation  op 
)

Definition at line 1237 of file qpaintengine_raster.cpp.

References d, Qt::IntersectClip, Qt::NoClip, path, qDebug(), Qt::ReplaceClip, QPainterPrivate::TxNone, and Qt::UniteClip.

Referenced by begin(), updateClipRegion(), and updateState().

01238 {
01239     Q_D(QRasterPaintEngine);
01240 #ifdef QT_DEBUG_DRAW
01241     qDebug() << " - QRasterPaintEngine::updateClipPath(), op="
01242              << op
01243              << path.boundingRect();
01244 #endif
01245     d->updateClip_helper(path, op);
01246 
01247     // Reset the baseClip if the operation requires it.
01248     if (!d->baseClip.isEmpty()) {
01249         switch (op) {
01250         case Qt::UniteClip:
01251         case Qt::ReplaceClip:
01252         case Qt::NoClip:
01253             d->outlineMapper->setMatrix(QMatrix(), QPainterPrivate::TxNone);
01254             d->updateClip_helper(d->baseClip, Qt::IntersectClip);
01255             d->outlineMapper->setMatrix(d->matrix, d->txop);
01256             break;
01257         default:
01258             break;
01259         }
01260     }
01261 }

Here is the call graph for this function:

void QRasterPaintEngine::drawPath ( const QPainterPath path  )  [virtual]

Reimplemented from QPaintEngine.

Definition at line 1402 of file qpaintengine_raster.cpp.

References d, fillPath(), QRectF::height(), path, qDebug(), QPainterPrivate::TxNone, QRectF::width(), width, Qt::WindingFill, QRectF::x(), and QRectF::y().

Referenced by drawPoints().

01403 {
01404 #ifdef QT_DEBUG_DRAW
01405     QRectF bounds = path.boundingRect();
01406     qDebug(" - QRasterPaintEngine::drawPath(), [%.2f, %.2f, %.2f, %.2f]",
01407            bounds.x(), bounds.y(), bounds.width(), bounds.height());
01408 #endif
01409     if (path.isEmpty())
01410         return;
01411 
01412     Q_D(QRasterPaintEngine);
01413 
01414     if (d->brushData.blend) {
01415         d->outlineMapper->setMatrix(d->matrix, d->txop);
01416         fillPath(path, &d->brushData);
01417     }
01418 
01419     if (!d->penData.blend)
01420         return;
01421 
01422     {
01423         Q_ASSERT(d->stroker);
01424         qreal width = d->pen.widthF();
01425         d->outlineMapper->beginOutline(Qt::WindingFill);
01426         if (width == 0) {
01427             d->outlineMapper->setMatrix(QMatrix(), QPainterPrivate::TxNone);
01428             d->stroker->strokePath(path, d->outlineMapper, d->matrix);
01429         } else {
01430             d->outlineMapper->setMatrix(d->matrix, d->txop);
01431             d->stroker->strokePath(path, d->outlineMapper, QMatrix());
01432         }
01433         d->outlineMapper->endOutline();
01434 
01435         d->rasterize(d->outlineMapper->outline(), d->penData.blend, &d->penData, d->rasterBuffer);
01436         d->outlineMapper->setMatrix(d->matrix, d->txop);
01437     }
01438 
01439 }

Here is the call graph for this function:

void QRasterPaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1444 of file qpaintengine_raster.cpp.

References d, drawLine_midpoint_dashed_i(), drawLine_midpoint_i(), Qt::FlatCap, i, LineDrawIncludeLastPixel, LineDrawNormal, Qt::OddEvenFill, p, QPaintEngine::PolylineMode, qDebug(), qFloor(), Qt::SolidLine, QPainterPrivate::TxNone, width, Qt::WindingFill, QPaintEngine::WindingMode, QPointF::x(), and QPointF::y().

Referenced by drawRects().

01445 {
01446     Q_D(QRasterPaintEngine);
01447 #ifdef QT_DEBUG_DRAW
01448     qDebug(" - QRasterPaintEngine::drawPolygon(), pointCount=%d", pointCount);
01449     for (int i=0; i<pointCount; ++i)
01450         qDebug() << "   - " << points[i];
01451 #endif
01452     Q_ASSERT(pointCount >= 2);
01453 
01454     // Do the fill
01455     if (d->brushData.blend && mode != PolylineMode) {
01456 
01457         // Compose polygon fill..,
01458         d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill);
01459         d->outlineMapper->moveTo(*points);
01460         const QPointF *p = points;
01461         const QPointF *ep = points + pointCount - 1;
01462         do {
01463             d->outlineMapper->lineTo(*(++p));
01464         } while (p < ep);
01465         d->outlineMapper->endOutline();
01466 
01467         // scanconvert.
01468         d->rasterize(d->outlineMapper->outline(), d->brushData.blend, &d->brushData, d->rasterBuffer);
01469     }
01470 
01471     // Do the outline...
01472     if (d->penData.blend) {
01473 
01474         bool needs_closing = mode != PolylineMode && points[0] != points[pointCount-1];
01475 
01476         if (d->fast_pen && d->pen.brush().isOpaque()) {
01477             // Use fast path for 0 width /  trivial pens.
01478 
01479             QRect devRect(0, 0, d->deviceRect.width(), d->deviceRect.height());
01480 
01481             LineDrawMode mode_for_last = (d->pen.capStyle() != Qt::FlatCap
01482                                           ? LineDrawIncludeLastPixel
01483                                           : LineDrawNormal);
01484             int dashOffset = 0;
01485 
01486             // Draw all the line segments.
01487             for (int i=1; i<pointCount; ++i) {
01488                 QPointF lp1 = points[i-1] * d->matrix;
01489                 QPointF lp2 = points[i] * d->matrix;
01490                 if (d->pen.style() == Qt::SolidLine) {
01491                     drawLine_midpoint_i(qFloor(lp1.x()), qFloor(lp1.y()),
01492                                         qFloor(lp2.x()), qFloor(lp2.y()),
01493                                         d->penData.blend, &d->penData,
01494                                         i == pointCount - 1 ? mode_for_last : LineDrawIncludeLastPixel,
01495                                         devRect);
01496                 } else {
01497                     drawLine_midpoint_dashed_i(qFloor(lp1.x()), qFloor(lp1.y()),
01498                                                qFloor(lp2.x()), qFloor(lp2.y()),
01499                                                &d->pen,
01500                                                d->penData.blend, &d->penData,
01501                                                i == pointCount - 1 ? mode_for_last : LineDrawIncludeLastPixel,
01502                                                devRect, &dashOffset);
01503                 }
01504             }
01505 
01506             // Polygons are implicitly closed.
01507             if (needs_closing) {
01508                 QPointF lp1 = points[pointCount-1] * d->matrix;
01509                 QPointF lp2 = points[0] * d->matrix;
01510                 if (d->pen.style() == Qt::SolidLine) {
01511                     drawLine_midpoint_i(qFloor(lp1.x()), qFloor(lp1.y()),
01512                                         qFloor(lp2.x()), qFloor(lp2.y()),
01513                                         d->penData.blend, &d->penData,
01514                                         LineDrawIncludeLastPixel,
01515                                         devRect);
01516                 } else {
01517                     drawLine_midpoint_dashed_i(qFloor(lp1.x()), qFloor(lp1.y()),
01518                                                qFloor(lp2.x()), qFloor(lp2.y()),
01519                                                &d->pen,
01520                                                d->penData.blend, &d->penData,
01521                                                LineDrawIncludeLastPixel,
01522                                                devRect, &dashOffset);
01523                 }
01524             }
01525 
01526         } else {
01527             // fallback case for complex or transformed pens.
01528             qreal width = d->pen.widthF();
01529             d->outlineMapper->beginOutline(Qt::WindingFill);
01530             if (width == 0) {
01531                 d->basicStroker.setStrokeWidth(1);
01532                 d->outlineMapper->setMatrix(QMatrix(), QPainterPrivate::TxNone);
01533                 d->stroker->strokePolygon(points, pointCount, needs_closing,
01534                                           d->outlineMapper, d->matrix);
01535             } else {
01536                 d->basicStroker.setStrokeWidth(width);
01537                 d->outlineMapper->setMatrix(d->matrix, d->txop);
01538                 d->stroker->strokePolygon(points, pointCount, needs_closing,
01539                                           d->outlineMapper, QMatrix());
01540             }
01541             d->outlineMapper->endOutline();
01542 
01543             d->rasterize(d->outlineMapper->outline(), d->penData.blend, &d->penData, d->rasterBuffer);
01544 
01545             d->outlineMapper->setMatrix(d->matrix, d->txop);
01546         }
01547     }
01548 
01549 }

Here is the call graph for this function:

void QRasterPaintEngine::drawPolygon ( const QPoint points,
int  pointCount,
PolygonDrawMode  mode 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1554 of file qpaintengine_raster.cpp.

References d, drawLine_midpoint_dashed_i(), drawLine_midpoint_i(), QPaintEngine::drawPolygon(), Qt::FlatCap, i, int, LineDrawIncludeLastPixel, LineDrawNormal, Qt::OddEvenFill, p, QPaintEngine::PolylineMode, qDebug(), Qt::SolidLine, Qt::WindingFill, QPaintEngine::WindingMode, x, and y.

01555 {
01556     Q_D(QRasterPaintEngine);
01557     if (!(d->int_xform && d->fast_pen)) {
01558         // this calls the float version
01559         QPaintEngine::drawPolygon(points, pointCount, mode);
01560         return;
01561     }
01562 
01563 #ifdef QT_DEBUG_DRAW
01564     qDebug(" - QRasterPaintEngine::drawPolygon(), pointCount=%d", pointCount);
01565     for (int i=0; i<pointCount; ++i)
01566         qDebug() << "   - " << points[i];
01567 #endif
01568     Q_ASSERT(pointCount >= 2);
01569 
01570     // Do the fill
01571     if (d->brushData.blend && mode != PolylineMode) {
01572 
01573         // Compose polygon fill..,
01574         d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill);
01575         d->outlineMapper->moveTo(*points);
01576         const QPoint *p = points;
01577         const QPoint *ep = points + pointCount - 1;
01578         do {
01579             d->outlineMapper->lineTo(*(++p));
01580         } while (p < ep);
01581         d->outlineMapper->endOutline();
01582 
01583         // scanconvert.
01584         d->rasterize(d->outlineMapper->outline(), d->brushData.blend, &d->brushData, d->rasterBuffer);
01585     }
01586 
01587     // Do the outline...
01588     if (d->penData.blend) {
01589 
01590         bool needs_closing = mode != PolylineMode && points[0] != points[pointCount-1];
01591 
01592         QRect devRect(0, 0, d->deviceRect.width(), d->deviceRect.height());
01593 
01594         LineDrawMode mode_for_last = (d->pen.capStyle() != Qt::FlatCap
01595                                       ? LineDrawIncludeLastPixel
01596                                       : LineDrawNormal);
01597 
01598         int m11 = int(d->matrix.m11());
01599         int m22 = int(d->matrix.m22());
01600         int dx = int(d->matrix.dx());
01601         int dy = int(d->matrix.dy());
01602 
01603         int dashOffset = 0;
01604 
01605         // Draw all the line segments.
01606         for (int i=1; i<pointCount; ++i) {
01607             if (d->pen.style() == Qt::SolidLine)
01608                 drawLine_midpoint_i(points[i-1].x() * m11 + dx, points[i-1].y() * m22 + dy,
01609                                     points[i].x() * m11 + dx, points[i].y() * m22 + dy,
01610                                     d->penData.blend, &d->penData,
01611                                     i == pointCount - 1 ? mode_for_last : LineDrawIncludeLastPixel,
01612                                     devRect);
01613             else
01614                 drawLine_midpoint_dashed_i(points[i-1].x() * m11 + dx, points[i-1].y() * m22 + dy,
01615                                            points[i].x() * m11 + dx, points[i].y() * m22 + dy,
01616                                            &d->pen,
01617                                            d->penData.blend, &d->penData,
01618                                            i == pointCount - 1 ? mode_for_last : LineDrawIncludeLastPixel,
01619                                            devRect, &dashOffset);
01620 
01621         }
01622 
01623         // Polygons are implicitly closed.
01624         if (needs_closing) {
01625             if (d->pen.style() == Qt::SolidLine)
01626                 drawLine_midpoint_i(points[pointCount-1].x() * m11 + dx, points[pointCount-1].y() * m22 + dy,
01627                                     points[0].x() * m11 + dx, points[0].y() * m22 + dy,
01628                                     d->penData.blend, &d->penData, LineDrawIncludeLastPixel,
01629                                     devRect);
01630             else
01631                 drawLine_midpoint_dashed_i(points[pointCount-1].x() * m11 + dx, points[pointCount-1].y() * m22 + dy,
01632                                     points[0].x() * m11 + dx, points[0].y() * m22 + dy,
01633                                            &d->pen,
01634                                            d->penData.blend, &d->penData, LineDrawIncludeLastPixel,
01635                                            devRect, &dashOffset);
01636         }
01637 
01638     }
01639 
01640 }

Here is the call graph for this function:

void QRasterPaintEngine::fillPath ( const QPainterPath path,
QSpanData fillData 
)

Definition at line 1266 of file qpaintengine_raster.cpp.

References QSpanData::blend, d, path, and qDebug().

Referenced by drawImage(), drawPath(), and drawTiledPixmap().

01267 {
01268 #ifdef QT_DEBUG_DRAW
01269     qDebug() << " --- fillPath, bounds=" << path.boundingRect();
01270 #endif
01271 
01272     if (!fillData->blend)
01273         return;
01274 
01275     Q_D(QRasterPaintEngine);
01276     d->rasterize(d->outlineMapper->convertPath(path), fillData->blend, fillData, d->rasterBuffer);
01277 }

Here is the call graph for this function:

void QRasterPaintEngine::drawEllipse ( const QRectF rect  )  [virtual]

Reimplemented from QPaintEngine.

Definition at line 2499 of file qpaintengine_raster.cpp.

References d, drawEllipse_midpoint_i(), QRectF::height(), i, int_dim, Qt::NoPen, qMax(), qt_curves_for_arc(), Qt::SolidLine, start, QPainterPrivate::TxNone, QPainterPrivate::TxScale, QRectF::width(), width, Qt::WindingFill, QRectF::x(), and QRectF::y().

02500 {
02501     Q_D(QRasterPaintEngine);
02502     if (!d->brushData.blend && !d->penData.blend)
02503         return;
02504 
02505     const QRectF r = d->matrix.mapRect(rect);
02506     if (d->fast_pen
02507         && (d->pen.style() == Qt::SolidLine || d->pen.style() == Qt::NoPen)
02508         && qMax(r.width(), r.height()) < 128 // integer math breakdown
02509         && d->txop <= QPainterPrivate::TxScale) // no shear
02510     {
02511         const QRect devRect(0, 0, d->deviceRect.width(), d->deviceRect.height());
02512 #ifdef QT_EXPERIMENTAL_REGIONS
02513         const QRect brect = QRect(int(r.x()), int(r.y()),
02514                                   int_dim(r.x(), r.width()),
02515                                   int_dim(r.y(), r.height()));
02516         const bool unclipped = qt_region_strictContains(d->clipRegion, brect);
02517         ProcessSpans penBlend;
02518         ProcessSpans brushBlend;
02519         if (unclipped) {
02520             penBlend = d->penData.unclipped_blend;
02521             brushBlend = d->brushData.unclipped_blend;
02522         } else {
02523             penBlend = d->penData.blend;
02524             brushBlend = d->brushData.blend;
02525         }
02526         drawEllipse_midpoint_i(brect, devRect, penBlend, brushBlend,
02527                                &d->penData, &d->brushData);
02528 #else
02529         drawEllipse_midpoint_i(QRect(int(r.x()), int(r.y()),
02530                                      int_dim(r.x(), r.width()), int_dim(r.y(), r.height())),
02531                                devRect,
02532                                d->penData.blend, d->brushData.blend,
02533                                &d->penData, &d->brushData);
02534 #endif
02535         return;
02536     }
02537 
02538     if (d->brushData.blend) {
02539         QPointF controlPoints[12];
02540         int point_count = 0;
02541         QPointF start = qt_curves_for_arc(rect, 0, 360, controlPoints, &point_count);
02542 
02543         Q_ASSERT(point_count == 12); // a perfect circle...
02544 
02545         d->outlineMapper->beginOutline(Qt::WindingFill);
02546         d->outlineMapper->moveTo(start);
02547         for (int i=0; i<point_count; i+=3) {
02548             d->outlineMapper->curveTo(controlPoints[i], controlPoints[i+1], controlPoints[i+2]);
02549         }
02550         d->outlineMapper->endOutline();
02551 
02552         d->rasterize(d->outlineMapper->outline(), d->brushData.blend, &d->brushData, d->rasterBuffer);
02553     }
02554 
02555     if (d->penData.blend) {
02556         qreal width = d->pen.widthF();
02557         d->outlineMapper->beginOutline(Qt::WindingFill);
02558         if (width == 0) {
02559             d->outlineMapper->setMatrix(QMatrix(), QPainterPrivate::TxNone);
02560             d->stroker->strokeEllipse(rect, d->outlineMapper, d->matrix);
02561         } else {
02562             d->outlineMapper->setMatrix(d->matrix, d->txop);
02563             d->stroker->strokeEllipse(rect, d->outlineMapper, QMatrix());
02564         }
02565         d->outlineMapper->endOutline();
02566 
02567         d->rasterize(d->outlineMapper->outline(), d->penData.blend, &d->penData, d->rasterBuffer);
02568 
02569         d->outlineMapper->setMatrix(d->matrix, d->txop);
02570     }
02571 }

Here is the call graph for this function:

void QRasterPaintEngine::drawRects ( const QRect rects,
int  rectCount 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1335 of file qpaintengine_raster.cpp.

References d, drawPolygon(), QPaintEngine::drawRects(), fillRect(), QRect::height(), int, left(), QRect::normalized(), offset_x, offset_y, qDebug(), right(), QRect::translated(), QPainterPrivate::TxTranslate, QRect::width(), QPaintEngine::WindingMode, QRect::x(), and QRect::y().

01336 {
01337 #ifdef QT_DEBUG_DRAW
01338     qDebug(" - QRasterPaintEngine::drawRect(), rectCount=%d", rectCount);
01339 #endif
01340     Q_D(QRasterPaintEngine);
01341     if (!d->antialiased && d->txop <= QPainterPrivate::TxTranslate) {
01342         int offset_x = int(d->matrix.dx());
01343         int offset_y = int(d->matrix.dy());
01344 
01345         const QRect *lastRect = rects + rectCount;
01346 
01347         while (rects < lastRect) {
01348 
01349             QRect rect = rects->normalized();
01350             if (d->brushData.blend) {
01351                 QRect r = rect.translated(offset_x, offset_y);
01352 #ifdef QT_EXPERIMENTAL_REGIONS
01353                 fillRect(r, d->clipRegion, &d->brushData);
01354 #else
01355                 fillRect(r, &d->brushData);
01356 #endif
01357             }
01358 
01359             if (d->penData.blend) {
01360                 ProcessSpans brush_blend = d->brushData.blend;
01361                 d->brushData.blend = 0;
01362                 int left = rect.x();
01363                 int right = rect.x() + rect.width();
01364                 int top = rect.y();
01365                 int bottom = rect.y() + rect.height();
01366                 QPoint pts[] = { QPoint(left, top),
01367                                  QPoint(right, top),
01368                                  QPoint(right, bottom),
01369                                  QPoint(left, bottom) };
01370                 QRasterPaintEngine::drawPolygon(pts, 4, WindingMode);
01371                 d->brushData.blend = brush_blend;
01372             }
01373 
01374             ++rects;
01375         }
01376     } else {
01377         QPaintEngine::drawRects(rects, rectCount);
01378     }
01379 }

Here is the call graph for this function:

void QRasterPaintEngine::drawRects ( const QRectF rects,
int  rectCount 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1384 of file qpaintengine_raster.cpp.

References QPaintEngine::ConvexMode, drawPolygon(), i, and qDebug().

01385 {
01386 #ifdef QT_DEBUG_DRAW
01387     qDebug(" - QRasterPaintEngine::drawRect(), rectCount=%d", rectCount);
01388 #endif
01389     for (int i=0; i<rectCount; ++i) {
01390         const QRectF &rf = rects[i];
01391         QPointF pts[4] = { QPointF(rf.x(), rf.y()),
01392                            QPointF(rf.x() + rf.width(), rf.y()),
01393                            QPointF(rf.x() + rf.width(), rf.y() + rf.height()),
01394                            QPointF(rf.x(), rf.y() + rf.height()) };
01395         drawPolygon(pts, 4, ConvexMode);
01396     }
01397 }

Here is the call graph for this function:

void QRasterPaintEngine::drawPixmap ( const QRectF r,
const QPixmap pixmap,
const QRectF sr 
) [virtual]

Implements QPaintEngine.

Definition at line 1645 of file qpaintengine_raster.cpp.

References d, QPixmap::data, QPixmap::depth(), drawImage(), QRectF::height(), qDebug(), qRound(), QRectF::size(), QPixmap::size(), QPixmap::toImage(), QRectF::topLeft(), QPainterPrivate::TxTranslate, QPixmap::width(), QRectF::width(), QRectF::x(), and QRectF::y().

01646 {
01647 #ifdef QT_DEBUG_DRAW
01648     qDebug() << " - QRasterPaintEngine::drawPixmap(), r=" << r << " sr=" << sr << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
01649 #endif
01650 
01651     Q_D(QRasterPaintEngine);
01652 
01653     if (pixmap.depth() == 1) {
01654         if (d->txop <= QPainterPrivate::TxTranslate
01655             && r.size() == sr.size()
01656             && r.size() == pixmap.size()) {
01657             d->drawBitmap(r.topLeft() + QPointF(d->matrix.dx(), d->matrix.dy()), pixmap, &d->penData);
01658             return;
01659         } else {
01660             drawImage(r, d->rasterBuffer->colorizeBitmap(pixmap.toImage(), d->pen.color()), sr);
01661         }
01662     } else {
01663 #if defined(Q_WS_MAC)
01664         if(CGContextRef ctx = macCGContext()) {
01665             const CGRect dest = CGRectMake(r.x(), r.y(), r.width(), r.height());
01666             QCFType<CGImageRef> subimage;
01667 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
01668             if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
01669                 const CGRect source = CGRectMake(sr.x(), sr.y(), sr.width(), sr.height());
01670                 subimage = CGImageCreateWithImageInRect(pixmap.data->cg_data, source);
01671             } else
01672 #endif
01673             {
01674                 int sx = qRound(sr.x());
01675                 int sy = qRound(sr.y());
01676                 int sw = qRound(sr.width());
01677                 int sh = qRound(sr.height());
01678                 quint32 *pantherData = pixmap.data->pixels + (sy * pixmap.width() + sx);
01679                 QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0,
01680                                                                    pantherData, sw*sh*sizeof(uint),
01681                                                                    0);
01682                 subimage = CGImageCreate(sw, sh, 8, 32, pixmap.width() * sizeof(uint),
01683                                 QCFType<CGColorSpaceRef>(CGColorSpaceCreateDeviceRGB()),
01684                                 kCGImageAlphaPremultipliedFirst, provider, 0, 0,
01685                                 kCGRenderingIntentDefault);
01686             }
01687             HIViewDrawCGImage(ctx, &dest, subimage); //top left
01688         } else
01689 #endif
01690             drawImage(r, pixmap.toImage(), sr);
01691     }
01692 
01693 }

Here is the call graph for this function:

void QRasterPaintEngine::drawImage ( const QRectF r,
const QImage img,
const QRectF sr,
Qt::ImageConversionFlags  falgs = Qt::AutoColor 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1698 of file qpaintengine_raster.cpp.

References QSpanData::adjustSpanMethods(), TokenEngine::copy(), d, QImage::depth(), QSpanData::dx, QSpanData::dy, fillPath(), fillRect(), QRectF::height(), QSpanData::init(), QSpanData::initTexture(), path, qDebug(), QSpanData::setupMatrix(), QImage::size(), QSpanData::Texture, QRectF::toRect(), QRectF::translate(), QPainterPrivate::TxRotShear, QPainterPrivate::TxTranslate, QSpanData::type, QRectF::width(), QRectF::x(), and QRectF::y().

Referenced by drawPixmap().

01700 {
01701 #ifdef QT_DEBUG_DRAW
01702     qDebug() << " - QRasterPaintEngine::drawImage(), r=" << r << " sr=" << sr << " image=" << img.size() << "depth=" << img.depth();
01703 #endif
01704 
01705     Q_D(QRasterPaintEngine);
01706     QSpanData textureData;
01707     textureData.init(d->rasterBuffer, this);
01708     textureData.type = QSpanData::Texture;
01709     textureData.initTexture(&img, d->opacity);
01710 
01711     bool stretch_sr = r.width() != sr.width() || r.height() != sr.height();
01712 
01713     if (d->txop > QPainterPrivate::TxTranslate || stretch_sr) {
01714         QMatrix copy = d->matrix;
01715         copy.translate(r.x(), r.y());
01716         if (stretch_sr)
01717             copy.scale(r.width() / sr.width(), r.height() / sr.height());
01718         copy.translate(-sr.x(), -sr.y());
01719         textureData.setupMatrix(copy, QPainterPrivate::TxRotShear, d->bilinear);
01720   textureData.adjustSpanMethods();
01721 
01722         bool wasAntialiased = d->antialiased;
01723         if (!d->antialiased)
01724             d->antialiased = d->bilinear;
01725         QPainterPath path;
01726         path.addRect(r);
01727         fillPath(path, &textureData);
01728         d->antialiased = wasAntialiased;
01729     } else {
01730         textureData.dx = -(r.x() + d->matrix.dx()) + sr.x();
01731         textureData.dy = -(r.y() + d->matrix.dy()) + sr.y();
01732 
01733         QRectF rr = r;
01734         rr.translate(d->matrix.dx(), d->matrix.dy());
01735 #ifdef QT_EXPERIMENTAL_REGIONS
01736         fillRect(rr.toRect(), d->clipRegion, &textureData);
01737 #else
01738         fillRect(rr.toRect(), &textureData);
01739 #endif
01740     }
01741 }

Here is the call graph for this function:

void QRasterPaintEngine::drawTiledPixmap ( const QRectF r,
const QPixmap pixmap,
const QPointF sr 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1746 of file qpaintengine_raster.cpp.

References TokenEngine::copy(), d, QPixmap::depth(), QSpanData::dx, QSpanData::dy, fillPath(), fillRect(), image, QSpanData::init(), QSpanData::initTexture(), path, qDebug(), QSpanData::setupMatrix(), QPixmap::size(), QSpanData::Texture, TextureData::Tiled, QPixmap::toImage(), QRectF::toRect(), QRectF::translate(), QPainterPrivate::TxRotShear, QPainterPrivate::TxTranslate, QSpanData::type, QRectF::x(), QPointF::x(), QRectF::y(), and QPointF::y().

01747 {
01748 #ifdef QT_DEBUG_DRAW
01749     qDebug() << " - QRasterPaintEngine::drawTiledPixmap(), r=" << r << "pixmap=" << pixmap.size();
01750 #endif
01751     Q_D(QRasterPaintEngine);
01752 
01753     QImage image;
01754     if (pixmap.depth() == 1)
01755         image = d->rasterBuffer->colorizeBitmap(pixmap.toImage(), d->pen.color());
01756     else
01757         image = pixmap.toImage();
01758 
01759     QSpanData textureData;
01760     textureData.init(d->rasterBuffer, this);
01761     textureData.type = QSpanData::Texture;
01762     textureData.initTexture(&image, d->opacity, TextureData::Tiled);
01763 
01764     if (d->txop > QPainterPrivate::TxTranslate) {
01765         QMatrix copy = d->matrix;
01766         copy.translate(r.x(), r.y());
01767         copy.translate(-sr.x(), -sr.y());
01768         textureData.setupMatrix(copy, QPainterPrivate::TxRotShear, d->bilinear);
01769 
01770         bool wasAntialiased = d->antialiased;
01771         if (!d->antialiased)
01772             d->antialiased = d->bilinear;
01773         QPainterPath path;
01774         path.addRect(r);
01775         fillPath(path, &textureData);
01776         d->antialiased = wasAntialiased;
01777     } else {
01778         textureData.dx = -(r.x() + d->matrix.dx()) + sr.x();
01779         textureData.dy = -(r.y() + d->matrix.dy()) + sr.y();
01780 
01781         QRectF rr = r;
01782         rr.translate(d->matrix.dx(), d->matrix.dy());
01783 #ifdef QT_EXPERIMENTAL_REGIONS
01784         fillRect(rr.toRect(), d->clipRegion, &textureData);
01785 #else
01786         fillRect(rr.toRect(), &textureData);
01787 #endif
01788     }
01789 
01790 }

Here is the call graph for this function:

void QRasterPaintEngine::drawTextItem ( const QPointF p,
const QTextItem textItem 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 1952 of file qpaintengine_raster.cpp.

References QPaintEngine::drawTextItem(), and p.

01953 {
01954     QPaintEngine::drawTextItem(p, textItem);
01955     // #####
01956 }

Here is the call graph for this function:

void QRasterPaintEngine::drawLines ( const QLine lines,
int  lineCount 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 2338 of file qpaintengine_raster.cpp.

References d, drawLine_midpoint_dashed_i(), drawLine_midpoint_i(), Qt::FlatCap, i, int, l, LineDrawIncludeLastPixel, LineDrawNormal, qDebug(), Qt::SolidLine, QLineF::x1(), QLineF::x2(), QLineF::y1(), and QLineF::y2().

02339 {
02340 #ifdef QT_DEBUG_DRAW
02341     qDebug() << " - QRasterPaintEngine::drawLine()";
02342 #endif
02343     Q_D(QRasterPaintEngine);
02344     if (!d->penData.blend)
02345         return;
02346     if (d->fast_pen) {
02347         QRect bounds(0, 0, d->deviceRect.width(), d->deviceRect.height());
02348         LineDrawMode mode = d->pen.capStyle() == Qt::FlatCap
02349                             ? LineDrawNormal
02350                             : LineDrawIncludeLastPixel;
02351 
02352         int m11 = int(d->matrix.m11());
02353         int m22 = int(d->matrix.m22());
02354         int dx = int(d->matrix.dx());
02355         int dy = int(d->matrix.dy());
02356         for (int i=0; i<lineCount; ++i) {
02357             int dashOffset = 0;
02358             if (d->int_xform) {
02359                 const QLine &l = lines[i];
02360                 int x1 = l.x1() * m11 + dx;
02361                 int y1 = l.y1() * m22 + dy;
02362                 int x2 = l.x2() * m11 + dx;
02363                 int y2 = l.y2() * m22 + dy;
02364 
02365 #ifdef QT_EXPERIMENTAL_REGIONS
02366                 const QRect brect(QPoint(x1, y1), QPoint(x2, y2));
02367                 const bool unclipped = qt_region_strictContains(d->clipRegion,
02368                                                                 brect);
02369                 ProcessSpans penBlend;
02370                 if (unclipped)
02371                     penBlend = d->penData.unclipped_blend;
02372                 else
02373                     penBlend = d->penData.blend;
02374                 if (d->pen.style() == Qt::SolidLine)
02375                     drawLine_midpoint_i(x1, y1, x2, y2,
02376                                         penBlend, &d->penData, mode, bounds);
02377                 else
02378                     drawLine_midpoint_dashed_i(x1, y1, x2, y2,
02379                                                &d->pen, penBlend,
02380                                                &d->penData, mode, bounds,
02381                                                &dashOffset);
02382 #else
02383                 if (d->pen.style() == Qt::SolidLine)
02384                     drawLine_midpoint_i(x1, y1, x2, y2,
02385                                         d->penData.blend, &d->penData, mode, bounds);
02386                 else
02387                     drawLine_midpoint_dashed_i(x1, y1, x2, y2,
02388                                                &d->pen, d->penData.blend,
02389                                                &d->penData, mode, bounds,
02390                                                &dashOffset);
02391 #endif
02392             } else {
02393                 QLineF line = lines[i] * d->matrix;
02394 #ifdef QT_EXPERIMENTAL_REGIONS
02395                 const QRect brect(QPoint(int(line.x1()), int(line.y1())),
02396                                   QPoint(int(line.x2()), int(line.y2())));
02397                 const bool unclipped = qt_region_strictContains(d->clipRegion,
02398                                                                 brect);
02399                 ProcessSpans penBlend;
02400                 if (unclipped)
02401                     penBlend = d->penData.unclipped_blend;
02402                 else
02403                     penBlend = d->penData.blend;
02404                 if (d->pen.style() == Qt::SolidLine)
02405                     drawLine_midpoint_i(int(line.x1()), int(line.y1()),
02406                                         int(line.x2()), int(line.y2()),
02407                                         penBlend, &d->penData, mode, bounds);
02408                 else
02409                     drawLine_midpoint_dashed_i(int(line.x1()), int(line.y1()),
02410                                                int(line.x2()), int(line.y2()),
02411                                                &d->pen, penBlend,
02412                                                &d->penData, mode, bounds,
02413                                                &dashOffset);
02414 #else
02415                 if (d->pen.style() == Qt::SolidLine)
02416                     drawLine_midpoint_i(int(line.x1()), int(line.y1()),
02417                                         int(line.x2()), int(line.y2()),
02418                                         d->penData.blend, &d->penData, mode, bounds);
02419                 else
02420                     drawLine_midpoint_dashed_i(int(line.x1()), int(line.y1()),
02421                                                int(line.x2()), int(line.y2()),
02422                                                &d->pen, d->penData.blend,
02423                                                &d->penData, mode, bounds,
02424                                                &dashOffset);
02425 #endif
02426             }
02427         }
02428     } else {
02429         QPaintEngine::drawLines(lines, lineCount);
02430     }
02431 }

Here is the call graph for this function:

void QRasterPaintEngine::drawLines ( const QLineF lines,
int  lineCount 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 2436 of file qpaintengine_raster.cpp.

References d, drawLine_midpoint_dashed_i(), drawLine_midpoint_i(), QPaintEngine::drawLines(), Qt::FlatCap, i, LineDrawIncludeLastPixel, LineDrawNormal, qDebug(), and Qt::SolidLine.

02437 {
02438 #ifdef QT_DEBUG_DRAW
02439     qDebug() << " - QRasterPaintEngine::drawLine()";
02440 #endif
02441     Q_D(QRasterPaintEngine);
02442     if (!d->penData.blend)
02443         return;
02444     if (d->fast_pen) {
02445         QRect bounds(0, 0, d->deviceRect.width(), d->deviceRect.height());
02446         LineDrawMode mode = d->pen.capStyle() == Qt::FlatCap
02447                             ? LineDrawNormal
02448                             : LineDrawIncludeLastPixel;
02449         for (int i=0; i<lineCount; ++i) {
02450             QLineF line = lines[i] * d->matrix;
02451             int dashOffset = 0;
02452 #ifdef QT_EXPERIMENTAL_REGIONS
02453             const QRect brect(QPoint(int(line.x1()), int(line.y1())),
02454                               QPoint(int(line.x2()), int(line.y2())));
02455             const bool unclipped = qt_region_strictContains(d->clipRegion,
02456                                                             brect);
02457             ProcessSpans penBlend;
02458             if (unclipped)
02459                 penBlend = d->penData.unclipped_blend;
02460             else
02461                 penBlend = d->penData.blend;
02462             if (d->pen.style() == Qt::SolidLine)
02463                 drawLine_midpoint_i(brect.left(), brect.top(),
02464                                     brect.right(), brect.bottom(),
02465                                     penBlend, &d->penData, mode, bounds);
02466             else
02467                 drawLine_midpoint_dashed_i(int(line.x1()), int(line.y1()),
02468                                            int(line.x2()), int(line.y2()),
02469                                            &d->pen,
02470                                            penBlend, &d->penData, mode,
02471                                            bounds, &dashOffset);
02472 #else
02473             if (d->pen.style() == Qt::SolidLine)
02474                 drawLine_midpoint_i(int(line.x1()), int(line.y1()),
02475                                     int(line.x2()), int(line.y2()),
02476                                     d->penData.blend, &d->penData, mode, bounds);
02477             else
02478                 drawLine_midpoint_dashed_i(int(line.x1()), int(line.y1()),
02479                                            int(line.x2()), int(line.y2()),
02480                                            &d->pen,
02481                                            d->penData.blend, &d->penData, mode,
02482                                            bounds, &dashOffset);
02483 #endif
02484         }
02485     } else {
02486         QPaintEngine::drawLines(lines, lineCount);
02487     }
02488 }

Here is the call graph for this function:

void QRasterPaintEngine::drawPoints ( const QPointF points,
int  pointCount 
) [virtual]

Reimplemented from QPaintEngine.

Definition at line 2276 of file qpaintengine_raster.cpp.

References QVarLengthArray< T, Prealloc >::constData(), d, drawPath(), end(), Qt::FlatCap, left(), Qt::NoBrush, path, qFloor(), right(), Qt::SquareCap, QPainterPrivate::TxTranslate, QT_FT_Span_::x, QPointF::x(), QPointF::y(), and QT_FT_Span_::y.

02277 {
02278     Q_D(QRasterPaintEngine);
02279 
02280     double pw = d->pen.widthF();
02281 
02282     if (!d->fast_pen && (d->txop > QPainterPrivate::TxTranslate || pw > 1)) {
02283         QBrush oldBrush = d->brush;
02284         d->brush = Qt::NoBrush;
02285 
02286         bool flat_pen = d->pen.capStyle() == Qt::FlatCap;
02287         if (flat_pen)
02288             d->basicStroker.setCapStyle(Qt::SquareCap);
02289 
02290         const QPointF *end = points + pointCount;
02291         while (points < end) {
02292             QPainterPath path;
02293             path.moveTo(*points);
02294             path.lineTo(points->x() + 0.001, points->y());
02295             drawPath(path);
02296             ++points;
02297         }
02298 
02299         d->brush = oldBrush;
02300 
02301         if (flat_pen)
02302             d->basicStroker.setCapStyle(Qt::FlatCap);
02303 
02304     } else {
02305         if (!d->penData.blend)
02306             return;
02307 
02308         QVarLengthArray<QT_FT_Span, 4096> array(pointCount);
02309 
02310         QT_FT_Span span = { 0, 1, 0, 255 };
02311         const QPointF *end = points + pointCount;
02312         qreal trans_x, trans_y;
02313         int x, y;
02314         int left = 0;
02315         int right = d->deviceRect.width();
02316         int top = 0;
02317         int bottom = d->deviceRect.height();
02318         int count = 0;
02319         while (points < end) {
02320             d->matrix.map(points->x(), points->y(), &trans_x, &trans_y);
02321             x = qFloor(trans_x);
02322             y = qFloor(trans_y);
02323             if (x >= left && x < right && y >= top && y < bottom) {
02324                 span.x = x;
02325                 span.y = y;
02326                 array[count++] = span;
02327             }
02328             ++points;
02329         }
02330 
02331         d->penData.blend(count, array.constData(), &d->penData);
02332     }
02333 }

Here is the call graph for this function:

void QRasterPaintEngine::setFlushOnEnd ( bool  flush  ) 

Definition at line 888 of file qpaintengine_raster.cpp.

References d.

Referenced by QRasterPaintDevice::QRasterPaintDevice().

00889 {
00890     Q_D(QRasterPaintEngine);
00891 
00892     d->flushOnEnd = flushOnEnd;
00893 }

void QRasterPaintEngine::flush ( QPaintDevice device,
const QPoint offset 
)

Definition at line 901 of file qpaintengine_raster.cpp.

References QVector< T >::at(), d, QPaintDevice::devType(), i, QRegion::isEmpty(), QRegion::rects(), QVector< T >::size(), QPaintEngine::systemClip(), QInternal::Widget, QPoint::x(), and QPoint::y().

Referenced by end().

00902 {
00903     Q_D(QRasterPaintEngine);
00904     Q_ASSERT(device);
00905 
00906 #if defined(Q_WS_WIN)
00907     if (!d->rasterBuffer->hdc())
00908         return;
00909 
00910     if (device->devType() == QInternal::Widget) {
00911         HDC hdc = device->getDC();
00912 
00913         QRegion sysClip = systemClip();
00914         if (sysClip.isEmpty()) {
00915             BitBlt(hdc, d->deviceRect.x() + offset.x(), d->deviceRect.y() + offset.y(),
00916                    d->deviceRect.width(), d->deviceRect.height(),
00917                    d->rasterBuffer->hdc(), 0, 0, SRCCOPY);
00918         } else {
00919             QVector<QRect> rects = sysClip.rects();
00920             for (int i=0; i<rects.size(); ++i) {
00921                 QRect r = rects.at(i);
00922                 BitBlt(hdc,
00923                        r.x() + offset.x(), r.y() + offset.y(), r.width(), r.height(),
00924                        d->rasterBuffer->hdc(), r.x() - d->deviceRect.x(), r.y() - d->deviceRect.y(),
00925                        SRCCOPY);
00926             }
00927         }
00928 
00929         device->releaseDC(hdc);
00930     }
00931 #elif defined(Q_WS_MAC)
00932     extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp
00933     extern void qt_mac_clip_cg(CGContextRef, const QRegion &, const QPoint *, CGAffineTransform *); //qpaintengine_mac.cpp
00934     if(CGContextRef ctx = qt_mac_cg_context(device)) {
00935         qt_mac_clip_cg(ctx, systemClip(), 0, 0);
00936         const CGRect source = CGRectMake(0, 0, d->deviceRect.width(), d->deviceRect.height());
00937         QCFType<CGImageRef> subimage;
00938 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
00939         if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
00940             subimage = CGImageCreateWithImageInRect(d->rasterBuffer->m_data, source);
00941         } else
00942 #endif
00943         {
00944             int dw = d->deviceRect.width();
00945             int dh = d->deviceRect.height();
00946             QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(
00947                                                             d->rasterBuffer->buffer(),
00948                                                             d->rasterBuffer->buffer(),
00949                                                             dw*dh*sizeof(uint), 0);
00950             subimage = CGImageCreate(dw, dh, 8, 32, d->rasterBuffer->width() * sizeof(uint),
00951                                      QCFType<CGColorSpaceRef>(CGColorSpaceCreateDeviceRGB()),
00952                                      kCGImageAlphaPremultipliedFirst, provider, 0, 0,
00953                                      kCGRenderingIntentDefault);
00954         }
00955         const CGRect dest = CGRectMake(offset.x(), offset.y(),
00956                                        d->deviceRect.width(), d->deviceRect.height());
00957         HIViewDrawCGImage(ctx, &dest, subimage); //top left
00958         CGContextRelease(ctx);
00959         CGImageRelease(subimage);
00960     }
00961 #else
00962     Q_UNUSED(d);
00963     Q_UNUSED(device);
00964     Q_UNUSED(offset);
00965 #endif
00966 }

Here is the call graph for this function:

void QRasterPaintEngine::releaseBuffer (  ) 

Definition at line 858 of file qpaintengine_raster.cpp.

References d.

00859 {
00860     Q_D(QRasterPaintEngine);
00861     delete d->rasterBuffer;
00862     d->rasterBuffer = new QRasterBuffer;
00863 }

QSize QRasterPaintEngine::size (  )  const

Definition at line 868 of file qpaintengine_raster.cpp.

References d.

Referenced by QRasterPaintDevice::size().

00869 {
00870     Q_D(const QRasterPaintEngine);
00871     return QSize(d->rasterBuffer->width(), d->rasterBuffer->height());
00872 }

void QRasterPaintEngine::saveBuffer ( const QString s  )  const

Definition at line 878 of file qpaintengine_raster.cpp.

References d, and s.

00879 {
00880     Q_D(const QRasterPaintEngine);
00881     d->rasterBuffer->bufferImage().save(s, "PNG");
00882 }

Type QRasterPaintEngine::type (  )  const [inline, virtual]

Implements QPaintEngine.

Definition at line 131 of file qpaintengine_raster_p.h.

00131 { return Raster; }

QPoint QRasterPaintEngine::coordinateOffset (  )  const [virtual]

Reimplemented from QPaintEngine.

Definition at line 2617 of file qpaintengine_raster.cpp.

References d.

02618 {
02619     Q_D(const QRasterPaintEngine);
02620     return QPoint(d->deviceRect.x(), d->deviceRect.y());
02621 }

void QRasterPaintEngine::init (  )  [private]

Definition at line 597 of file qpaintengine_raster.cpp.

References d, qt_ft_outline_cubic_to(), qt_ft_outline_line_to(), and qt_ft_outline_move_to().

Referenced by QRasterPaintEngine().

00598 {
00599     Q_D(QRasterPaintEngine);
00600 
00601     d->rasterPoolSize = 4096;
00602     d->rasterPoolBase =
00603 #if defined(Q_WS_WIN64)
00604         (unsigned char *) _aligned_malloc(d->rasterPoolSize, __alignof(void*));
00605 #else
00606         (unsigned char *) malloc(d->rasterPoolSize);
00607 #endif
00608 
00609     // The antialiasing raster.
00610     d->grayRaster = new QT_FT_Raster;
00611     qt_ft_grays_raster.raster_new(0, d->grayRaster);
00612     qt_ft_grays_raster.raster_reset(*d->grayRaster, d->rasterPoolBase, d->rasterPoolSize);
00613 
00614     // Initialize the standard raster.
00615     d->blackRaster = new QT_FT_Raster;
00616     qt_ft_standard_raster.raster_new(0, d->blackRaster);
00617     qt_ft_standard_raster.raster_reset(*d->blackRaster, d->rasterPoolBase, d->rasterPoolSize);
00618 
00619     d->rasterBuffer = new QRasterBuffer();
00620 #ifdef Q_WS_WIN
00621     d->fontRasterBuffer = new QRasterBuffer();
00622 #endif
00623     d->outlineMapper = new QFTOutlineMapper;
00624 
00625     d->dashStroker = 0;
00626 
00627     d->flushOnEnd = true;
00628 
00629     d->basicStroker.setMoveToHook(qt_ft_outline_move_to);
00630     d->basicStroker.setLineToHook(qt_ft_outline_line_to);
00631     d->basicStroker.setCubicToHook(qt_ft_outline_cubic_to);
00632     d->dashStroker = 0;
00633 }

Here is the call graph for this function:


Friends And Related Function Documentation

QSpan [related]

A struct equivalent to QT_FT_Span, containing a position (x, y), the span's length in pixels and its color/coverage (a value ranging from 0 to 255).


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 18:47:13 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1