6#include "QskPainterCommand.h"
8QskPainterCommand::QskPainterCommand(
const QPainterPath& path )
11 m_path =
new QPainterPath( path );
14QskPainterCommand::QskPainterCommand(
const QRectF& rect,
15 const QPixmap& pixmap,
const QRectF& subRect )
18 m_pixmapData =
new PixmapData();
19 m_pixmapData->rect = rect;
20 m_pixmapData->pixmap = pixmap;
21 m_pixmapData->subRect = subRect;
24QskPainterCommand::QskPainterCommand(
const QRectF& rect,
25 const QImage& image,
const QRectF& subRect, Qt::ImageConversionFlags flags )
28 m_imageData =
new ImageData();
29 m_imageData->rect = rect;
30 m_imageData->image = image;
31 m_imageData->subRect = subRect;
32 m_imageData->flags = flags;
35QskPainterCommand::QskPainterCommand(
const QskPainterCommand::StateData& data )
38 m_stateData =
new StateData( data );
41QskPainterCommand::QskPainterCommand(
const QPaintEngineState& state )
44 m_stateData =
new StateData();
46 m_stateData->flags = state.state();
48 if ( m_stateData->flags & QPaintEngine::DirtyPen )
49 m_stateData->pen = state.pen();
51 if ( m_stateData->flags & QPaintEngine::DirtyBrush )
52 m_stateData->brush = state.brush();
54 if ( m_stateData->flags & QPaintEngine::DirtyBrushOrigin )
55 m_stateData->brushOrigin = state.brushOrigin();
57 if ( m_stateData->flags & QPaintEngine::DirtyFont )
58 m_stateData->font = state.font();
60 if ( m_stateData->flags & QPaintEngine::DirtyBackground )
62 m_stateData->backgroundMode = state.backgroundMode();
63 m_stateData->backgroundBrush = state.backgroundBrush();
66 if ( m_stateData->flags & QPaintEngine::DirtyTransform )
67 m_stateData->transform = state.transform();
69 if ( m_stateData->flags & QPaintEngine::DirtyClipEnabled )
70 m_stateData->isClipEnabled = state.isClipEnabled();
72 if ( m_stateData->flags & QPaintEngine::DirtyClipRegion )
74 m_stateData->clipRegion = state.clipRegion();
75 m_stateData->clipOperation = state.clipOperation();
78 if ( m_stateData->flags & QPaintEngine::DirtyClipPath )
80 m_stateData->clipPath = state.clipPath();
81 m_stateData->clipOperation = state.clipOperation();
84 if ( m_stateData->flags & QPaintEngine::DirtyHints )
85 m_stateData->renderHints = state.renderHints();
87 if ( m_stateData->flags & QPaintEngine::DirtyCompositionMode )
88 m_stateData->compositionMode = state.compositionMode();
90 if ( m_stateData->flags & QPaintEngine::DirtyOpacity )
91 m_stateData->opacity = state.opacity();
99QskPainterCommand::~QskPainterCommand()
112bool QskPainterCommand::operator==(
const QskPainterCommand& other )
const noexcept
114 if ( m_type != other.m_type )
121 return ( m_path == other.m_path );
125 return ( m_pixmapData == other.m_pixmapData );
129 return ( m_imageData == other.m_imageData );
133 const StateData& sd = *m_stateData;
134 const StateData& osd = *other.m_stateData;
136 if ( sd.flags != osd.flags )
139 if ( sd.flags & QPaintEngine::DirtyPen )
141 if ( sd.pen != osd.pen )
145 if ( sd.flags & QPaintEngine::DirtyBrush )
147 if ( sd.brush != osd.brush )
151 if ( sd.flags & QPaintEngine::DirtyBrushOrigin )
153 if ( sd.brushOrigin != osd.brushOrigin )
157 if ( sd.flags & QPaintEngine::DirtyFont )
159 if ( sd.font != osd.font )
163 if ( sd.flags & QPaintEngine::DirtyBackground )
165 if ( sd.backgroundMode != osd.backgroundMode ||
166 sd.backgroundBrush != osd.backgroundBrush )
172 if ( sd.flags & QPaintEngine::DirtyTransform )
174 if ( sd.transform != osd.transform )
178 if ( sd.flags & QPaintEngine::DirtyClipEnabled )
180 if ( sd.isClipEnabled != osd.isClipEnabled )
184 if ( sd.flags & QPaintEngine::DirtyClipRegion )
186 if ( sd.clipRegion != osd.clipRegion ||
187 sd.clipOperation != osd.clipOperation )
193 if ( sd.flags & QPaintEngine::DirtyClipPath )
195 if ( sd.clipPath != osd.clipPath ||
196 sd.clipOperation != osd.clipOperation )
202 if ( sd.flags & QPaintEngine::DirtyHints )
204 if ( sd.renderHints != osd.renderHints )
208 if ( sd.flags & QPaintEngine::DirtyCompositionMode )
210 if ( sd.compositionMode != osd.compositionMode )
214 if ( sd.flags & QPaintEngine::DirtyOpacity )
216 if ( sd.opacity != osd.opacity )
231 m_type = other.m_type;
233 switch ( other.m_type )
237 m_path =
new QPainterPath( *other.m_path );
242 m_pixmapData =
new PixmapData( *other.m_pixmapData );
247 m_imageData =
new ImageData( *other.m_imageData );
252 m_stateData =
new StateData( *other.m_stateData );
260void QskPainterCommand::reset()
291QPainterPath* QskPainterCommand::path() noexcept
296QskPainterCommand::PixmapData* QskPainterCommand::pixmapData() noexcept
301QskPainterCommand::ImageData* QskPainterCommand::imageData() noexcept
306QskPainterCommand::StateData* QskPainterCommand::stateData() noexcept
@ Path
Draw a QPainterPath.
@ Invalid
Invalid command.
@ State
QPainter state change.