summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpaintengine_vg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvg/qpaintengine_vg.cpp')
-rw-r--r--src/openvg/qpaintengine_vg.cpp98
1 files changed, 61 insertions, 37 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index da07c1d..94e0793 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3455,28 +3455,24 @@ void QVGCompositionHelper::blitWindow
// Set the image transform.
QTransform transform;
int y = screenSize.height() - (rect.bottom() + 1);
- transform.translate(rect.x() + 0.5f, y + 0.5f);
+ transform.translate(rect.x() - 0.5f, y - 0.5f);
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
// Enable opacity for image drawing if necessary.
- if (opacity < 255) {
- if (opacity != d->paintOpacity) {
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = ((VGfloat)opacity) / 255.0f;
- vgSetParameterfv(d->opacityPaint, VG_PAINT_COLOR, 4, values);
- d->paintOpacity = values[3];
- }
- if (d->fillPaint != d->opacityPaint) {
- vgSetPaint(d->opacityPaint, VG_FILL_PATH);
- d->fillPaint = d->opacityPaint;
- }
- d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
- } else {
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
+ if (opacity != d->paintOpacity) {
+ VGfloat values[4];
+ values[0] = 1.0f;
+ values[1] = 1.0f;
+ values[2] = 1.0f;
+ values[3] = ((VGfloat)opacity) / 255.0f;
+ vgSetParameterfv(d->opacityPaint, VG_PAINT_COLOR, 4, values);
+ d->paintOpacity = values[3];
}
+ if (d->fillPaint != d->opacityPaint) {
+ vgSetPaint(d->opacityPaint, VG_FILL_PATH);
+ d->fillPaint = d->opacityPaint;
+ }
+ d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
// Draw the child image.
vgDrawImage(child);
@@ -3527,27 +3523,55 @@ static void fillBackgroundRect(const QRect& rect, QVGPaintEnginePrivate *d)
void QVGCompositionHelper::fillBackground
(const QRegion& region, const QBrush& brush)
{
- // Set the path transform to the default viewport transformation.
- VGfloat devh = screenSize.height() - 1;
- QTransform viewport(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- 0.5f, devh + 0.5f, 1.0f);
- d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
-
- // Set the brush to use to fill the background.
- d->ensureBrush(brush);
- d->setFillRule(VG_EVEN_ODD);
+ if (brush.style() == Qt::SolidPattern) {
+ // Use vgClear() to quickly fill the background.
+ QColor color = brush.color();
+ if (d->clearColor != color || d->clearOpacity != 1.0f) {
+ VGfloat values[4];
+ values[0] = color.redF();
+ values[1] = color.greenF();
+ values[2] = color.blueF();
+ values[3] = color.alphaF();
+ vgSetfv(VG_CLEAR_COLOR, 4, values);
+ d->clearColor = color;
+ d->clearOpacity = 1.0f;
+ }
+ if (region.numRects() == 1) {
+ QRect r = region.boundingRect();
+ vgClear(r.x(), screenSize.height() - r.y() - r.height(),
+ r.width(), r.height());
+ } else {
+ const QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ QRect r = rects.at(i);
+ vgClear(r.x(), screenSize.height() - r.y() - r.height(),
+ r.width(), r.height());
+ }
+ }
- if (region.numRects() == 1) {
- fillBackgroundRect(region.boundingRect(), d);
} else {
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i)
- fillBackgroundRect(rects.at(i), d);
- }
+ // Set the path transform to the default viewport transformation.
+ VGfloat devh = screenSize.height() - 1;
+ QTransform viewport(1.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ -0.5f, devh + 0.5f, 1.0f);
+ d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
+
+ // Set the brush to use to fill the background.
+ d->ensureBrush(brush);
+ d->setFillRule(VG_EVEN_ODD);
+
+ if (region.numRects() == 1) {
+ fillBackgroundRect(region.boundingRect(), d);
+ } else {
+ const QVector<QRect> rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ fillBackgroundRect(rects.at(i), d);
+ }
- // We will need to reset the path transform during the next paint.
- d->pathTransformSet = false;
+ // We will need to reset the path transform during the next paint.
+ d->pathTransformSet = false;
+ }
}
void QVGCompositionHelper::drawCursorImage
@@ -3584,7 +3608,7 @@ void QVGCompositionHelper::drawCursorPixmap
VGfloat devh = screenSize.height() - 1;
QTransform transform(1.0f, 0.0f, 0.0f,
0.0f, -1.0f, 0.0f,
- 0.5f, devh + 0.5f, 1.0f);
+ -0.5f, devh + 0.5f, 1.0f);
transform.translate(offset.x(), offset.y());
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);