QPainterPrivate Class Reference

#include <qpainter_p.h>

Collaboration diagram for QPainterPrivate:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 108 of file qpainter_p.h.

Public Types

enum  TransformationCodes
enum  DrawOperation

Public Member Functions

 QPainterPrivate (QPainter *painter)
 ~QPainterPrivate ()
void updateEmulationSpecifier (QPainterState *s)
void updateState (QPainterState *state)
void draw_helper (const QPainterPath &path, DrawOperation operation=StrokeAndFillDraw)
void drawStretchToDevice (const QPainterPath &path, DrawOperation operation)
void drawOpaqueBackground (const QPainterPath &path, DrawOperation operation)
void updateMatrix ()
void updateInvMatrix ()
void init ()
int rectSubtraction () const
QMatrix viewMatrix () const

Public Attributes

QPainterq_ptr
QPoint redirection_offset
QPainterStatestate
QVector< QPainterState * > states
QMatrix invMatrix
uint txinv:1
QPaintDevicedevice
QPaintDeviceoriginal_device
QPaintEngineengine


Member Enumeration Documentation

enum QPainterPrivate::TransformationCodes

Definition at line 136 of file qpainter_p.h.

00136                              {
00137         TxNone = 0,
00138         TxTranslate = 1,
00139         TxScale = 2,
00140         TxRotShear = 3
00141     };

enum QPainterPrivate::DrawOperation

Definition at line 143 of file qpainter_p.h.

00143                        { StrokeDraw        = 0x1,
00144                          FillDraw          = 0x2,
00145                          StrokeAndFillDraw = 0x3
00146     };


Constructor & Destructor Documentation

QPainterPrivate::QPainterPrivate ( QPainter painter  )  [inline]

Definition at line 112 of file qpainter_p.h.

References QVector< T >::back(), QVector< T >::push_back(), state, and states.

00113         : q_ptr(painter), txinv(0), device(0)
00114         , original_device(0), engine(0)
00115     {
00116         states.push_back(new QPainterState());
00117         state = states.back();
00118     }

Here is the call graph for this function:

QPainterPrivate::~QPainterPrivate (  )  [inline]

Definition at line 120 of file qpainter_p.h.

References QVector< T >::at(), i, QVector< T >::size(), and states.

00121     {
00122         for (int i=0; i<states.size(); ++i)
00123             delete states.at(i);
00124     }

Here is the call graph for this function:


Member Function Documentation

void QPainterPrivate::updateEmulationSpecifier ( QPainterState s  ) 

Definition at line 378 of file qpainter.cpp.

References alpha, QPaintEngine::AlphaBlend, QPaintEngine::BrushStroke, check_gradient(), QPaintEngine::ConicalGradientFill, Qt::ConicalGradientPattern, QPaintEngine::ConstantOpacity, QPaintEngine::DirtyBackgroundMode, QPaintEngine::DirtyBrush, QPaintEngine::DirtyHints, QPaintEngine::DirtyOpacity, QPaintEngine::DirtyPen, QPaintEngine::DirtyTransform, engine, QPaintEngine::hasFeature(), is_brush_transparent(), is_pen_transparent(), QPaintEngine::LinearGradientFill, Qt::LinearGradientPattern, QPaintEngine::MaskedBrush, QPainterState::opacity, Qt::OpaqueMode, QPaintEngine::PatternBrush, QPaintEngine::PatternTransform, QPaintEngine::PrimitiveTransform, qDebug(), QGradient_StretchToDevice, QPaintEngine_OpaqueBackground, QPaintEngine::RadialGradientFill, Qt::RadialGradientPattern, s, Qt::SolidPattern, state, Qt::TexturePattern, and TxTranslate.

Referenced by updateState().

