6#include "QskGraphicNode.h"
8#include "QskColorFilter.h"
9#include "QskPainterCommand.h"
21QskGraphicNode::QskGraphicNode()
25QskGraphicNode::~QskGraphicNode()
29void QskGraphicNode::setGraphic( QQuickWindow* window,
const QskGraphic& graphic,
34 if ( graphic.commandTypes() == QskGraphic::RasterData )
41 size = graphic.defaultSize();
44 const GraphicData graphicData { graphic, colorFilter };
45 update( window, rect, size, &graphicData );
48void QskGraphicNode::paint( QPainter* painter,
const QSize& size,
const void* nodeData )
50 const auto graphicData =
reinterpret_cast< const GraphicData*
>( nodeData );
52 const auto& graphic = graphicData->graphic;
53 const auto& colorFilter = graphicData->colorFilter;
55 const QRectF rect( 0, 0, size.width(), size.height() );
56 graphic.render( painter, rect, colorFilter, Qt::IgnoreAspectRatio );
59QskHashValue QskGraphicNode::hash(
const void* nodeData )
const
61 const auto graphicData =
reinterpret_cast< const GraphicData*
>( nodeData );
63 const auto& graphic = graphicData->graphic;
65 QskHashValue hash = 12000;
67 const auto& substitutions = graphicData->colorFilter.substitutions();
68 if ( substitutions.size() > 0 )
70 hash = qHashBits( substitutions.constData(),
71 substitutions.size() *
sizeof( substitutions[ 0 ] ), hash );
74 return graphic.hash( hash );
A paint device for scalable graphics.