d->baseUrl = qmlEngine(this)->contextForObject(this)->baseUrl();
requestPaint();
updatePolish(); //force update the canvas sizes to texture for the first time
+ update();
d->componentCompleted = true;
}
node = new QSGContext2DNode(this);
node->setTexture(d->texture);
+ node->setSize(d->canvasWindow.size());
node->update();
return node;
}
, m_item(item)
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
, m_texture(0)
+ , m_size(1, 1)
, m_dirtyGeometry(false)
, m_dirtyTexture(false)
{
{
}
+void QSGContext2DNode::setSize(const QSizeF& size)
+{
+ if (m_size != size) {
+ m_dirtyGeometry = true;
+ m_size = size;
+ }
+}
+
void QSGContext2DNode::preprocess()
{
bool doDirty = false;
QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(m_material.texture());
if (t) {
doDirty = t->updateTexture();
- updateGeometry();
}
if (doDirty) {
m_dirtyTexture = true;
void QSGContext2DNode::updateGeometry()
{
- QSizeF size = m_item->canvasWindow().size();
QRectF source = m_texture->textureSubRect();
QSGGeometry::updateTexturedRectGeometry(&m_geometry,
- QRectF(0, 0, size.width(), size.height()),
+ QRectF(0, 0, m_size.width(), m_size.height()),
source);
markDirty(DirtyGeometry);
}
void setTexture(QSGContext2DTexture* texture);
void update();
void preprocess();
+ void setSize(const QSizeF& size);
private:
void updateTexture();
void updateGeometry();
QSGTextureMaterial m_materialO;
QSGGeometry m_geometry;
QSGContext2DTexture* m_texture;
+ QSizeF m_size;
bool m_dirtyGeometry;
bool m_dirtyTexture;
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()));
}
}
m_threadRendering = false;
}
+QSGContext2DFBOTexture::~QSGContext2DFBOTexture()
+{
+ delete m_fbo;
+ delete m_multisampledFbo;
+ delete m_paint_device;
+}
+
bool QSGContext2DFBOTexture::setCanvasSize(const QSize &size)
{
QSize s = QSize(qMax(QT_MINIMUM_FBO_SIZE, qt_next_power_of_two(size.width()))
QRectF QSGContext2DFBOTexture::textureSubRect() const
{
return QRectF(0
- , 1
+ , 0
, qreal(m_canvasWindow.width()) / m_fboSize.width()
- , qreal(-m_canvasWindow.height()) / m_fboSize.height());
+ , qreal(m_canvasWindow.height()) / m_fboSize.height());
}
delete m_multisampledFbo;
m_fbo = 0;
m_multisampledFbo = 0;
+ return 0;
} else if (!m_fbo || m_fbo->size() != m_fboSize) {
delete m_fbo;
delete m_multisampledFbo;
format.setAttachment(QOpenGLFramebufferObject::NoAttachment);
m_fbo = new QOpenGLFramebufferObject(m_fboSize, format);
}
- m_multisampledFbo->bind();
} else {
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
- delete m_fbo;
m_fbo = new QOpenGLFramebufferObject(m_fboSize, format);
- m_fbo->bind();
}
}
+ if (doMultisampling())
+ m_multisampledFbo->bind();
+ else
+ m_fbo->bind();
+
if (!m_paint_device) {
QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size());
+ gl_device->setPaintFlipped(true);
m_paint_device = gl_device;
}
public:
QSGContext2DFBOTexture();
+ ~QSGContext2DFBOTexture();
virtual int textureId() const;
virtual bool updateTexture();
virtual QSGContext2DTile* createTile() const;
verify(c);
c.renderTarget = Canvas.Image;
-
- c.requestPaint();
- wait(100);
+ c.renderInThread = true;
+ var ctx = c.getContext();
+ ctx.fillRect(0, 0, c.width, c.height);
c.toDataURL();
+ wait(100);
compare(c.paintedCount, 1);
compare(c.paintCount, 1);