00379 {
00380     bool alpha = false;
00381     bool linearGradient = false;
00382     bool radialGradient = false;
00383     bool conicalGradient = false;
00384     bool patternBrush = false;
00385     bool xform = false;
00386 
00387     bool skip = true;
00388 
00389     // Pen and brush properties (we have to check both if one changes because the
00390     // one that's unchanged can still be in a state which requires emulation)
00391     if (s->state() & QPaintEngine::DirtyPen ||
00392         s->state() & QPaintEngine::DirtyBrush) {
00393         // Check Brush stroke emulation
00394         if (!s->pen.isSolid() && !engine->hasFeature(QPaintEngine::BrushStroke))
00395             s->emulationSpecifier |= QPaintEngine::BrushStroke;
00396         else
00397             s->emulationSpecifier &= ~QPaintEngine::BrushStroke;
00398 
00399         skip = false;
00400 
00401         QBrush penBrush = s->pen.brush();
00402         alpha = (!penBrush.isOpaque() || !s->brush.isOpaque());
00403         linearGradient = ((penBrush.style() == Qt::LinearGradientPattern) ||
00404                            (s->brush.style() == Qt::LinearGradientPattern));
00405         radialGradient = ((penBrush.style() == Qt::RadialGradientPattern) ||
00406                            (s->brush.style() == Qt::RadialGradientPattern));
00407         conicalGradient = ((penBrush.style() == Qt::ConicalGradientPattern) ||
00408                             (s->brush.style() == Qt::ConicalGradientPattern));
00409         patternBrush = (((penBrush.style() > Qt::SolidPattern
00410                            && penBrush.style() < Qt::LinearGradientPattern)
00411                           || s->brush.style() == Qt::TexturePattern) ||
00412                          ((s->brush.style() > Qt::SolidPattern
00413                            && s->brush.style() < Qt::LinearGradientPattern)
00414                           || s->brush.style() == Qt::TexturePattern));
00415 
00416         if (((penBrush.style() == Qt::TexturePattern && penBrush.texture().hasAlpha())
00417              || (s->brush.style() == Qt::TexturePattern && s->brush.texture().hasAlpha()))
00418             && !engine->hasFeature(QPaintEngine::MaskedBrush))
00419             s->emulationSpecifier |= QPaintEngine::MaskedBrush;
00420         else
00421             s->emulationSpecifier &= ~QPaintEngine::MaskedBrush;
00422     }
00423 
00424     if (s->state() & (QPaintEngine::DirtyHints
00425                       | QPaintEngine::DirtyOpacity
00426                       | QPaintEngine::DirtyBackgroundMode)) {
00427         skip = false;
00428     }
00429 
00430     if (skip)
00431         return;
00432 
00433 #if 0
00434     qDebug("QPainterPrivate::updateEmulationSpecifier, state=%p\n"
00435            " - alpha: %d\n"
00436            " - linearGradient: %d\n"
00437            " - radialGradient: %d\n"
00438            " - conicalGradient: %d\n"
00439            " - patternBrush: %d\n"
00440            " - hints: %x\n"
00441            " - xform: %d\n",
00442            s,
00443            alpha,
00444            linearGradient,
00445            radialGradient,
00446            conicalGradient,
00447            patternBrush,
00448            uint(s->renderHints),
00449            xform);
00450 #endif
00451 
00452     // XForm properties
00453     if (s->state() & QPaintEngine::DirtyTransform) {
00454         xform = !s->matrix.isIdentity();
00455     } else if (s->txop >= TxTranslate) {
00456         xform = true;
00457     }
00458 
00459     // Check alphablending
00460     if (alpha && !engine->hasFeature(QPaintEngine::AlphaBlend))
00461         s->emulationSpecifier |= QPaintEngine::AlphaBlend;
00462     else
00463         s->emulationSpecifier &= ~QPaintEngine::AlphaBlend;
00464 
00465     // Linear gradient emulation
00466     if (linearGradient && !engine->hasFeature(QPaintEngine::LinearGradientFill))
00467         s->emulationSpecifier |= QPaintEngine::LinearGradientFill;
00468     else
00469         s->emulationSpecifier &= ~QPaintEngine::LinearGradientFill;
00470 
00471     // Radial gradient emulation
00472     if (radialGradient && !engine->hasFeature(QPaintEngine::RadialGradientFill))
00473         s->emulationSpecifier |= QPaintEngine::RadialGradientFill;
00474     else
00475         s->emulationSpecifier &= ~QPaintEngine::RadialGradientFill;
00476 
00477     // Conical gradient emulation
00478     if (conicalGradient && !engine->hasFeature(QPaintEngine::ConicalGradientFill))
00479         s->emulationSpecifier |= QPaintEngine::ConicalGradientFill;
00480     else
00481         s->emulationSpecifier &= ~QPaintEngine::ConicalGradientFill;
00482 
00483     // Pattern brushes
00484     if (patternBrush && !engine->hasFeature(QPaintEngine::PatternBrush))
00485         s->emulationSpecifier |= QPaintEngine::PatternBrush;
00486     else
00487         s->emulationSpecifier &= ~QPaintEngine::PatternBrush;
00488 
00489     // Pattern XForms
00490     if (patternBrush && xform && !engine->hasFeature(QPaintEngine::PatternTransform))
00491         s->emulationSpecifier |= QPaintEngine::PatternTransform;
00492     else
00493         s->emulationSpecifier &= ~QPaintEngine::PatternTransform;
00494 
00495     // Primitive XForms
00496     if (xform && !engine->hasFeature(QPaintEngine::PrimitiveTransform))
00497         s->emulationSpecifier |= QPaintEngine::PrimitiveTransform;
00498     else
00499         s->emulationSpecifier &= ~QPaintEngine::PrimitiveTransform;
00500 
00501     // Constant opacity
00502     if (state->opacity != 1 && !engine->hasFeature(QPaintEngine::ConstantOpacity))
00503         s->emulationSpecifier |= QPaintEngine::ConstantOpacity;
00504     else
00505         s->emulationSpecifier &= ~QPaintEngine::ConstantOpacity;
00506 
00507     bool gradientStretch = false;
00508     if (linearGradient || conicalGradient || radialGradient) {
00509         gradientStretch |= check_gradient(s->brush);
00510         gradientStretch |= check_gradient(s->pen.brush());
00511     }
00512     if (gradientStretch)
00513         s->emulationSpecifier |= QGradient_StretchToDevice;
00514     else
00515         s->emulationSpecifier &= ~QGradient_StretchToDevice;
00516 
00517     // Opaque backgrounds...
00518     if (s->bgMode == Qt::OpaqueMode &&
00519         (is_pen_transparent(s->pen) || is_brush_transparent(s->brush)))
00520         s->emulationSpecifier |= QPaintEngine_OpaqueBackground;
00521     else
00522         s->emulationSpecifier &= ~QPaintEngine_OpaqueBackground;
00523 }

