Direct2D QPA: Get rid of QPainterPath conversion function

This function was used only in one place and duplicated a lot of logic
with the very similar QVectorPath conversion function. Just use
QVectorPath everywhere instead.

Change-Id: I3a4821f0452634c309ca0730047ea6ef7a7591ca
Reviewed-by: Risto Avila <risto.avila@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
bb10
Louai Al-Khanji 2014-05-21 14:02:42 +03:00 committed by The Qt Project
parent 8d7e23ea0b
commit bcab05cb4f
1 changed files with 3 additions and 46 deletions

View File

@ -211,51 +211,6 @@ private:
bool m_roundCoordinates;
};
static ComPtr<ID2D1PathGeometry1> painterPathToID2D1PathGeometry(const QPainterPath &path, bool alias)
{
Direct2DPathGeometryWriter writer;
if (!writer.begin())
return NULL;
writer.setWindingFillEnabled(path.fillRule() == Qt::WindingFill);
writer.setAliasingEnabled(alias);
for (int i = 0; i < path.elementCount(); i++) {
const QPainterPath::Element element = path.elementAt(i);
switch (element.type) {
case QPainterPath::MoveToElement:
writer.moveTo(element);
break;
case QPainterPath::LineToElement:
writer.lineTo(element);
break;
case QPainterPath::CurveToElement:
{
const QPainterPath::Element data1 = path.elementAt(++i);
const QPainterPath::Element data2 = path.elementAt(++i);
Q_ASSERT(i < path.elementCount());
Q_ASSERT(data1.type == QPainterPath::CurveToDataElement);
Q_ASSERT(data2.type == QPainterPath::CurveToDataElement);
writer.curveTo(element, data1, data2);
}
break;
case QPainterPath::CurveToDataElement:
qWarning("%s: Unhandled Curve Data Element", __FUNCTION__);
break;
}
}
writer.close();
return writer.geometry();
}
struct D2DVectorPathCache {
ComPtr<ID2D1PathGeometry1> aliased;
ComPtr<ID2D1PathGeometry1> antiAliased;
@ -908,7 +863,9 @@ bool QWindowsDirect2DPaintEngine::begin(QPaintDevice * pdev)
QPainterPath p;
p.addRegion(systemClip());
ComPtr<ID2D1PathGeometry1> geometry = painterPathToID2D1PathGeometry(p, d->antialiasMode() == D2D1_ANTIALIAS_MODE_ALIASED);
ComPtr<ID2D1PathGeometry1> geometry = vectorPathToID2D1PathGeometry(qtVectorPathForPath(p),
d->antialiasMode() == D2D1_ANTIALIAS_MODE_ALIASED,
this);
if (!geometry)
return false;