equal
deleted
inserted
replaced
75 #define QVG_NO_RENDER_TO_MASK 1 |
75 #define QVG_NO_RENDER_TO_MASK 1 |
76 #endif |
76 #endif |
77 |
77 |
78 #if !defined(QVG_NO_DRAW_GLYPHS) |
78 #if !defined(QVG_NO_DRAW_GLYPHS) |
79 |
79 |
|
80 // use the same rounding as in qrasterizer.cpp (6 bit fixed point) |
|
81 static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; |
|
82 |
80 Q_DECL_IMPORT extern int qt_defaultDpiX(); |
83 Q_DECL_IMPORT extern int qt_defaultDpiX(); |
81 Q_DECL_IMPORT extern int qt_defaultDpiY(); |
84 Q_DECL_IMPORT extern int qt_defaultDpiY(); |
82 |
85 |
83 class QVGPaintEnginePrivate; |
86 class QVGPaintEnginePrivate; |
84 |
87 |
100 QVGPaintEnginePrivate *d_ptr; |
103 QVGPaintEnginePrivate *d_ptr; |
101 }; |
104 }; |
102 |
105 |
103 class QVGPaintEnginePrivate : public QPaintEngineExPrivate |
106 class QVGPaintEnginePrivate : public QPaintEngineExPrivate |
104 { |
107 { |
|
108 Q_DECLARE_PUBLIC(QVGPaintEngine) |
105 public: |
109 public: |
106 // Extra blending modes from VG_KHR_advanced_blending extension. |
110 // Extra blending modes from VG_KHR_advanced_blending extension. |
107 // Use the QT_VG prefix to avoid conflicts with any definitions |
111 // Use the QT_VG prefix to avoid conflicts with any definitions |
108 // that may come in via <VG/vgext.h>. |
112 // that may come in via <VG/vgext.h>. |
109 enum AdvancedBlending { |
113 enum AdvancedBlending { |
130 QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, |
134 QT_VG_BLEND_SRC_ATOP_KHR = 0x2024, |
131 QT_VG_BLEND_DST_ATOP_KHR = 0x2025, |
135 QT_VG_BLEND_DST_ATOP_KHR = 0x2025, |
132 QT_VG_BLEND_XOR_KHR = 0x2026 |
136 QT_VG_BLEND_XOR_KHR = 0x2026 |
133 }; |
137 }; |
134 |
138 |
135 QVGPaintEnginePrivate(); |
139 QVGPaintEnginePrivate(QVGPaintEngine *q_ptr); |
136 ~QVGPaintEnginePrivate(); |
140 ~QVGPaintEnginePrivate(); |
137 |
141 |
138 void init(); |
142 void init(); |
139 void initObjects(); |
143 void initObjects(); |
140 void destroy(); |
144 void destroy(); |
151 VGPaintType prevPaintType); |
155 VGPaintType prevPaintType); |
152 void setPenParams(const QPen& pen); |
156 void setPenParams(const QPen& pen); |
153 void setBrushTransform(const QBrush& brush, VGMatrixMode mode); |
157 void setBrushTransform(const QBrush& brush, VGMatrixMode mode); |
154 void setupColorRamp(const QGradient *grad, VGPaint paint); |
158 void setupColorRamp(const QGradient *grad, VGPaint paint); |
155 void setImageOptions(); |
159 void setImageOptions(); |
|
160 void systemStateChanged(); |
156 #if !defined(QVG_SCISSOR_CLIP) |
161 #if !defined(QVG_SCISSOR_CLIP) |
157 void ensureMask(QVGPaintEngine *engine, int width, int height); |
162 void ensureMask(QVGPaintEngine *engine, int width, int height); |
158 void modifyMask |
163 void modifyMask |
159 (QVGPaintEngine *engine, VGMaskOperation op, const QRegion& region); |
164 (QVGPaintEngine *engine, VGMaskOperation op, const QRegion& region); |
160 void modifyMask |
165 void modifyMask |
279 inline void setBlendMode(VGBlendMode mode); |
284 inline void setBlendMode(VGBlendMode mode); |
280 inline void setFillRule(VGint mode); |
285 inline void setFillRule(VGint mode); |
281 |
286 |
282 // Clear all lazily-set modes. |
287 // Clear all lazily-set modes. |
283 void clearModes(); |
288 void clearModes(); |
|
289 |
|
290 private: |
|
291 QVGPaintEngine *q; |
284 }; |
292 }; |
285 |
293 |
286 inline void QVGPaintEnginePrivate::setImageMode(VGImageMode mode) |
294 inline void QVGPaintEnginePrivate::setImageMode(VGImageMode mode) |
287 { |
295 { |
288 if (imageMode != mode) { |
296 if (imageMode != mode) { |
330 blendMode = (VGBlendMode)0; |
338 blendMode = (VGBlendMode)0; |
331 renderingQuality = (VGRenderingQuality)0; |
339 renderingQuality = (VGRenderingQuality)0; |
332 imageQuality = (VGImageQuality)0; |
340 imageQuality = (VGImageQuality)0; |
333 } |
341 } |
334 |
342 |
335 QVGPaintEnginePrivate::QVGPaintEnginePrivate() |
343 QVGPaintEnginePrivate::QVGPaintEnginePrivate(QVGPaintEngine *q_ptr) : q(q_ptr) |
336 { |
344 { |
337 init(); |
345 init(); |
338 } |
346 } |
339 |
347 |
340 void QVGPaintEnginePrivate::init() |
348 void QVGPaintEnginePrivate::init() |
1429 QVGPainterState::~QVGPainterState() |
1437 QVGPainterState::~QVGPainterState() |
1430 { |
1438 { |
1431 } |
1439 } |
1432 |
1440 |
1433 QVGPaintEngine::QVGPaintEngine() |
1441 QVGPaintEngine::QVGPaintEngine() |
1434 : QPaintEngineEx(*new QVGPaintEnginePrivate) |
1442 : QPaintEngineEx(*new QVGPaintEnginePrivate(this)) |
1435 { |
1443 { |
1436 } |
1444 } |
1437 |
1445 |
1438 QVGPaintEngine::QVGPaintEngine(QVGPaintEnginePrivate &data) |
1446 QVGPaintEngine::QVGPaintEngine(QVGPaintEnginePrivate &data) |
1439 : QPaintEngineEx(data) |
1447 : QPaintEngineEx(data) |
2972 } else { |
2980 } else { |
2973 setImageMode(VG_DRAW_IMAGE_NORMAL); |
2981 setImageMode(VG_DRAW_IMAGE_NORMAL); |
2974 } |
2982 } |
2975 } |
2983 } |
2976 |
2984 |
|
2985 void QVGPaintEnginePrivate::systemStateChanged() |
|
2986 { |
|
2987 q->updateScissor(); |
|
2988 } |
|
2989 |
2977 static void drawVGImage(QVGPaintEnginePrivate *d, |
2990 static void drawVGImage(QVGPaintEnginePrivate *d, |
2978 const QRectF& r, VGImage vgImg, |
2991 const QRectF& r, VGImage vgImg, |
2979 const QSize& imageSize, const QRectF& sr) |
2992 const QSize& imageSize, const QRectF& sr) |
2980 { |
2993 { |
2981 if (vgImg == VG_INVALID_HANDLE) |
2994 if (vgImg == VG_INVALID_HANDLE) |
3430 } |
3443 } |
3431 |
3444 |
3432 // Set the transformation to use for drawing the current glyphs. |
3445 // Set the transformation to use for drawing the current glyphs. |
3433 QTransform glyphTransform(d->pathTransform); |
3446 QTransform glyphTransform(d->pathTransform); |
3434 if (d->transform.type() <= QTransform::TxTranslate) { |
3447 if (d->transform.type() <= QTransform::TxTranslate) { |
3435 // Prevent blurriness of unscaled, unrotated text by using integer coordinates. |
3448 // Prevent blurriness of unscaled, unrotated text by forcing integer coordinates. |
3436 // Using ceil(x-0.5) instead of qRound() or int-cast, behave like other paint engines. |
3449 glyphTransform.translate( |
3437 glyphTransform.translate(ceil(p.x() - 0.5), ceil(p.y() - 0.5)); |
3450 floor(p.x() + glyphTransform.dx() + aliasedCoordinateDelta) - glyphTransform.dx(), |
|
3451 floor(p.y() - glyphTransform.dy() + aliasedCoordinateDelta) + glyphTransform.dy()); |
3438 } else { |
3452 } else { |
3439 glyphTransform.translate(p.x(), p.y()); |
3453 glyphTransform.translate(p.x(), p.y()); |
3440 } |
3454 } |
3441 #if defined(QVG_NO_IMAGE_GLYPHS) |
3455 #if defined(QVG_NO_IMAGE_GLYPHS) |
3442 glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY); |
3456 glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY); |
3594 QPaintEngine::DirtyClipEnabled)) != 0) { |
3608 QPaintEngine::DirtyClipEnabled)) != 0) { |
3595 d->maskValid = false; |
3609 d->maskValid = false; |
3596 d->maskIsSet = false; |
3610 d->maskIsSet = false; |
3597 d->scissorMask = false; |
3611 d->scissorMask = false; |
3598 d->maskRect = QRect(); |
3612 d->maskRect = QRect(); |
|
3613 d->scissorDirty = true; |
3599 clipEnabledChanged(); |
3614 clipEnabledChanged(); |
3600 } |
3615 } |
3601 |
3616 |
3602 #if defined(QVG_SCISSOR_CLIP) |
3617 #if defined(QVG_SCISSOR_CLIP) |
3603 if ((dirty & (QPaintEngine::DirtyClipRegion | |
3618 if ((dirty & (QPaintEngine::DirtyClipRegion | |