Here is the call graph for this function:

void QPainterPrivate::updateState ( QPainterState state  ) 

Definition at line 527 of file qpainter.cpp.

References QPaintEngine::AllDirty, QPainterState::changeFlags, QPaintEngine::clearDirty(), QPaintEngine::DirtyBackground, QPaintEngine::DirtyBackgroundMode, QPaintEngineState::dirtyFlags, engine, QPaintEngineState::painter(), QPainterState::painter, QPaintEngine::setDirty(), QPaintEngineState::state(), QPaintEngine::state, updateEmulationSpecifier(), and QPaintEngine::updateState().

Referenced by draw_helper(), and drawStretchToDevice().

00528 {
00529 
00530     if (!newState) {
00531         engine->state = newState;
00532 
00533     } else if (newState->state() || engine->state!=newState) {
00534 
00535         // ### we might have to call QPainter::begin() here...
00536         if (!engine->state) {
00537             engine->state = newState;
00538             engine->setDirty(QPaintEngine::AllDirty);
00539         }
00540 
00541         if (engine->state->painter() != newState->painter)
00542             // ### this could break with clip regions vs paths.
00543             engine->setDirty(QPaintEngine::AllDirty);
00544 
00545         // Upon restore, revert all changes since last save
00546         else if (engine->state != newState)
00547             newState->dirtyFlags |= QPaintEngine::DirtyFlags(static_cast<QPainterState *>(engine->state)->changeFlags);
00548 
00549         // We need to store all changes made so that restore can deal with them
00550         else
00551             newState->changeFlags |= newState->dirtyFlags;
00552 
00553         updateEmulationSpecifier(newState);
00554 
00555         // Unset potential dirty background mode
00556         newState->dirtyFlags &= ~(QPaintEngine::DirtyBackgroundMode
00557                                   | QPaintEngine::DirtyBackground);
00558 
00559         engine->state = newState;
00560         engine->updateState(*newState);
00561         engine->clearDirty(QPaintEngine::AllDirty);
00562     }
00563 }

Here is the call graph for this function:

void QPainterPrivate::draw_helper ( const QPainterPath path,
DrawOperation  operation = StrokeAndFillDraw 
)

Definition at line 121 of file qpainter.cpp.

