src/gui/painting/qpaintengine_raster.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
  1360     qDebug() << "QRasterPaintEngine::clip(): " << region << op;
  1360     qDebug() << "QRasterPaintEngine::clip(): " << region << op;
  1361 #endif
  1361 #endif
  1362 
  1362 
  1363     Q_D(QRasterPaintEngine);
  1363     Q_D(QRasterPaintEngine);
  1364 
  1364 
  1365     if (region.numRects() == 1) {
  1365     if (region.rectCount() == 1) {
  1366         clip(region.boundingRect(), op);
  1366         clip(region.boundingRect(), op);
  1367         return;
  1367         return;
  1368     }
  1368     }
  1369 
  1369 
  1370     QRasterPaintEngineState *s = state();
  1370     QRasterPaintEngineState *s = state();
  1684     QRasterPaintEngineState *s = state();
  1684     QRasterPaintEngineState *s = state();
  1685     ensurePen(pen);
  1685     ensurePen(pen);
  1686     if (!s->penData.blend)
  1686     if (!s->penData.blend)
  1687         return;
  1687         return;
  1688 
  1688 
  1689     if (s->flags.fast_pen && path.shape() <= QVectorPath::NonCurvedShapeHint
  1689     if (s->flags.fast_pen && !path.isCurved()
  1690         && s->lastPen.brush().isOpaque()) {
  1690         && s->lastPen.brush().isOpaque()) {
  1691         int count = path.elementCount();
  1691         int count = path.elementCount();
  1692         QPointF *points = (QPointF *) path.points();
  1692         QPointF *points = (QPointF *) path.points();
  1693         const QPainterPath::ElementType *types = path.elements();
  1693         const QPainterPath::ElementType *types = path.elements();
  1694         if (types) {
  1694         if (types) {
  1737         d->initializeRasterizer(&s->penData);
  1737         d->initializeRasterizer(&s->penData);
  1738         int lineCount = path.elementCount() / 2;
  1738         int lineCount = path.elementCount() / 2;
  1739         const QLineF *lines = reinterpret_cast<const QLineF *>(path.points());
  1739         const QLineF *lines = reinterpret_cast<const QLineF *>(path.points());
  1740 
  1740 
  1741         for (int i = 0; i < lineCount; ++i) {
  1741         for (int i = 0; i < lineCount; ++i) {
  1742             if (path.shape() == QVectorPath::LinesHint)
  1742             dashOffset = s->lastPen.dashOffset();
  1743                 dashOffset = s->lastPen.dashOffset();
       
  1744             if (lines[i].p1() == lines[i].p2()) {
  1743             if (lines[i].p1() == lines[i].p2()) {
  1745                 if (s->lastPen.capStyle() != Qt::FlatCap) {
  1744                 if (s->lastPen.capStyle() != Qt::FlatCap) {
  1746                     QPointF p = lines[i].p1();
  1745                     QPointF p = lines[i].p1();
  1747                     QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()),
  1746                     QLineF line = s->matrix.map(QLineF(QPointF(p.x() - width*0.5, p.y()),
  1748                                                        QPointF(p.x() + width*0.5, p.y())));
  1747                                                        QPointF(p.x() + width*0.5, p.y())));
  3017     ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
  3016     ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
  3018 
  3017 
  3019     QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType;
  3018     QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType;
  3020 
  3019 
  3021     QImageTextureGlyphCache *cache =
  3020     QImageTextureGlyphCache *cache =
  3022         (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(glyphType, s->matrix);
  3021         (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(0, glyphType, s->matrix);
  3023     if (!cache) {
  3022     if (!cache) {
  3024         cache = new QImageTextureGlyphCache(glyphType, s->matrix);
  3023         cache = new QImageTextureGlyphCache(glyphType, s->matrix);
  3025         ti.fontEngine->setGlyphCache(glyphType, cache);
  3024         ti.fontEngine->setGlyphCache(0, cache);
  3026     }
  3025     }
  3027 
  3026 
  3028     cache->populate(ti, glyphs, positions);
  3027     cache->populate(ti, glyphs, positions);
  3029 
  3028 
  3030     const QImage &image = cache->image();
  3029     const QImage &image = cache->image();
  3239 
  3238 
  3240     if (s->matrix.type() >= QTransform::TxProject)
  3239     if (s->matrix.type() >= QTransform::TxProject)
  3241         drawCached = false;
  3240         drawCached = false;
  3242 
  3241 
  3243     // don't try to cache huge fonts
  3242     // don't try to cache huge fonts
  3244     if (ti.fontEngine->fontDef.pixelSize * qSqrt(s->matrix.determinant()) >= 64)
  3243     const qreal pixelSize = ti.fontEngine->fontDef.pixelSize;
       
  3244     if (pixelSize * pixelSize * qAbs(s->matrix.determinant()) >= 64 * 64)
  3245         drawCached = false;
  3245         drawCached = false;
  3246 
  3246 
  3247     // ### Remove the TestFontEngine and Box engine crap, in these
  3247     // ### Remove the TestFontEngine and Box engine crap, in these
  3248     // ### cases we should delegate painting to the font engine
  3248     // ### cases we should delegate painting to the font engine
  3249     // ### directly...
  3249     // ### directly...
  4535 /*
  4535 /*
  4536     Convert \a region to clip spans.
  4536     Convert \a region to clip spans.
  4537  */
  4537  */
  4538 void QClipData::setClipRegion(const QRegion &region)
  4538 void QClipData::setClipRegion(const QRegion &region)
  4539 {
  4539 {
  4540     if (region.numRects() == 1) {
  4540     if (region.rectCount() == 1) {
  4541         setClipRect(region.rects().at(0));
  4541         setClipRect(region.rects().at(0));
  4542         return;
  4542         return;
  4543     }
  4543     }
  4544 
  4544 
  4545     hasRegionClip = true;
  4545     hasRegionClip = true;
  5118 #endif
  5118 #endif
  5119             unclipped_blend = qBlendTexture;
  5119             unclipped_blend = qBlendTexture;
  5120 #else
  5120 #else
  5121         unclipped_blend = qBlendTexture;
  5121         unclipped_blend = qBlendTexture;
  5122 #endif
  5122 #endif
       
  5123         if (!texture.imageData)
       
  5124             unclipped_blend = 0;
       
  5125 
  5123         break;
  5126         break;
  5124     }
  5127     }
  5125     // setup clipping
  5128     // setup clipping
  5126     if (!unclipped_blend) {
  5129     if (!unclipped_blend) {
  5127         blend = 0;
  5130         blend = 0;