version compatible handling of QPainter::RenderHints
This commit is contained in:
parent
441488e41f
commit
efabc6d2ee
@ -16,6 +16,11 @@
|
|||||||
#include <qpainterpath.h>
|
#include <qpainterpath.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
|
|
||||||
|
QSK_QT_PRIVATE_BEGIN
|
||||||
|
#include <private/qpainter_p.h>
|
||||||
|
#include <private/qpaintengineex_p.h>
|
||||||
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
static inline qreal qskDevicePixelRatio()
|
static inline qreal qskDevicePixelRatio()
|
||||||
{
|
{
|
||||||
return qGuiApp ? qGuiApp->devicePixelRatio() : 1.0;
|
return qGuiApp ? qGuiApp->devicePixelRatio() : 1.0;
|
||||||
@ -44,16 +49,18 @@ static bool qskHasScalablePen( const QPainter* painter )
|
|||||||
static QRectF qskStrokedPathRect(
|
static QRectF qskStrokedPathRect(
|
||||||
const QPainter* painter, const QPainterPath& path )
|
const QPainter* painter, const QPainterPath& path )
|
||||||
{
|
{
|
||||||
|
const auto pen = painter->pen();
|
||||||
|
|
||||||
QPainterPathStroker stroker;
|
QPainterPathStroker stroker;
|
||||||
stroker.setWidth( painter->pen().widthF() );
|
stroker.setWidth( pen.widthF() );
|
||||||
stroker.setCapStyle( painter->pen().capStyle() );
|
stroker.setCapStyle( pen.capStyle() );
|
||||||
stroker.setJoinStyle( painter->pen().joinStyle() );
|
stroker.setJoinStyle( pen.joinStyle() );
|
||||||
stroker.setMiterLimit( painter->pen().miterLimit() );
|
stroker.setMiterLimit( pen.miterLimit() );
|
||||||
|
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
if ( qskHasScalablePen( painter ) )
|
if ( qskHasScalablePen( painter ) )
|
||||||
{
|
{
|
||||||
QPainterPath stroke = stroker.createStroke( path );
|
const QPainterPath stroke = stroker.createStroke( path );
|
||||||
rect = painter->transform().map( stroke ).boundingRect();
|
rect = painter->transform().map( stroke ).boundingRect();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -128,20 +135,20 @@ static inline void qskExecCommand(
|
|||||||
}
|
}
|
||||||
case QskPainterCommand::Pixmap:
|
case QskPainterCommand::Pixmap:
|
||||||
{
|
{
|
||||||
const QskPainterCommand::PixmapData* data = cmd.pixmapData();
|
const auto data = cmd.pixmapData();
|
||||||
painter->drawPixmap( data->rect, data->pixmap, data->subRect );
|
painter->drawPixmap( data->rect, data->pixmap, data->subRect );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QskPainterCommand::Image:
|
case QskPainterCommand::Image:
|
||||||
{
|
{
|
||||||
const QskPainterCommand::ImageData* data = cmd.imageData();
|
const auto data = cmd.imageData();
|
||||||
painter->drawImage( data->rect, data->image,
|
painter->drawImage( data->rect, data->image,
|
||||||
data->subRect, data->flags );
|
data->subRect, data->flags );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QskPainterCommand::State:
|
case QskPainterCommand::State:
|
||||||
{
|
{
|
||||||
const QskPainterCommand::StateData* data = cmd.stateData();
|
const auto data = cmd.stateData();
|
||||||
|
|
||||||
if ( data->flags & QPaintEngine::DirtyPen )
|
if ( data->flags & QPaintEngine::DirtyPen )
|
||||||
painter->setPen( colorFilter.substituted( data->pen ) );
|
painter->setPen( colorFilter.substituted( data->pen ) );
|
||||||
@ -182,22 +189,20 @@ static inline void qskExecCommand(
|
|||||||
|
|
||||||
if ( data->flags & QPaintEngine::DirtyHints )
|
if ( data->flags & QPaintEngine::DirtyHints )
|
||||||
{
|
{
|
||||||
const QPainter::RenderHints hints = data->renderHints;
|
#if 1
|
||||||
|
auto state = QPainterPrivate::get( painter )->state;
|
||||||
|
state->renderHints = data->renderHints;
|
||||||
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing,
|
// to trigger internal updates we have to set at least one flag
|
||||||
hints.testFlag( QPainter::Antialiasing ) );
|
const auto hint = QPainter::SmoothPixmapTransform;
|
||||||
|
painter->setRenderHint( hint, data->renderHints.testFlag( hint ) );
|
||||||
painter->setRenderHint( QPainter::TextAntialiasing,
|
#else
|
||||||
hints.testFlag( QPainter::TextAntialiasing ) );
|
for ( int i = 0; i < 8; i++ )
|
||||||
|
{
|
||||||
painter->setRenderHint( QPainter::SmoothPixmapTransform,
|
const auto hint = static_cast< QPainter::RenderHint >( 1 << i );
|
||||||
hints.testFlag( QPainter::SmoothPixmapTransform ) );
|
painter->setRenderHint( hint, data->renderHints.testFlag( hint ) );
|
||||||
|
}
|
||||||
painter->setRenderHint( QPainter::HighQualityAntialiasing,
|
#endif
|
||||||
hints.testFlag( QPainter::HighQualityAntialiasing ) );
|
|
||||||
|
|
||||||
painter->setRenderHint( QPainter::NonCosmeticDefaultPen,
|
|
||||||
hints.testFlag( QPainter::NonCosmeticDefaultPen ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( data->flags & QPaintEngine::DirtyCompositionMode )
|
if ( data->flags & QPaintEngine::DirtyCompositionMode )
|
||||||
@ -694,7 +699,7 @@ void QskGraphic::render( QPainter* painter, const QRectF& rect,
|
|||||||
tr.scale( sx, sy );
|
tr.scale( sx, sy );
|
||||||
tr.translate( -pr.x(), -pr.y() );
|
tr.translate( -pr.x(), -pr.y() );
|
||||||
|
|
||||||
const QTransform transform = painter->transform();
|
const auto transform = painter->transform();
|
||||||
|
|
||||||
painter->setTransform( tr, true );
|
painter->setTransform( tr, true );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user