References QPainter::Antialiasing, QPainterState::bgBrush, QPainterState::bgMode, QPainterState::bgOrigin, QRectF::bottom(), QPainterState::brush, QPen::capStyle(), ceil, QPainterState::clipInfo, QPainterPathStroker::createStroke(), device, QPaintEngine::drawImage(), drawOpaqueBackground(), drawStretchToDevice(), QPainterState::emulationSpecifier, engine, FillDraw, QImage::Format_ARGB32_Premultiplied, QPaintDevice::height(), image, int, QRectF::isEmpty(), QPainterPath::isEmpty(), QPen::joinStyle(), QRectF::left(), QMatrix::m11(), QMatrix::m22(), QPainterState::matrix, Qt::NoBrush, Qt::NoPen, QPainterState::opacity, Qt::OrderedAlphaDither, Qt::OrderedDither, original_device, p, path, QPainterState::pen, printf, QGradient_StretchToDevice, QPaintEngine_OpaqueBackground, redirection_offset, QPainterState::renderHints, QRectF::right(), QPainterPathStroker::setCapStyle(), QPainterPathStroker::setJoinStyle(), QPainterPathStroker::setWidth(), QList< T >::size(), QPainter::SmoothPixmapTransform, state, StrokeDraw, QPen::style(), QRectF::top(), QPainterState::txop, TxScale, updateState(), QPaintDevice::width(), QPen::widthF(), QPoint::x(), and QPoint::y().

00122 {
00123 #ifdef QT_DEBUG_DRAW
00124     if (qt_show_painter_debug_output) {
00125         printf("QPainter::drawHelper\n");
00126     }
00127 #endif
00128 
00129     if (originalPath.isEmpty())
00130         return;
00131 
00132     if (state->emulationSpecifier == QGradient_StretchToDevice) {
00133         drawStretchToDevice(originalPath, op);
00134         return;
00135     } else if (state->emulationSpecifier & QPaintEngine_OpaqueBackground) {
00136         drawOpaqueBackground(originalPath, op);
00137         return;
00138     }
00139 
00140     Q_Q(QPainter);
00141     int devMinX = 0, devMaxX = 0, devMinY = 0, devMaxY = 0;
00142 
00143     qreal strokeOffsetX = 0, strokeOffsetY = 0;
00144 
00145     QPainterPath path = originalPath * state->matrix;
00146     QRectF pathBounds = path.boundingRect();
00147     QRectF strokeBounds;
00148     bool doStroke = (op & StrokeDraw) && (state->pen.style() != Qt::NoPen);
00149     if (doStroke) {
00150         qreal penWidth = state->pen.widthF();
00151         if (penWidth == 0) {
00152             strokeOffsetX = 1;
00153             strokeOffsetY = 1;
00154         } else {
00155             // In case of complex xform
00156             if (state->txop > TxScale) {
00157                 QPainterPathStroker stroker;
00158                 stroker.setWidth(penWidth);
00159                 stroker.setJoinStyle(state->pen.joinStyle());
00160                 stroker.setCapStyle(state->pen.capStyle());
00161                 QPainterPath stroke = stroker.createStroke(originalPath);
00162                 strokeBounds = (stroke * state->matrix).boundingRect();
00163             } else {
00164                 strokeOffsetX = penWidth / 2.0 * state->matrix.m11();
00165                 strokeOffsetY = penWidth / 2.0 * state->matrix.m22();
00166             }
00167         }
00168     }
00169 
00170     const qreal ROUND_UP_TRICK = 0.9999;
00171     if (!strokeBounds.isEmpty()) {
00172         devMinX = int(strokeBounds.left());
00173         devMaxX = int(strokeBounds.right() + ROUND_UP_TRICK);
00174         devMinY = int(strokeBounds.top());
00175         devMaxY = int(strokeBounds.bottom() + ROUND_UP_TRICK);
00176     } else {
00177         devMinX = int(pathBounds.left() - strokeOffsetX);
00178         devMaxX = int(pathBounds.right() + strokeOffsetX + ROUND_UP_TRICK);
00179         devMinY = int(pathBounds.top() - strokeOffsetY);
00180         devMaxY = int(pathBounds.bottom() + strokeOffsetY + ROUND_UP_TRICK);
00181     }
00182 
00183     QRect absPathRect(devMinX, devMinY, devMaxX - devMinX, devMaxY - devMinY);
00184 
00185     if (state->clipInfo.size() != 0) {
00186         QPainterPath clipPath = q->clipPath() * q->deviceMatrix();
00187         QRectF r = clipPath.boundingRect().intersected(absPathRect);
00188         absPathRect.setCoords((int) floor(r.left()), (int) floor(r.top()),
00189                               (int) ceil(r.right()), (int) ceil(r.bottom()));
00190     }
00191     absPathRect = absPathRect.intersected(QRect(0, 0, device->width(), device->height()));
00192 
00193 
00194 //     qDebug("\nQPainterPrivate::draw_helper(), x=%d, y=%d, w=%d, h=%d",
00195 //            devMinX, devMinY, device->width(), device->height());
00196 //     qDebug() << " - matrix" << state->matrix;
00197 //     qDebug() << " - originalPath.bounds" << originalPath.boundingRect();
00198 //     qDebug() << " - path.bounds" << path.boundingRect();
00199 
00200     if (absPathRect.width() <= 0 || absPathRect.height() <= 0)
00201         return;
00202 
00203     QImage image(absPathRect.width(), absPathRect.height(), QImage::Format_ARGB32_Premultiplied);
00204     image.fill(0);
00205 
00206     QPainter p(&image);
00207 
00208     p.d_ptr->original_device = original_device;
00209     p.setOpacity(state->opacity);
00210     p.translate(-absPathRect.x(), -absPathRect.y());
00211     p.setMatrix(state->matrix, true);
00212     p.setPen(doStroke ? state->pen : QPen(Qt::NoPen));
00213     p.setBrush((op & FillDraw) ? state->brush : QBrush(Qt::NoBrush));
00214     p.setBackground(state->bgBrush);
00215     p.setBackgroundMode(state->bgMode);
00216     p.setBrushOrigin(state->bgOrigin);
00217 
00218     p.setRenderHint(QPainter::Antialiasing, state->renderHints & QPainter::Antialiasing);
00219     p.setRenderHint(QPainter::SmoothPixmapTransform,
00220                     state->renderHints & QPainter::SmoothPixmapTransform);
00221 
00222     p.drawPath(originalPath);
00223 
00224     p.end();
00225 
00226     q->save();
00227     q->setViewTransformEnabled(false);
00228     q->setMatrix(QMatrix(1, 0, 0, 1, -redirection_offset.x(), -redirection_offset.y()));
00229     updateState(state);
00230     engine->drawImage(absPathRect,
00231                  image,
00232                  QRectF(0, 0, absPathRect.width(), absPathRect.height()),
00233                  Qt::OrderedDither | Qt::OrderedAlphaDither);
00234     q->restore();
00235 }

