Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    7474
    7575
    76 void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen)
     76void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, const QRectF &)
    7777{
    7878    const qreal *pts = path.points();
     
    112112    //
    113113    // The curvyness value of PI/14 was based on,
    114     // arcLength=2*PI*r/4=PI/2 and splitting length into somewhere
     114    // arcLength = 2*PI*r/4 = PI*r/2 and splitting length into somewhere
    115115    // between 3 and 8 where 5 seemed to be give pretty good results
    116116    // hence: Q_PI/14. Lower divisors will give more detail at the
     
    482482
    483483QDashedStrokeProcessor::QDashedStrokeProcessor()
    484     : m_dash_stroker(0), m_inv_scale(1)
     484    : m_points(0), m_types(0),
     485      m_dash_stroker(0), m_inv_scale(1)
    485486{
    486487    m_dash_stroker.setMoveToHook(qdashprocessor_moveTo);
     
    489490}
    490491
    491 void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen)
     492void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, const QRectF &clip)
    492493{
    493494
     
    496497    int count = path.elementCount();
    497498
     499    bool cosmetic = pen.isCosmetic();
     500
    498501    m_points.reset();
    499502    m_types.reset();
     503    m_points.reserve(path.elementCount());
     504    m_types.reserve(path.elementCount());
    500505
    501506    qreal width = qpen_widthf(pen);
     
    504509
    505510    m_dash_stroker.setDashPattern(pen.dashPattern());
    506     m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width);
     511    m_dash_stroker.setStrokeWidth(cosmetic ? width * m_inv_scale : width);
     512    m_dash_stroker.setDashOffset(pen.dashOffset());
    507513    m_dash_stroker.setMiterLimit(pen.miterLimit());
    508     qreal curvyness = sqrt(width) * m_inv_scale / 8;
     514    m_dash_stroker.setClipRect(clip);
     515
     516    float curvynessAdd, curvynessMul, roundness = 0;
     517
     518    // simplfy pens that are thin in device size (2px wide or less)
     519    if (width < 2.5 && (cosmetic || m_inv_scale == 1)) {
     520        curvynessAdd = 0.5;
     521        curvynessMul = CURVE_FLATNESS / m_inv_scale;
     522        roundness = 1;
     523    } else if (cosmetic) {
     524        curvynessAdd= width / 2;
     525        curvynessMul= CURVE_FLATNESS;
     526        roundness = qMax<int>(4, width * CURVE_FLATNESS);
     527    } else {
     528        curvynessAdd = width * m_inv_scale;
     529        curvynessMul = CURVE_FLATNESS / m_inv_scale;
     530        roundness = qMax<int>(4, width * curvynessMul);
     531    }
    509532
    510533    if (count < 2)
     
    541564                                                *(((const QPointF *) pts) + 2));
    542565                QRectF bounds = b.bounds();
    543                 int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * curvyness);
     566                float rad = qMax(bounds.width(), bounds.height());
     567                int threshold = qMin<float>(64, (rad + curvynessAdd) * curvynessMul);
    544568                if (threshold < 4)
    545569                    threshold = 4;
     570
    546571                qreal threshold_minus_1 = threshold - 1;
    547572                for (int i=0; i<threshold; ++i) {
Note: See TracChangeset for help on using the changeset viewer.