summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp98
-rw-r--r--src/openvg/qwindowsurface_vg.cpp4
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp59
-rw-r--r--src/openvg/qwindowsurface_vgegl_p.h19
4 files changed, 63 insertions, 117 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);
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
index 661e06a..f8486a6 100644
--- a/src/openvg/qwindowsurface_vg.cpp
+++ b/src/openvg/qwindowsurface_vg.cpp
@@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE
QVGWindowSurface::QVGWindowSurface(QWidget *window)
: QWindowSurface(window)
{
- d_ptr = QVGEGLWindowSurfacePrivate::create
- (QVGEGLWindowSurfacePrivate::WindowSurface, this);
+ // Create the default type of EGL window surface for windows.
+ d_ptr = new QVGEGLWindowSurfaceDirect(this);
}
QVGWindowSurface::QVGWindowSurface
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
index d622c1f..103f84d 100644
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ b/src/openvg/qwindowsurface_vgegl.cpp
@@ -101,18 +101,6 @@ QImage::Format qt_vg_config_to_image_format(QEglContext *context)
return argbFormat; // XXX
}
-static void copySubImage(QImage *image, VGImage vgImage, const QRect& rect)
-{
- vgGetImageSubData
- (vgImage,
- image->bits() + rect.bottom() * image->bytesPerLine() +
- rect.x() * (image->depth() / 8),
- -(image->bytesPerLine()),
- qt_vg_image_to_vg_format(image->format()),
- rect.x(), (image->height() - 1) - rect.bottom(),
- rect.width(), rect.height());
-}
-
#if !defined(QVG_NO_SINGLE_CONTEXT)
class QVGSharedContext
@@ -336,20 +324,6 @@ QVGEGLWindowSurfacePrivate::~QVGEGLWindowSurfacePrivate()
destroyPaintEngine();
}
-QVGEGLWindowSurfacePrivate *QVGEGLWindowSurfacePrivate::create
- (SurfaceType type, QWindowSurface *win)
-{
-#if defined(QVG_VGIMAGE_BACKBUFFERS)
- if (type == VGImageSurface)
- return new QVGEGLWindowSurfaceVGImage(win);
- else if (type == QImageSurface)
- return new QVGEGLWindowSurfaceQImage(win);
-#endif
- if (type == WindowSurface)
- return new QVGEGLWindowSurfaceDirect(win);
- return 0;
-}
-
QVGPaintEngine *QVGEGLWindowSurfacePrivate::paintEngine()
{
if (!engine)
@@ -514,39 +488,6 @@ EGLSurface QVGEGLWindowSurfaceVGImage::mainSurface() const
return qt_vg_shared_surface();
}
-QVGEGLWindowSurfaceQImage::QVGEGLWindowSurfaceQImage(QWindowSurface *win)
- : QVGEGLWindowSurfaceVGImage(win)
-{
-}
-
-QVGEGLWindowSurfaceQImage::~QVGEGLWindowSurfaceQImage()
-{
-}
-
-void QVGEGLWindowSurfaceQImage::endPaint
- (QWidget *widget, const QRegion& region, QImage *image)
-{
- QEglContext *context = ensureContext(widget);
- if (context) {
- if (backBufferSurface != EGL_NO_SURFACE) {
- if (isPaintingActive)
- vgFlush();
- context->makeCurrent(mainSurface());
- QRegion rgn = region.intersected
- (QRect(0, 0, image->width(), image->height()));
- if (rgn.numRects() == 1) {
- copySubImage(image, backBuffer, rgn.boundingRect());
- } else {
- QVector<QRect> rects = rgn.rects();
- for (int index = 0; index < rects.size(); ++index)
- copySubImage(image, backBuffer, rects[index]);
- }
- context->lazyDoneCurrent();
- }
- isPaintingActive = false;
- }
-}
-
#endif // QVG_VGIMAGE_BACKBUFFERS
QVGEGLWindowSurfaceDirect::QVGEGLWindowSurfaceDirect(QWindowSurface *win)
diff --git a/src/openvg/qwindowsurface_vgegl_p.h b/src/openvg/qwindowsurface_vgegl_p.h
index fa36b94..7fa60ea 100644
--- a/src/openvg/qwindowsurface_vgegl_p.h
+++ b/src/openvg/qwindowsurface_vgegl_p.h
@@ -70,16 +70,6 @@ public:
QVGEGLWindowSurfacePrivate(QWindowSurface *win);
virtual ~QVGEGLWindowSurfacePrivate();
- enum SurfaceType
- {
- WindowSurface,
- VGImageSurface,
- QImageSurface
- };
-
- static QVGEGLWindowSurfacePrivate *create
- (SurfaceType type, QWindowSurface *win);
-
QVGPaintEngine *paintEngine();
virtual QEglContext *ensureContext(QWidget *widget) = 0;
virtual void beginPaint(QWidget *widget) = 0;
@@ -126,15 +116,6 @@ protected:
EGLSurface mainSurface() const;
};
-class Q_OPENVG_EXPORT QVGEGLWindowSurfaceQImage : public QVGEGLWindowSurfaceVGImage
-{
-public:
- QVGEGLWindowSurfaceQImage(QWindowSurface *win);
- virtual ~QVGEGLWindowSurfaceQImage();
-
- void endPaint(QWidget *widget, const QRegion& region, QImage *image);
-};
-
#endif // EGL_OPENVG_IMAGE
class Q_OPENVG_EXPORT QVGEGLWindowSurfaceDirect : public QVGEGLWindowSurfacePrivate