Here is the call graph for this function:

void QPainterPrivate::drawStretchToDevice ( const QPainterPath path,
DrawOperation  operation 
)

Definition at line 257 of file qpainter.cpp.

References QPainterState::brush, QPen::brush(), QPen::capStyle(), check_gradient(), QPainterPathStroker::createStroke(), QPaintEngine::drawPath(), engine, FillDraw, QPaintDevice::height(), QPen::joinStyle(), QPen::miterLimit(), Qt::NoBrush, Qt::NoPen, original_device, path, QPainterState::pen, QPainterPathStroker::setCapStyle(), QPainterPathStroker::setDashPattern(), QPainterPathStroker::setJoinStyle(), QPainterPathStroker::setMiterLimit(), QPainterPathStroker::setWidth(), state, StrokeDraw, QPen::style(), QBrush::style(), updateState(), QPaintDevice::width(), and QPen::widthF().

Referenced by draw_helper().

00258 {
00259     Q_Q(QPainter);
00260 
00261     double sw = original_device->width();
00262     double sh = original_device->height();
00263 
00264     QMatrix inv(1.0/sw, 0, 0, 1.0/sh, 0, 0);
00265 
00266     QPen pen = state->pen;
00267     QBrush brush = state->brush;
00268 
00269     if ((op & FillDraw) && brush.style() == Qt::NoBrush) op = DrawOperation(op - FillDraw);
00270     if ((op & StrokeDraw) && pen.style() == Qt::NoPen) op = DrawOperation(op - StrokeDraw);
00271 
00272     q->scale(sw, sh);
00273     q->setPen(Qt::NoPen);
00274     updateState(state);
00275 
00276     // Draw the xformed fill if the brush is a stretch gradient.
00277     if ((op & FillDraw) && check_gradient(brush)) {
00278         engine->drawPath(path * inv);
00279         op = DrawOperation(op - FillDraw);
00280     }
00281 
00282     // Draw the xformed outline if the pen is a stretch gradient.
00283     if ((op & StrokeDraw) && check_gradient(pen.brush())) {
00284         q->setBrush(pen.brush());
00285         updateState(state);
00286 
00287         QPainterPathStroker stroker;
00288         stroker.setDashPattern(pen.style());
00289         stroker.setWidth(pen.widthF());
00290         stroker.setJoinStyle(pen.joinStyle());
00291         stroker.setCapStyle(pen.capStyle());
00292         stroker.setMiterLimit(pen.miterLimit());
00293         QPainterPath stroke = stroker.createStroke(path);
00294 
00295         engine->drawPath(stroke * inv);
00296         op = DrawOperation(op - StrokeDraw);
00297     }
00298 
00299     q->scale(1/sw, 1/sh);
00300 
00301     if (op & FillDraw) {
00302         updateState(state);
00303         engine->drawPath(path);
00304     }
00305 
00306     q->setPen(pen);
00307 
00308     if (op & StrokeDraw) {
00309         q->setBrush(Qt::NoBrush);
00310         updateState(state);
00311         engine->drawPath(path);
00312         q->setBrush(brush);
00313     }
00314 }

