Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/openvg/qpaintengine_vg.cpp

    r651 r769  
    7676#if !defined(QVG_NO_DRAW_GLYPHS)
    7777
    78 extern int qt_defaultDpiX();
    79 extern int qt_defaultDpiY();
     78Q_DECL_IMPORT extern int qt_defaultDpiX();
     79Q_DECL_IMPORT extern int qt_defaultDpiY();
    8080
    8181class QVGPaintEnginePrivate;
     
    121121{
    122122public:
     123    // Extra blending modes from VG_KHR_advanced_blending extension.
     124    // Use the QT_VG prefix to avoid conflicts with any definitions
     125    // that may come in via <VG/vgext.h>.
     126    enum AdvancedBlending {
     127        QT_VG_BLEND_OVERLAY_KHR       = 0x2010,
     128        QT_VG_BLEND_HARDLIGHT_KHR     = 0x2011,
     129        QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
     130        QT_VG_BLEND_SOFTLIGHT_KHR     = 0x2013,
     131        QT_VG_BLEND_COLORDODGE_KHR    = 0x2014,
     132        QT_VG_BLEND_COLORBURN_KHR     = 0x2015,
     133        QT_VG_BLEND_DIFFERENCE_KHR    = 0x2016,
     134        QT_VG_BLEND_SUBTRACT_KHR      = 0x2017,
     135        QT_VG_BLEND_INVERT_KHR        = 0x2018,
     136        QT_VG_BLEND_EXCLUSION_KHR     = 0x2019,
     137        QT_VG_BLEND_LINEARDODGE_KHR   = 0x201a,
     138        QT_VG_BLEND_LINEARBURN_KHR    = 0x201b,
     139        QT_VG_BLEND_VIVIDLIGHT_KHR    = 0x201c,
     140        QT_VG_BLEND_LINEARLIGHT_KHR   = 0x201d,
     141        QT_VG_BLEND_PINLIGHT_KHR      = 0x201e,
     142        QT_VG_BLEND_HARDMIX_KHR       = 0x201f,
     143        QT_VG_BLEND_CLEAR_KHR         = 0x2020,
     144        QT_VG_BLEND_DST_KHR           = 0x2021,
     145        QT_VG_BLEND_SRC_OUT_KHR       = 0x2022,
     146        QT_VG_BLEND_DST_OUT_KHR       = 0x2023,
     147        QT_VG_BLEND_SRC_ATOP_KHR      = 0x2024,
     148        QT_VG_BLEND_DST_ATOP_KHR      = 0x2025,
     149        QT_VG_BLEND_XOR_KHR           = 0x2026
     150    };
     151
    123152    QVGPaintEnginePrivate();
    124153    ~QVGPaintEnginePrivate();
     
    218247#endif
    219248
     249    bool hasAdvancedBlending;
     250
    220251    QScopedPointer<QPixmapFilter> convolutionFilter;
    221252    QScopedPointer<QPixmapFilter> colorizeFilter;
     
    370401    fontEngineCleaner = 0;
    371402#endif
     403
     404    hasAdvancedBlending = false;
    372405
    373406    clearModes();
     
    447480    vgAppendPathData(linePath, 2, segments, coords);
    448481#endif
     482
     483    const char *extensions = reinterpret_cast<const char *>(vgGetString(VG_EXTENSIONS));
     484    if (extensions)
     485        hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0;
    449486}
    450487
     
    497534}
    498535
    499 extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
     536Q_DECL_IMPORT extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
    500537
    501538void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
    502539{
    503     VGfloat devh = pdev->height() - 1;
     540    VGfloat devh = pdev->height();
    504541
    505542    // Construct the VG transform by combining the Qt transform with
    506543    // the following viewport transformation:
    507     //        | 1  0  0   |   | 1 0  0.5 |   | 1  0     0.5      |
    508     //        | 0 -1 devh | * | 0 1 -0.5 | = | 0 -1 (0.5 + devh) |
    509     //        | 0  0  1   |   | 0 0   1  |   | 0  0      1       |
     544    //        | 1  0  0   |
     545    //        | 0 -1 devh |
     546    //        | 0  0  1   |
    510547    // The full VG transform is effectively:
    511548    //      1. Apply the user's transformation matrix.
    512     //      2. Translate by (0.5, -0.5) to correct for Qt and VG putting
    513     //         the centre of the pixel at different positions.
    514     //      3. Flip the co-ordinate system upside down.
     549    //      2. Flip the co-ordinate system upside down.
    515550    QTransform viewport(1.0f, 0.0f, 0.0f,
    516551                        0.0f, -1.0f, 0.0f,
    517                         0.5f, devh + 0.5f, 1.0f);
    518 
    519     // The image transform is always the full transformation,
    520     // because it can be projective.
    521     imageTransform = transform * viewport;
    522 
    523     // Determine if the transformation is projective.
    524     bool projective = (imageTransform.m13() != 0.0f ||
    525                        imageTransform.m23() != 0.0f ||
    526                        imageTransform.m33() != 1.0f);
     552                        0.0f, devh, 1.0f);
     553
     554    // Compute the path transform and determine if it is projective.
     555    pathTransform = transform * viewport;
     556    bool projective = (pathTransform.m13() != 0.0f ||
     557                       pathTransform.m23() != 0.0f ||
     558                       pathTransform.m33() != 1.0f);
    527559    if (projective) {
    528560        // The engine cannot do projective path transforms for us,
     
    532564        simpleTransform = false;
    533565    } else {
    534         pathTransform = imageTransform;
    535566        simpleTransform = true;
    536567    }
    537568    pathTransformSet = false;
     569
     570    // The image transform is always the full transformation,
     571    imageTransform = transform * viewport;
    538572
    539573    // Calculate the scaling factor to use for turning cosmetic pens
     
    9681002}
    9691003
    970 extern QImage qt_imageForBrush(int style, bool invert);
     1004Q_DECL_IMPORT extern QImage qt_imageForBrush(int style, bool invert);
    9711005
    9721006static QImage colorizeBitmap(const QImage &image, const QColor &color)
     
    20632097        (QVGPaintEngine *engine, int width, int height)
    20642098{
     2099    scissorMask = false;
    20652100    if (maskIsSet) {
    20662101        vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, 0, 0, width, height);
     
    22952330    d->dirty |= QPaintEngine::DirtyCompositionMode;
    22962331
    2297     VGBlendMode vgMode = VG_BLEND_SRC_OVER;
     2332    VGint vgMode = VG_BLEND_SRC_OVER;
    22982333
    22992334    switch (state()->composition_mode) {
     
    23292364        break;
    23302365    default:
    2331         qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode;
    2332         break;  // Fall back to VG_BLEND_SRC_OVER.
    2333     }
    2334 
    2335     d->setBlendMode(vgMode);
     2366        if (d->hasAdvancedBlending) {
     2367            switch (state()->composition_mode) {
     2368            case QPainter::CompositionMode_Overlay:
     2369                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR;
     2370                break;
     2371            case QPainter::CompositionMode_ColorDodge:
     2372                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR;
     2373                break;
     2374            case QPainter::CompositionMode_ColorBurn:
     2375                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR;
     2376                break;
     2377            case QPainter::CompositionMode_HardLight:
     2378                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR;
     2379                break;
     2380            case QPainter::CompositionMode_SoftLight:
     2381                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR;
     2382                break;
     2383            case QPainter::CompositionMode_Difference:
     2384                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR;
     2385                break;
     2386            case QPainter::CompositionMode_Exclusion:
     2387                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR;
     2388                break;
     2389            case QPainter::CompositionMode_SourceOut:
     2390                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR;
     2391                break;
     2392            case QPainter::CompositionMode_DestinationOut:
     2393                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR;
     2394                break;
     2395            case QPainter::CompositionMode_SourceAtop:
     2396                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR;
     2397                break;
     2398            case QPainter::CompositionMode_DestinationAtop:
     2399                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR;
     2400                break;
     2401            case QPainter::CompositionMode_Xor:
     2402                vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR;
     2403                break;
     2404            default: break; // Fall back to VG_BLEND_SRC_OVER.
     2405            }
     2406        }
     2407        if (vgMode == VG_BLEND_SRC_OVER)
     2408            qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode;
     2409        break;
     2410    }
     2411
     2412    d->setBlendMode(VGBlendMode(vgMode));
    23362413}
    23372414
     
    24002477
    24012478    // Check to see if we can use vgClear() for faster filling.
    2402     if (brush.style() == Qt::SolidPattern &&
     2479    if (brush.style() == Qt::SolidPattern && brush.isOpaque() &&
    24032480            clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
    24042481            clearRect(rect, brush.color())) {
     
    24432520
    24442521    // Check to see if we can use vgClear() for faster filling.
    2445     if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
     2522    if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 &&
    24462523            clearRect(rect, color)) {
    24472524        return;
     
    32403317            }
    32413318        }
    3242         origin[0] = -metrics.x.toReal() + 0.5f;
    3243         origin[1] = -metrics.y.toReal() + 0.5f;
    3244         escapement[0] = metrics.xoff.toReal();
    3245         escapement[1] = metrics.yoff.toReal();
     3319        origin[0] = -metrics.x.toReal();
     3320        origin[1] = -metrics.y.toReal();
     3321        escapement[0] = 0;
     3322        escapement[1] = 0;
    32463323        vgSetGlyphToImage(font, glyph, vgImage, origin, escapement);
    32473324        vgDestroyImage(vgImage);    // Reduce reference count.
     
    32593336        origin[0] = 0;
    32603337        origin[1] = 0;
    3261         escapement[0] = metrics.xoff.toReal();
    3262         escapement[1] = metrics.yoff.toReal();
     3338        escapement[0] = 0;
     3339        escapement[1] = 0;
    32633340        vgSetGlyphToPath(font, glyph, vgPath, VG_FALSE, origin, escapement);
    32643341        vgDestroyPath(vgPath);      // Reduce reference count.
     
    32853362    QVarLengthArray<QFixedPoint> positions;
    32863363    QVarLengthArray<glyph_t> glyphs;
    3287     QTransform matrix = d->transform;
    3288     matrix.translate(p.x(), p.y());
    3289     ti.fontEngine->getGlyphPositions
    3290         (ti.glyphs, matrix, ti.flags, glyphs, positions);
     3364    QTransform matrix;
     3365    ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
    32913366
    32923367    // Find the glyph cache for this font.
     
    33223397    glyphCache->cacheGlyphs(d, ti, glyphs);
    33233398
     3399    // Create the array of adjustments between glyphs
     3400    QVarLengthArray<VGfloat> adjustments_x(glyphs.size());
     3401    QVarLengthArray<VGfloat> adjustments_y(glyphs.size());
     3402    for (int i = 1; i < glyphs.size(); ++i) {
     3403        adjustments_x[i-1] = (positions[i].x - positions[i-1].x).toReal();
     3404        adjustments_y[i-1] = (positions[i].y - positions[i-1].y).toReal();
     3405    }
     3406
    33243407    // Set the glyph drawing origin.
    33253408    VGfloat origin[2];
    3326     origin[0] = 0;
    3327     origin[1] = 0;
     3409    origin[0] = positions[0].x.toReal();
     3410    origin[1] = positions[0].y.toReal();
    33283411    vgSetfv(VG_GLYPH_ORIGIN, 2, origin);
    33293412
     
    33403423    d->ensureBrush(state()->pen.brush());
    33413424    vgDrawGlyphs(glyphCache->font, glyphs.size(), (VGuint*)glyphs.data(),
    3342                  NULL, NULL, VG_FILL_PATH, VG_TRUE);
     3425                 adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE);
    33433426#else
    33443427    // OpenGL 1.0 does not have support for VGFont and glyphs,
     
    36453728    } else {
    36463729        // Set the path transform to the default viewport transformation.
    3647         VGfloat devh = screenSize.height() - 1;
     3730        VGfloat devh = screenSize.height();
    36483731        QTransform viewport(1.0f, 0.0f, 0.0f,
    36493732                            0.0f, -1.0f, 0.0f,
    3650                             -0.5f, devh + 0.5f, 1.0f);
     3733                            0.0f, devh, 1.0f);
    36513734        d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
    36523735
     
    36843767
    36853768    // Set the image transformation and modes.
    3686     VGfloat devh = screenSize.height() - 1;
     3769    VGfloat devh = screenSize.height();
    36873770    QTransform transform(1.0f, 0.0f, 0.0f,
    36883771                         0.0f, -1.0f, 0.0f,
    3689                          -0.5f, devh + 0.5f, 1.0f);
     3772                         0.0f, devh, 1.0f);
    36903773    transform.translate(offset.x(), offset.y());
    36913774    d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
Note: See TracChangeset for help on using the changeset viewer.