Changeset 846 for trunk/src/gui/painting/qpaintengine_raster.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/painting/qpaintengine_raster.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 41 41 42 42 #include <QtCore/qglobal.h> 43 #include <QtCore/qmutex.h> 43 44 44 45 #define QT_FT_BEGIN_HEADER … … 68 69 // #include <private/qrasterizer_p.h> 69 70 #include <private/qimage_p.h> 71 #include <private/qstatictext_p.h> 72 #include "qmemrotate_p.h" 70 73 71 74 #include "qpaintengine_raster_p.h" … … 251 254 #endif 252 255 256 QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() : 257 QPaintEngineExPrivate(), 258 cachedLines(0) 259 { 260 } 253 261 254 262 … … 336 344 #endif 337 345 338 d->rasterPoolSize = 8192;339 d->rasterPoolBase =340 #if defined(Q_WS_WIN64)341 // We make use of setjmp and longjmp in qgrayraster.c which requires342 // 16-byte alignment, hence we hardcode this requirement here..343 (unsigned char *) _aligned_malloc(d->rasterPoolSize, sizeof(void*) * 2);344 #else345 (unsigned char *) malloc(d->rasterPoolSize);346 #endif347 Q_CHECK_PTR(d->rasterPoolBase);348 349 346 // The antialiasing raster. 350 347 d->grayRaster.reset(new QT_FT_Raster); 351 348 Q_CHECK_PTR(d->grayRaster.data()); 352 if (qt_ft_grays_raster.raster_new( 0,d->grayRaster.data()))349 if (qt_ft_grays_raster.raster_new(d->grayRaster.data())) 353 350 QT_THROW(std::bad_alloc()); // an error creating the raster is caused by a bad malloc 354 351 355 356 qt_ft_grays_raster.raster_reset(*d->grayRaster.data(), d->rasterPoolBase, d->rasterPoolSize);357 352 358 353 d->rasterizer.reset(new QRasterizer); … … 437 432 Q_D(QRasterPaintEngine); 438 433 439 #if defined(Q_WS_WIN64)440 _aligned_free(d->rasterPoolBase);441 #else442 free(d->rasterPoolBase);443 #endif444 445 434 qt_ft_grays_raster.raster_done(*d->grayRaster.data()); 446 435 } … … 455 444 if (device->devType() == QInternal::Pixmap) { 456 445 QPixmap *pixmap = static_cast<QPixmap *>(device); 457 if (pixmap->data->classId() == QPixmapData::RasterClass) 458 d->device = pixmap->data->buffer(); 446 QPixmapData *pd = pixmap->pixmapData(); 447 if (pd->classId() == QPixmapData::RasterClass) 448 d->device = pd->buffer(); 459 449 } else { 460 450 d->device = device; … … 471 461 QRasterPaintEngineState *s = state(); 472 462 ensureOutlineMapper(); 473 d->outlineMapper->m_clip_rect = d->deviceRect.adjusted(-10, -10, 10, 10); 474 475 // This is the upp 476 QRect bounds(-QT_RASTER_COORD_LIMIT, -QT_RASTER_COORD_LIMIT, 477 QT_RASTER_COORD_LIMIT*2 - 1, QT_RASTER_COORD_LIMIT * 2 - 1); 478 d->outlineMapper->m_clip_rect = bounds.intersected(d->outlineMapper->m_clip_rect); 479 463 d->outlineMapper->m_clip_rect = d->deviceRect; 464 465 if (d->outlineMapper->m_clip_rect.width() > QT_RASTER_COORD_LIMIT) 466 d->outlineMapper->m_clip_rect.setWidth(QT_RASTER_COORD_LIMIT); 467 if (d->outlineMapper->m_clip_rect.height() > QT_RASTER_COORD_LIMIT) 468 d->outlineMapper->m_clip_rect.setHeight(QT_RASTER_COORD_LIMIT); 480 469 481 470 d->rasterizer->setClipRect(d->deviceRect); … … 887 876 updateMatrix(s->matrix); 888 877 889 if (s->dirty & (DirtyPen|DirtyCompositionMode )) {878 if (s->dirty & (DirtyPen|DirtyCompositionMode|DirtyOpacity)) { 890 879 const QPainter::CompositionMode mode = s->composition_mode; 891 880 s->flags.fast_text = (s->penData.type == QSpanData::Solid) 881 && s->intOpacity == 256 892 882 && (mode == QPainter::CompositionMode_Source 893 883 || (mode == QPainter::CompositionMode_SourceOver … … 913 903 s->strokeFlags |= DirtyOpacity; 914 904 s->pixmapFlags |= DirtyOpacity; 905 s->dirty |= DirtyOpacity; 915 906 s->intOpacity = (int) (s->opacity * 256); 916 907 } … … 1115 1106 bool bilinear = q->state()->flags.bilinear; 1116 1107 1117 if (b.d->transform.type() > QTransform::TxNone) { // FALCON: optimi se1108 if (b.d->transform.type() > QTransform::TxNone) { // FALCON: optimize 1118 1109 spanData->setupMatrix(b.transform() * m, bilinear); 1119 1110 } else { … … 1222 1213 if (op != Qt::UniteClip && (op != Qt::IntersectClip || !s->clip 1223 1214 || s->clip->hasRectClip || s->clip->hasRegionClip)) { 1224 if (s->matrix.type() <= QTransform::Tx Translate1215 if (s->matrix.type() <= QTransform::TxScale 1225 1216 && ((path.shape() == QVectorPath::RectangleHint) 1226 1217 || (isRect(points, path.elementCount()) … … 1234 1225 1235 1226 QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); 1236 clip(r.toRect(), op);1237 return;1227 if (setClipRectInDeviceCoords(s->matrix.mapRect(r).toRect(), op)) 1228 return; 1238 1229 } 1239 1230 } … … 1296 1287 #endif 1297 1288 1298 Q_D(QRasterPaintEngine);1299 1289 QRasterPaintEngineState *s = state(); 1300 1290 … … 1306 1296 return; 1307 1297 1308 } else if (op == Qt::ReplaceClip || s->clip == 0) { 1298 } else if (!setClipRectInDeviceCoords(s->matrix.mapRect(rect), op)) { 1299 QPaintEngineEx::clip(rect, op); 1300 return; 1301 } 1302 } 1303 1304 1305 bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOperation op) 1306 { 1307 Q_D(QRasterPaintEngine); 1308 QRect clipRect = r & d->deviceRect; 1309 QRasterPaintEngineState *s = state(); 1310 1311 if (op == Qt::ReplaceClip || s->clip == 0) { 1309 1312 1310 1313 // No current clip, hence we intersect with sysclip and be 1311 1314 // done with it... 1312 QRect clipRect = s->matrix.mapRect(rect) & d->deviceRect;1313 1315 QRegion clipRegion = systemClip(); 1314 1316 QClipData *clip = new QClipData(d->rasterBuffer->height()); … … 1326 1328 s->flags.has_clip_ownership = true; 1327 1329 1328 } else { // intersect clip with current clip1330 } else if (op == Qt::IntersectClip){ // intersect clip with current clip 1329 1331 QClipData *base = s->clip; 1330 1332 1331 1333 Q_ASSERT(base); 1332 1334 if (base->hasRectClip || base->hasRegionClip) { 1333 QRect clipRect = s->matrix.mapRect(rect) & d->deviceRect;1334 1335 if (!s->flags.has_clip_ownership) { 1335 1336 s->clip = new QClipData(d->rasterBuffer->height()); … … 1342 1343 s->clip->enabled = true; 1343 1344 } else { 1344 QPaintEngineEx::clip(rect, op); 1345 return; 1346 } 1347 } 1345 return false; 1346 } 1347 } else { 1348 return false; 1349 } 1350 1348 1351 qrasterpaintengine_dirty_clip(d, s); 1352 return true; 1349 1353 } 1350 1354 … … 1725 1729 int n = qFloor(dashOffset / patternLength); 1726 1730 dashOffset -= n * patternLength; 1727 while (dashOffset > pattern.at(dashIndex)) {1731 while (dashOffset >= pattern.at(dashIndex)) { 1728 1732 dashOffset -= pattern.at(dashIndex); 1729 dashIndex = (dashIndex + 1) % pattern.size(); 1733 if (++dashIndex >= pattern.size()) 1734 dashIndex = 0; 1730 1735 inDash = !inDash; 1731 1736 } … … 1738 1743 1739 1744 for (int i = 0; i < lineCount; ++i) { 1740 dashOffset = s->lastPen.dashOffset();1741 1745 if (lines[i].p1() == lines[i].p2()) { 1742 1746 if (s->lastPen.capStyle() != Qt::FlatCap) { … … 1812 1816 if (s->flags.tx_noshear) { 1813 1817 d->initializeRasterizer(&s->brushData); 1814 // ### Is normalizing really ne ssesary here?1818 // ### Is normalizing really necessary here? 1815 1819 const qreal *p = path.points(); 1816 1820 QRectF r = QRectF(p[0], p[1], p[2] - p[0], p[7] - p[1]).normalized(); … … 2372 2376 #endif 2373 2377 2374 if (pixmap.data->classId() == QPixmapData::RasterClass) { 2375 const QImage &image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; 2378 QPixmapData *pd = pixmap.pixmapData(); 2379 if (pd->classId() == QPixmapData::RasterClass) { 2380 const QImage &image = static_cast<QRasterPixmapData *>(pd)->image; 2376 2381 if (image.depth() == 1) { 2377 2382 Q_D(QRasterPaintEngine); … … 2412 2417 #endif 2413 2418 2414 if (pixmap.data->classId() == QPixmapData::RasterClass) { 2415 const QImage &image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; 2419 QPixmapData* pd = pixmap.pixmapData(); 2420 if (pd->classId() == QPixmapData::RasterClass) { 2421 const QImage &image = static_cast<QRasterPixmapData *>(pd)->image; 2416 2422 if (image.depth() == 1) { 2417 2423 Q_D(QRasterPaintEngine); … … 2430 2436 } 2431 2437 } else { 2432 const QImage image = pixmap.toImage(); 2438 QRect clippedSource = sr.toAlignedRect().intersected(pixmap.rect()); 2439 const QImage image = pd->toImage(clippedSource); 2440 QRectF translatedSource = sr.translated(-clippedSource.topLeft()); 2433 2441 if (image.depth() == 1) { 2434 2442 Q_D(QRasterPaintEngine); … … 2441 2449 return; 2442 2450 } else { 2443 drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);2451 drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), translatedSource); 2444 2452 } 2445 2453 } else { 2446 drawImage(r, image, sr);2454 drawImage(r, image, translatedSource); 2447 2455 } 2448 2456 } … … 2532 2540 } 2533 2541 2542 namespace { 2543 enum RotationType { 2544 Rotation90, 2545 Rotation180, 2546 Rotation270, 2547 NoRotation 2548 }; 2549 2550 inline RotationType qRotationType(const QTransform &transform) 2551 { 2552 QTransform::TransformationType type = transform.type(); 2553 2554 if (type > QTransform::TxRotate) 2555 return NoRotation; 2556 2557 if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(-1)) 2558 && qFuzzyCompare(transform.m21(), qreal(1)) && qFuzzyIsNull(transform.m22())) 2559 return Rotation90; 2560 2561 if (type == QTransform::TxScale && qFuzzyCompare(transform.m11(), qreal(-1)) && qFuzzyIsNull(transform.m12()) 2562 && qFuzzyIsNull(transform.m21()) && qFuzzyCompare(transform.m22(), qreal(-1))) 2563 return Rotation180; 2564 2565 if (type == QTransform::TxRotate && qFuzzyIsNull(transform.m11()) && qFuzzyCompare(transform.m12(), qreal(1)) 2566 && qFuzzyCompare(transform.m21(), qreal(-1)) && qFuzzyIsNull(transform.m22())) 2567 return Rotation270; 2568 2569 return NoRotation; 2570 } 2571 2572 inline bool isPixelAligned(const QRectF &rect) { 2573 return QRectF(rect.toRect()) == rect; 2574 } 2575 } 2576 2534 2577 /*! 2535 2578 \reimp … … 2552 2595 int sr_b = qCeil(sr.bottom()) - 1; 2553 2596 2554 if ( !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {2597 if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) { 2555 2598 // as fillRect will apply the aliased coordinate delta we need to 2556 2599 // subtract it here as we don't use it for image drawing … … 2593 2636 const QClipData *clip = d->clip(); 2594 2637 2638 if (s->matrix.type() > QTransform::TxTranslate 2639 && !stretch_sr 2640 && (!clip || clip->hasRectClip) 2641 && s->intOpacity == 256 2642 && (d->rasterBuffer->compositionMode == QPainter::CompositionMode_SourceOver 2643 || d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source) 2644 && d->rasterBuffer->format == img.format() 2645 && (d->rasterBuffer->format == QImage::Format_RGB16 2646 || d->rasterBuffer->format == QImage::Format_RGB32 2647 || (d->rasterBuffer->format == QImage::Format_ARGB32_Premultiplied 2648 && d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source))) 2649 { 2650 RotationType rotationType = qRotationType(s->matrix); 2651 2652 if (rotationType != NoRotation && qMemRotateFunctions[d->rasterBuffer->format][rotationType] && img.rect().contains(sr.toAlignedRect())) { 2653 QRectF transformedTargetRect = s->matrix.mapRect(r); 2654 2655 if ((!(s->renderHints & QPainter::SmoothPixmapTransform) && !(s->renderHints & QPainter::Antialiasing)) 2656 || (isPixelAligned(transformedTargetRect) && isPixelAligned(sr))) 2657 { 2658 QRect clippedTransformedTargetRect = transformedTargetRect.toRect().intersected(clip ? clip->clipRect : d->deviceRect); 2659 if (clippedTransformedTargetRect.isNull()) 2660 return; 2661 2662 QRectF clippedTargetRect = s->matrix.inverted().mapRect(QRectF(clippedTransformedTargetRect)); 2663 2664 QRect clippedSourceRect 2665 = QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(), 2666 clippedTargetRect.width(), clippedTargetRect.height()).toRect(); 2667 2668 uint dbpl = d->rasterBuffer->bytesPerLine(); 2669 uint sbpl = img.bytesPerLine(); 2670 2671 uchar *dst = d->rasterBuffer->buffer(); 2672 uint bpp = img.depth() >> 3; 2673 2674 const uchar *srcBase = img.bits() + clippedSourceRect.y() * sbpl + clippedSourceRect.x() * bpp; 2675 uchar *dstBase = dst + clippedTransformedTargetRect.y() * dbpl + clippedTransformedTargetRect.x() * bpp; 2676 2677 uint cw = clippedSourceRect.width(); 2678 uint ch = clippedSourceRect.height(); 2679 2680 qMemRotateFunctions[d->rasterBuffer->format][rotationType](srcBase, cw, ch, sbpl, dstBase, dbpl); 2681 2682 return; 2683 } 2684 } 2685 } 2686 2595 2687 if (s->matrix.type() > QTransform::TxTranslate || stretch_sr) { 2596 2688 2597 if (s->flags.fast_images) { 2689 QRectF targetBounds = s->matrix.mapRect(r); 2690 bool exceedsPrecision = targetBounds.width() > 0xffff 2691 || targetBounds.height() > 0xffff; 2692 2693 if (s->flags.fast_images && !exceedsPrecision) { 2598 2694 if (s->matrix.type() > QTransform::TxScale) { 2599 2695 SrcOverTransformFunc func = qTransformFunctions[d->rasterBuffer->format][img.format()]; … … 2717 2813 QImage image; 2718 2814 2719 if (pixmap.data->classId() == QPixmapData::RasterClass) { 2720 image = static_cast<QRasterPixmapData *>(pixmap.data.data())->image; 2815 QPixmapData *pd = pixmap.pixmapData(); 2816 if (pd->classId() == QPixmapData::RasterClass) { 2817 image = static_cast<QRasterPixmapData *>(pd)->image; 2721 2818 } else { 2722 2819 image = pixmap.toImage(); … … 3003 3100 } 3004 3101 3005 void QRasterPaintEngine::drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti) 3102 void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, 3103 const QFixedPoint *positions, QFontEngine *fontEngine) 3006 3104 { 3007 3105 Q_D(QRasterPaintEngine); 3008 3106 QRasterPaintEngineState *s = state(); 3009 3107 3010 QVarLengthArray<QFixedPoint> positions; 3011 QVarLengthArray<glyph_t> glyphs; 3012 QTransform matrix = s->matrix; 3013 matrix.translate(p.x(), p.y()); 3014 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); 3015 3016 QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) : d->glyphCacheType; 3108 QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0 ? QFontEngineGlyphCache::Type(fontEngine->glyphFormat) : d->glyphCacheType; 3017 3109 3018 3110 QImageTextureGlyphCache *cache = 3019 (QImageTextureGlyphCache *) ti.fontEngine->glyphCache(0, glyphType, s->matrix);3111 static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphType, s->matrix)); 3020 3112 if (!cache) { 3021 3113 cache = new QImageTextureGlyphCache(glyphType, s->matrix); 3022 ti.fontEngine->setGlyphCache(0, cache);3023 } 3024 3025 cache->populate( ti, glyphs, positions);3114 fontEngine->setGlyphCache(0, cache); 3115 } 3116 3117 cache->populate(fontEngine, numGlyphs, glyphs, positions); 3026 3118 3027 3119 const QImage &image = cache->image(); … … 3041 3133 3042 3134 const uchar *bits = image.bits(); 3043 for (int i=0; i< glyphs.size(); ++i) {3135 for (int i=0; i<numGlyphs; ++i) { 3044 3136 const QTextureGlyphCache::Coord &c = cache->coords.value(glyphs[i]); 3045 3137 int x = qFloor(positions[i].x + offs) + c.baseLineX - margin; … … 3089 3181 TSize glyphBitmapSize; 3090 3182 fe->getCharacterData(glyphs[i], tmetrics, glyphBitmapBytes, glyphBitmapSize); 3091 const glyph_metrics_t metrics = ti.fontEngine->boundingBox(glyphs[i]); 3092 const int x = qFloor(positions[i].x + metrics.x + aliasDelta); 3093 const int y = qFloor(positions[i].y + metrics.y + aliasDelta); 3094 3183 const int x = qFloor(positions[i].x + tmetrics.HorizBearingX() + aliasDelta); 3184 const int y = qFloor(positions[i].y - tmetrics.HorizBearingY() + aliasDelta); 3095 3185 alphaPenBlt(glyphBitmapBytes, glyphBitmapSize.iWidth, 8, x, y, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight); 3096 3186 } … … 3104 3194 3105 3195 /*! 3106 * Returns true if the rectangle is complet ly within the current clip3196 * Returns true if the rectangle is completely within the current clip 3107 3197 * state of the paint engine. 3108 3198 */ … … 3219 3309 3220 3310 /*! 3311 \reimp 3312 */ 3313 void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) 3314 { 3315 ensurePen(); 3316 ensureState(); 3317 3318 drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, 3319 textItem->fontEngine()); 3320 } 3321 3322 /*! 3221 3323 \reimp 3222 3324 */ … … 3266 3368 #endif 3267 3369 if (drawCached) { 3268 drawCachedGlyphs(p, ti); 3370 QRasterPaintEngineState *s = state(); 3371 3372 QVarLengthArray<QFixedPoint> positions; 3373 QVarLengthArray<glyph_t> glyphs; 3374 3375 QTransform matrix = s->matrix; 3376 matrix.translate(p.x(), p.y()); 3377 3378 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); 3379 3380 drawCachedGlyphs(glyphs.size(), glyphs.constData(), positions.constData(), ti.fontEngine); 3269 3381 return; 3270 3382 } … … 3373 3485 3374 3486 for(int i = 0; i < glyphs.size(); i++) { 3375 QFontEngineFT::Glyph *glyph = gset->g lyph_data.value(glyphs[i]);3487 QFontEngineFT::Glyph *glyph = gset->getGlyph(glyphs[i]); 3376 3488 3377 3489 if (!glyph || glyph->format != neededFormat) { … … 3609 3721 *dashOffset = 0; 3610 3722 *inDash = !(*inDash); 3611 *dashIndex = (*dashIndex + 1) % pattern.size(); 3723 if (++*dashIndex >= pattern.size()) 3724 *dashIndex = 0; 3612 3725 length -= dash; 3613 3726 l.setLength(dash); … … 3615 3728 } 3616 3729 3617 if (rasterize && dash !=0)3730 if (rasterize && dash > 0) 3618 3731 rasterizer->rasterizeLine(l.p1(), l.p2(), width / dash, squareCap); 3619 3732 } … … 3676 3789 || (qpen_style(s->lastPen) == Qt::NoPen && !s->flags.antialiased)) 3677 3790 && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT 3791 && !rect.isEmpty() 3678 3792 && s->matrix.type() <= QTransform::TxScale) // no shear 3679 3793 { … … 4049 4163 } 4050 4164 4165 extern "C" { 4166 int q_gray_rendered_spans(QT_FT_Raster raster); 4167 } 4168 4051 4169 void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, 4052 4170 ProcessSpans callback, … … 4071 4189 return; 4072 4190 } 4191 4192 // Initial size for raster pool is MINIMUM_POOL_SIZE so as to 4193 // minimize memory reallocations. However if initial size for 4194 // raster pool is changed for lower value, reallocations will 4195 // occur normally. 4196 const int rasterPoolInitialSize = MINIMUM_POOL_SIZE; 4197 int rasterPoolSize = rasterPoolInitialSize; 4198 unsigned char *rasterPoolBase; 4199 #if defined(Q_WS_WIN64) 4200 rasterPoolBase = 4201 // We make use of setjmp and longjmp in qgrayraster.c which requires 4202 // 16-byte alignment, hence we hardcode this requirement here.. 4203 (unsigned char *) _aligned_malloc(rasterPoolSize, sizeof(void*) * 2); 4204 #else 4205 unsigned char rasterPoolOnStack[rasterPoolInitialSize]; 4206 rasterPoolBase = rasterPoolOnStack; 4207 #endif 4208 Q_CHECK_PTR(rasterPoolBase); 4209 4210 qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); 4073 4211 4074 4212 void *data = userData; … … 4093 4231 int error; 4094 4232 4233 int rendered_spans = 0; 4234 4095 4235 while (!done) { 4096 4236 4097 4237 rasterParams.flags |= (QT_FT_RASTER_FLAG_AA | QT_FT_RASTER_FLAG_DIRECT); 4098 4238 rasterParams.gray_spans = callback; 4239 rasterParams.skip_spans = rendered_spans; 4099 4240 error = qt_ft_grays_raster.raster_render(*grayRaster.data(), &rasterParams); 4100 4241 4101 4242 // Out of memory, reallocate some more and try again... 4102 if (error == -6) { // -6 is Result_err_OutOfMemory4243 if (error == -6) { // ErrRaster_OutOfMemory from qgrayraster.c 4103 4244 int new_size = rasterPoolSize * 2; 4104 4245 if (new_size > 1024 * 1024) { 4105 4246 qWarning("QPainter: Rasterization of primitive failed"); 4106 return;4247 break; 4107 4248 } 4249 4250 rendered_spans += q_gray_rendered_spans(*grayRaster.data()); 4108 4251 4109 4252 #if defined(Q_WS_WIN64) 4110 4253 _aligned_free(rasterPoolBase); 4111 4254 #else 4112 free(rasterPoolBase); 4255 if (rasterPoolBase != rasterPoolOnStack) // initially on the stack 4256 free(rasterPoolBase); 4113 4257 #endif 4114 4258 … … 4125 4269 4126 4270 qt_ft_grays_raster.raster_done(*grayRaster.data()); 4127 qt_ft_grays_raster.raster_new( 0,grayRaster.data());4271 qt_ft_grays_raster.raster_new(grayRaster.data()); 4128 4272 qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); 4129 4273 } else { … … 4131 4275 } 4132 4276 } 4277 4278 #if defined(Q_WS_WIN64) 4279 _aligned_free(rasterPoolBase); 4280 #else 4281 if (rasterPoolBase != rasterPoolOnStack) // initially on the stack 4282 free(rasterPoolBase); 4283 #endif 4133 4284 } 4134 4285 … … 4812 4963 hash_val += stops[i].second.rgba(); 4813 4964 4965 QMutexLocker lock(&mutex); 4814 4966 QGradientColorTableHash::const_iterator it = cache.constFind(hash_val); 4815 4967 … … 4845 4997 4846 4998 QGradientColorTableHash cache; 4999 QMutex mutex; 4847 5000 }; 4848 5001
Note:
See TracChangeset
for help on using the changeset viewer.