Here is the call graph for this function:

void QPainterPrivate::drawOpaqueBackground ( const QPainterPath path,
DrawOperation  operation 
)

Definition at line 237 of file qpainter.cpp.

References QPainterState::bgBrush, QPainterState::brush, QBrush::color(), FillDraw, Qt::NoBrush, Qt::NoPen, Qt::OpaqueMode, path, QPainterState::pen, state, StrokeDraw, QPen::style(), QBrush::style(), Qt::TransparentMode, and QPen::width().

Referenced by draw_helper().

00238 {
00239     Q_Q(QPainter);
00240 
00241     q->setBackgroundMode(Qt::TransparentMode);
00242 
00243     if (op & FillDraw && state->brush.style() != Qt::NoBrush) {
00244         q->fillPath(path, state->bgBrush.color());
00245         q->fillPath(path, state->brush);
00246     }
00247 
00248     if (op & StrokeDraw && state->pen.style() != Qt::NoPen) {
00249         q->strokePath(path, QPen(state->bgBrush.color(), state->pen.width()));
00250         q->strokePath(path, state->pen);
00251     }
00252 
00253     q->setBackgroundMode(Qt::OpaqueMode);
00254 }

Here is the call graph for this function:

void QPainterPrivate::updateMatrix (  ) 

Definition at line 323 of file qpainter.cpp.

References QPaintEngineState::dirtyFlags, QPaintEngine::DirtyTransform, QMatrix::dx(), QMatrix::dy(), QPoint::isNull(), QMatrix::m11(), QMatrix::m12(), QMatrix::m21(), QMatrix::m22(), QPainterState::matrix, redirection_offset, state, txinv, TxNone, QPainterState::txop, TxRotShear, TxScale, TxTranslate, viewMatrix(), QPainterState::VxF, QPainterState::worldMatrix, QPainterState::WxF, QPoint::x(), and QPoint::y().

00324 {
00325     state->matrix = (state->WxF ? state->worldMatrix : QMatrix())
00326                     * (state->VxF ? viewMatrix() : QMatrix());
00327 
00328     txinv = false;                                // no inverted matrix
00329     state->txop  = TxNone;
00330     if (state->matrix.m12()==0.0 && state->matrix.m21()==0.0
00331         && state->matrix.m11() >= 0.0 && state->matrix.m22() >= 0.0) {
00332         if (state->matrix.m11()==1.0 && state->matrix.m22()==1.0) {
00333             if (state->matrix.dx()!=0.0 || state->matrix.dy()!=0.0)
00334                 state->txop = TxTranslate;
00335         } else {
00336             state->txop = TxScale;
00337         }
00338     } else {
00339         state->txop = TxRotShear;
00340     }
00341     if (!redirection_offset.isNull()) {
00342         state->txop |= TxTranslate;
00343         state->WxF = true;
00344         // We want to translate in dev space so we do the adding of the redirection
00345         // offset manually.
00346         state->matrix = QMatrix(state->matrix.m11(), state->matrix.m12(),
00347                               state->matrix.m21(), state->matrix.m22(),
00348                               state->matrix.dx()-redirection_offset.x(),
00349                               state->matrix.dy()-redirection_offset.y());
00350     }
00351     state->dirtyFlags |= QPaintEngine::DirtyTransform;
00352 
00353 //     printf("VxF=%d, WxF=%d\n", state->VxF, state->WxF);
00354 //     qDebug() << " --- using matrix" << state->matrix << redirection_offset;
00355 }

