diff options
author | Charles Yin <charles.yin@nokia.com> | 2012-06-04 16:34:17 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-05 12:32:58 +0200 |
commit | 1dcfa8aa2ae6460f26d9843c197532024447e43b (patch) | |
tree | 10b5243607d603443a4abe9f89e2a453757ffaeb /src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h | |
parent | 332fe582d1bd590b59618cc7b732be9bf7f9f475 (diff) |
Introduce QQuickCanvasPixmap
1. QQuickPixmap now only store textures instead of QImage data, however
context2d still need to access the QImage in some places, so cache the
loaded images to avoid the expensive GL readback operations.
2. Use texture directly if the render target is FBO.
Change-Id: I6228011e5698fa00f2e3420a3a4a305995b8a238
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h index f33c43a936..ddf5ba14e4 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h @@ -44,8 +44,6 @@ #include <QtCore/qmutex.h> #include "qquickcontext2d_p.h" -#include <QtQuick/private/qquickpixmapcache_p.h> - QT_BEGIN_HEADER @@ -98,11 +96,18 @@ public: bools << repeatX << repeatY; } - inline void drawImage(const QImage& image, qreal sx, qreal sy, qreal sw, qreal sh, qreal dx, qreal dy, qreal dw, qreal dh) + inline void drawImage(const QImage& image, const QRectF& sr, const QRectF& dr) { commands << QQuickContext2D::DrawImage; images << image; - reals << sx << sy << sw << sh << dx << dy << dw << dh; + rects << sr << dr; + } + + inline void drawPixmap(QQmlRefPointer<QQuickCanvasPixmap> pixmap, const QRectF& sr, const QRectF& dr) + { + commands << QQuickContext2D::DrawPixmap; + pixmaps << pixmap; + rects << sr << dr; } inline qreal takeShadowOffsetX() { return takeReal(); } @@ -117,22 +122,22 @@ public: matrixes << matrix; } - inline void clearRect(qreal x, qreal y, qreal w, qreal h) + inline void clearRect(const QRectF& r) { commands << QQuickContext2D::ClearRect; - reals << x << y << w << h; + rects << r; } - inline void fillRect(qreal x, qreal y, qreal w, qreal h) + inline void fillRect(const QRectF& r) { commands << QQuickContext2D::FillRect; - reals << x << y << w << h; + rects << r; } - inline void strokeRect(qreal x, qreal y, qreal w, qreal h) + inline void strokeRect(const QRectF& r) { QPainterPath p; - p.addRect(x, y, w, h); + p.addRect(r); commands << QQuickContext2D::Stroke; pathes << p; @@ -218,19 +223,12 @@ public: inline QTransform takeMatrix() { return matrixes[matrixIdx++]; } - // rects - inline QRectF takeRect() { - qreal x, y, w, h; - x = takeReal(); - y = takeReal(); - w = takeReal(); - h = takeReal(); - return QRectF(x, y, w ,h); - } + inline QRectF takeRect() { return rects[rectIdx++]; } inline QPainterPath takePath() { return pathes[pathIdx++]; } inline const QImage& takeImage() { return images[imageIdx++]; } + inline QQmlRefPointer<QQuickCanvasPixmap> takePixmap() { return pixmaps[pixmapIdx++]; } inline int takeInt() { return ints[intIdx++]; } inline bool takeBool() {return bools[boolIdx++]; } @@ -246,21 +244,25 @@ private: int intIdx; int boolIdx; int realIdx; + int rectIdx; int colorIdx; int matrixIdx; int brushIdx; int pathIdx; int imageIdx; + int pixmapIdx; QVector<QQuickContext2D::PaintCommand> commands; QVector<int> ints; QVector<bool> bools; QVector<qreal> reals; + QVector<QRectF> rects; QVector<QColor> colors; QVector<QTransform> matrixes; QVector<QBrush> brushes; QVector<QPainterPath> pathes; QVector<QImage> images; + QVector<QQmlRefPointer<QQuickCanvasPixmap> > pixmaps; QMutex queueLock; }; |