do painting only after component loaded and paint after geometry size initialized
Task-number:QTBUG-21920
Task-number:QTBUG-21918
Change-Id: Ibbc12d416dc694eff35f16c03cbc3c16e333645b
Reviewed-on: http://codereview.qt-project.org/6387
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Charles Yin <charles.yin@nokia.com>
void QSGCanvasItem::componentComplete()
{
Q_D(QSGCanvasItem);
+ QSGItem::componentComplete();
if (!d->context)
createContext();
createTexture();
-
- _doPainting(canvasWindow());
- QSGItem::componentComplete();
-
d->baseUrl = qmlEngine(this)->contextForObject(this)->baseUrl();
+ requestPaint();
+ updatePolish(); //force update the canvas sizes to texture for the first time
d->componentCompleted = true;
- update();
}
void QSGCanvasItem::updatePolish()
{
Q_D(QSGCanvasItem);
d->dirtyRect |= region;
- polish();
+ if (d->componentCompleted)
+ polish();
update();
}
type = QLatin1Literal("PPM");
else if (mime == QLatin1Literal("image/tiff"))
type = QLatin1Literal("TIFF");
- else if (mime == QLatin1Literal("image/xbm"))
- type = QLatin1Literal("XBM");
else if (mime == QLatin1Literal("image/xpm"))
type = QLatin1Literal("XPM");
else
m_dirtyTexture = true;
unlock();
emit textureChanged();
+ if (m_item)
+ emit m_item->painted();
}
bool QSGContext2DTexture::setCanvasSize(const QSize &size)
m_context = item->context();
m_state = m_context->state;
unlock();
- connect(this, SIGNAL(textureChanged()), m_item, SIGNAL(painted()), Qt::QueuedConnection);
- canvasChanged(item->canvasSize().toSize()
- , item->tileSize()
- , item->canvasWindow().toAlignedRect()
- , item->canvasWindow().toAlignedRect()
- , item->smooth());
}
}
id:canvas
Canvas {
id:c
- width:10;height:10
+ width:100;height:100
onPaint: {
context.fillStyle = "red";
- context.fillRect(0, 0, 10, 10);
+ context.fillRect(0, 0, 100, 100);
}
property int paintCount:spyPaint.count
property int paintedCount:spyPainted.count
{mimeType:"image/jpeg"},
{mimeType:"image/x-portable-pixmap"},
{mimeType:"image/tiff"},
- {mimeType:"image/xbm"},
{mimeType:"image/xpm"},
];
}
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, c.width, c.height);
ctx.restore();
-
+ c.requestPaint();
+ wait(100);
var dataUrl2 = c.toDataURL(data.mimeType);
verify (dataUrl2 != "data:,");
verify (dataUrl2 != dataUrl);
c.renderTarget = Canvas.Image;
c.requestPaint();
- wait(200);
+ wait(100);
+ c.toDataURL();
+
compare(c.paintedCount, 1);
compare(c.paintCount, 1);
c.destroy();