Here is the call graph for this function:

void QPainterPrivate::updateInvMatrix (  ) 

Definition at line 358 of file qpainter.cpp.

References invMatrix, m, state, txinv, QPainterState::vh, QPainterState::vw, QPainterState::vx, QPainterState::VxF, QPainterState::vy, QPainterState::wh, QPainterState::worldMatrix, QPainterState::ww, QPainterState::wx, QPainterState::WxF, and QPainterState::wy.

Referenced by QPainter::clipPath(), and QPainter::clipRegion().

00359 {
00360     Q_ASSERT(txinv == false);
00361     txinv = true;                                // creating inverted matrix
00362     bool invertible;
00363     QMatrix m;
00364     if (state->VxF) {
00365         m.translate(state->vx, state->vy);
00366         m.scale(1.0*state->vw/state->ww, 1.0*state->vh/state->wh);
00367         m.translate(-state->wx, -state->wy);
00368     }
00369     if (state->WxF) {
00370         if (state->VxF)
00371             m = state->worldMatrix * m;
00372         else
00373             m = state->worldMatrix;
00374     }
00375     invMatrix = m.inverted(&invertible);                // invert matrix
00376 }

void QPainterPrivate::init (  ) 

Definition at line 317 of file qpainter.cpp.

References QPainterState::painter, and state.

Referenced by QPainter::QPainter().

00318 {
00319     Q_Q(QPainter);
00320     state->painter = q;
00321 }

int QPainterPrivate::rectSubtraction (  )  const [inline]

Definition at line 159 of file qpainter_p.h.

References Qt::NoPen, QPainterState::pen, state, QPen::style(), and QPen::width().

00159                                 {
00160         return state->pen.style() != Qt::NoPen && state->pen.width() == 0 ? 1 : 0;
00161     }

Here is the call graph for this function:

QMatrix QPainterPrivate::viewMatrix (  )  const

Definition at line 109 of file qpainter.cpp.

References m, state, QPainterState::vh, QPainterState::vw, QPainterState::vx, QPainterState::VxF, QPainterState::vy, QPainterState::wh, QPainterState::ww, QPainterState::wx, and QPainterState::wy.

Referenced by updateMatrix().

00110 {
00111     QMatrix m;
00112     if (state->VxF) {
00113         qreal scaleW = qreal(state->vw)/qreal(state->ww);
00114         qreal scaleH = qreal(state->vh)/qreal(state->wh);
00115         m.setMatrix(scaleW, 0, 0, scaleH, state->vx - state->wx*scaleW, state->vy - state->wy*scaleH);
00116     }
00117     return m;
00118 }


Member Data Documentation

QPainter* QPainterPrivate::q_ptr

Definition at line 126 of file qpainter_p.h.

QPoint QPainterPrivate::redirection_offset

Definition at line 128 of file qpainter_p.h.

Referenced by draw_helper(), and updateMatrix().

QPainterState* QPainterPrivate::state

Definition at line 130 of file qpainter_p.h.

Referenced by draw_helper(), drawOpaqueBackground(), drawStretchToDevice(), init(), QPainterPrivate(), rectSubtraction(), updateEmulationSpecifier(), updateInvMatrix(), updateMatrix(), and viewMatrix().

QVector<QPainterState*> QPainterPrivate::states

Definition at line 131 of file qpainter_p.h.

Referenced by QPainterPrivate(), and ~QPainterPrivate().

QMatrix QPainterPrivate::invMatrix

Definition at line 133 of file qpainter_p.h.

Referenced by updateInvMatrix().

uint QPainterPrivate::txinv

Definition at line 134 of file qpainter_p.h.

Referenced by updateInvMatrix(), and updateMatrix().

QPaintDevice* QPainterPrivate::device

Definition at line 165 of file qpainter_p.h.

Referenced by draw_helper().

QPaintDevice* QPainterPrivate::original_device

Definition at line 166 of file qpainter_p.h.

Referenced by draw_helper(), and drawStretchToDevice().

QPaintEngine* QPainterPrivate::engine

Definition at line 167 of file qpainter_p.h.

Referenced by draw_helper(), drawStretchToDevice(), updateEmulationSpecifier(), and updateState().


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