summaryrefslogtreecommitdiffstats
path: root/src/opengl/qpaintengine_opengl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qpaintengine_opengl.cpp')
-rw-r--r--src/opengl/qpaintengine_opengl.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index e173a8d..638bfb3 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -768,7 +768,7 @@ public:
bool isFastRect(const QRectF &r);
void drawImageAsPath(const QRectF &r, const QImage &img, const QRectF &sr);
- void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy);
+ void drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy, const QPointF &offset);
void drawOffscreenPath(const QPainterPath &path);
@@ -4222,13 +4222,15 @@ void QOpenGLPaintEnginePrivate::drawImageAsPath(const QRectF &r, const QImage &i
brush_origin = old_brush_origin;
}
-void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy)
+void QOpenGLPaintEnginePrivate::drawTiledImageAsPath(const QRectF &r, const QImage &img, qreal sx, qreal sy,
+ const QPointF &offset)
{
QBrush old_brush = cbrush;
QPointF old_brush_origin = brush_origin;
QTransform brush_matrix = QTransform::fromTranslate(r.left(), r.top());
brush_matrix.scale(sx, sy);
+ brush_matrix.translate(-offset.x(), -offset.y());
cbrush = QBrush(img);
cbrush.setTransform(brush_matrix);
@@ -4305,7 +4307,7 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR
}
}
-void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &)
+void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &offset)
{
Q_D(QOpenGLPaintEngine);
@@ -4315,7 +4317,7 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
int rw = qCeil(r.width());
int rh = qCeil(r.height());
if (rw < pm.width() && rh < pm.height()) {
- drawTiledPixmap(r, pm.copy(0, 0, rw, rh), QPointF());
+ drawTiledPixmap(r, pm.copy(0, 0, rw, rh), offset);
return;
}
@@ -4324,11 +4326,11 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
if (d->composition_mode > QPainter::CompositionMode_Plus || (d->high_quality_antialiasing && !d->isFastRect(r))) {
if (scaled.isNull())
- d->drawTiledImageAsPath(r, pm.toImage(), 1, 1);
+ d->drawTiledImageAsPath(r, pm.toImage(), 1, 1, offset);
else {
const qreal sx = pm.width() / qreal(scaled.width());
const qreal sy = pm.height() / qreal(scaled.height());
- d->drawTiledImageAsPath(r, scaled, sx, sy);
+ d->drawTiledImageAsPath(r, scaled, sx, sy, offset);
}
} else {
d->flushDrawQueue();
@@ -4359,8 +4361,12 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con
q_vertexType vertexArray[4*2];
q_vertexType texCoordArray[4*2];
+ double offset_x = offset.x() / pm.width();
+ double offset_y = offset.y() / pm.height();
+
qt_add_rect_to_array(r, vertexArray);
- qt_add_texcoords_to_array(0, 0, tc_w, tc_h, texCoordArray);
+ qt_add_texcoords_to_array(offset_x, offset_y,
+ tc_w + offset_x, tc_h + offset_y, texCoordArray);
glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray);
glTexCoordPointer(2, q_vertexTypeEnum, 0, texCoordArray);