aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-05-02 07:23:24 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-05-02 07:23:24 +0200
commit280242a5a14a99cc10857e35da61ac5b894d5f6b (patch)
treefcb25e58ad391b288c55ec9298259bd5bf8f4e8b
parent3f872cd6899fe53ed2549f7d2d9b0c902721f667 (diff)
parent155faa3b8b1e04241bd53df3eb008d54a71cc667 (diff)
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
-rw-r--r--src/declarative/items/qsgimage.cpp4
-rw-r--r--src/declarative/items/qsgninepatchnode.cpp14
-rw-r--r--src/declarative/items/qsgshadereffectitem.cpp2
-rw-r--r--src/declarative/items/qsgshadereffectmesh.cpp2
-rw-r--r--src/declarative/items/qsgshadereffectsource.cpp12
-rw-r--r--src/declarative/items/qsgshadereffectsource_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp3
-rw-r--r--src/declarative/scenegraph/qsgdefaultimagenode.cpp1
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp32
-rw-r--r--src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h5
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.cpp9
-rw-r--r--src/declarative/scenegraph/util/qsgtexture.h3
-rw-r--r--src/declarative/scenegraph/util/qsgtexture_p.h1
-rw-r--r--src/declarative/scenegraph/util/qsgtextureprovider_p.h2
14 files changed, 40 insertions, 57 deletions
diff --git a/src/declarative/items/qsgimage.cpp b/src/declarative/items/qsgimage.cpp
index 6f63555b81..d24db9f670 100644
--- a/src/declarative/items/qsgimage.cpp
+++ b/src/declarative/items/qsgimage.cpp
@@ -262,9 +262,9 @@ QSGNode *QSGImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
};
QRectF nsrect(sourceRect.x() / d->pix.width(),
- 1 - sourceRect.y() / d->pix.height(),
+ sourceRect.y() / d->pix.height(),
sourceRect.width() / d->pix.width(),
- -sourceRect.height() / d->pix.height());
+ sourceRect.height() / d->pix.height());
node->setHorizontalWrapMode(hWrap);
node->setVerticalWrapMode(vWrap);
diff --git a/src/declarative/items/qsgninepatchnode.cpp b/src/declarative/items/qsgninepatchnode.cpp
index 7858e98190..045dd6c94f 100644
--- a/src/declarative/items/qsgninepatchnode.cpp
+++ b/src/declarative/items/qsgninepatchnode.cpp
@@ -147,7 +147,8 @@ void QSGNinePatchNode::update()
xChunkSize = xTexSize;
} else if (m_horizontalTileMode == QSGBorderImage::Round) {
xChunkCount = qCeil(xSize / xTexSize);
- xChunkSize = xSize / xChunkCount;
+ qreal fullWidth = xChunkCount * xTexSize;
+ xChunkSize = xTexSize * xSize / fullWidth;
} else {
xChunkCount = 1;
xChunkSize = xSize;
@@ -163,7 +164,8 @@ void QSGNinePatchNode::update()
yChunkSize = yTexSize;
} else if (m_verticalTileMode == QSGBorderImage::Round) {
yChunkCount = qCeil(ySize / yTexSize);
- yChunkSize = ySize / yChunkCount;
+ qreal fullHeight = yChunkCount * yTexSize;
+ yChunkSize = yTexSize * ySize / fullHeight;
} else {
yChunkCount = 1;
yChunkSize = ySize;
@@ -184,10 +186,10 @@ void QSGNinePatchNode::update()
// Fill in the vertices.. The loop below is pretty much an exact replica
// of the one inside fillRow.
- float yTexChunk1 = 1 - m_innerRect.top() / th;
- float yTexChunk2 = 1 - m_innerRect.bottom() / th;
+ float yTexChunk1 = m_innerRect.top() / th;
+ float yTexChunk2 = m_innerRect.bottom() / th;
- fillRow(v, 0, 1, xChunkCount, xChunkSize);
+ fillRow(v, 0, 0, xChunkCount, xChunkSize);
fillRow(v, m_innerRect.y(), yTexChunk1, xChunkCount, xChunkSize);
for (int yc=0; yc<yChunkCount; ++yc) {
@@ -206,7 +208,7 @@ void QSGNinePatchNode::update()
}
fillRow(v, m_targetRect.height() - bottomBorder, yTexChunk2, xChunkCount, xChunkSize);
- fillRow(v, m_targetRect.height(), 0, xChunkCount, xChunkSize);
+ fillRow(v, m_targetRect.height(), 1, xChunkCount, xChunkSize);
// v = m_geometry.vertexDataAsTexturedPoint2D();
diff --git a/src/declarative/items/qsgshadereffectitem.cpp b/src/declarative/items/qsgshadereffectitem.cpp
index 286b67bacd..40ec25c2cc 100644
--- a/src/declarative/items/qsgshadereffectitem.cpp
+++ b/src/declarative/items/qsgshadereffectitem.cpp
@@ -435,7 +435,7 @@ QSGNode *QSGShaderEffectItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeD
textures.append(qMakePair(source.name, source.item));
QSGTextureProvider *t = QSGTextureProvider::from(source.item);
if (t && t->textureChangedSignal())
- connect(source.item, t->textureChangedSignal(), node, SLOT(markDirtyTexture()));
+ connect(source.item, t->textureChangedSignal(), node, SLOT(markDirtyTexture()), Qt::DirectConnection);
}
m_material.setUniforms(values);
m_material.setTextureProviders(textures);
diff --git a/src/declarative/items/qsgshadereffectmesh.cpp b/src/declarative/items/qsgshadereffectmesh.cpp
index 09d820706b..192e95c164 100644
--- a/src/declarative/items/qsgshadereffectmesh.cpp
+++ b/src/declarative/items/qsgshadereffectmesh.cpp
@@ -112,7 +112,7 @@ QSGGeometry *QSGGridMesh::updateGeometry(QSGGeometry *geometry, const QVector<QB
bool positionFirst = attributes.at(0) == qtPositionAttributeName();
- QRectF srcRect(0, 1, 1, -1);
+ QRectF srcRect(0, 0, 1, 1);
for (int iy = 0; iy <= vmesh; ++iy) {
float fy = iy / float(vmesh);
float y = float(dstRect.top()) + fy * float(dstRect.height());
diff --git a/src/declarative/items/qsgshadereffectsource.cpp b/src/declarative/items/qsgshadereffectsource.cpp
index 36d380b15f..e5b79a6d78 100644
--- a/src/declarative/items/qsgshadereffectsource.cpp
+++ b/src/declarative/items/qsgshadereffectsource.cpp
@@ -192,7 +192,7 @@ void QSGShaderEffectTexture::grab()
if (!m_renderer) {
m_renderer = context->createRenderer();
- connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()));
+ connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture()), Qt::DirectConnection);
}
m_renderer->setRootNode(static_cast<QSGRootNode *>(root));
@@ -255,7 +255,8 @@ void QSGShaderEffectTexture::grab()
const QGLContext *ctx = QGLContext::currentContext();
m_renderer->setDeviceRect(m_size);
m_renderer->setViewportRect(m_size);
- m_renderer->setProjectMatrixToRect(m_rect);
+ QRectF mirrored(m_rect.left(), m_rect.bottom(), m_rect.width(), -m_rect.height());
+ m_renderer->setProjectMatrixToRect(mirrored);
m_renderer->setClearColor(Qt::transparent);
if (m_multisampling) {
@@ -292,6 +293,7 @@ QSGShaderEffectSource::QSGShaderEffectSource(QSGItem *parent)
{
setFlag(ItemHasContents);
m_texture = new QSGShaderEffectTexture(this);
+ connect(m_texture, SIGNAL(textureChanged()), this, SIGNAL(textureChanged()), Qt::DirectConnection);
}
QSGShaderEffectSource::~QSGShaderEffectSource()
@@ -492,12 +494,12 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
QSGShaderEffectTexture *tex = qobject_cast<QSGShaderEffectTexture *>(m_texture);
tex->setItem(QSGItemPrivate::get(m_sourceItem)->itemNode());
- QRectF sourceRect = m_sourceRect.isEmpty()
+ QRectF sourceRect = m_sourceRect.isNull()
? QRectF(0, 0, m_sourceItem->width(), m_sourceItem->height())
: m_sourceRect;
tex->setRect(sourceRect);
QSize textureSize = m_textureSize.isEmpty()
- ? QSize(qCeil(sourceRect.width()), qCeil(sourceRect.height()))
+ ? QSize(qCeil(qAbs(sourceRect.width())), qCeil(qAbs(sourceRect.height())))
: m_textureSize;
tex->setSize(textureSize);
tex->setLive(m_live);
@@ -517,7 +519,7 @@ QSGNode *QSGShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNod
node->setHorizontalWrapMode(hWrap);
node->setVerticalWrapMode(vWrap);
node->setTargetRect(QRectF(0, 0, width(), height()));
- node->setSourceRect(QRectF(0, 1, 1, -1));
+ node->setSourceRect(QRectF(0, 0, 1, 1));
node->update();
return node;
diff --git a/src/declarative/items/qsgshadereffectsource_p.h b/src/declarative/items/qsgshadereffectsource_p.h
index d8c4a18df1..1b6e1b5fe8 100644
--- a/src/declarative/items/qsgshadereffectsource_p.h
+++ b/src/declarative/items/qsgshadereffectsource_p.h
@@ -99,6 +99,9 @@ public:
void grab();
+Q_SIGNALS:
+ void textureChanged();
+
public Q_SLOTS:
void markDirtyTexture();
@@ -183,7 +186,7 @@ public:
void setMipmap(bool enabled);
QSGTexture *texture() const;
- const char *textureChangedSignal() const { return SIGNAL(textureChanged); }
+ const char *textureChangedSignal() const { return SIGNAL(textureChanged()); }
Q_INVOKABLE void grab();
@@ -197,6 +200,8 @@ Q_SIGNALS:
void hideSourceChanged();
void mipmapChanged();
+ void textureChanged();
+
protected:
virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index b30b4cfb55..ba0ddbbfaf 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1738,9 +1738,6 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine
qsreal w = ctxt->argument(2).toNumber();
qsreal h = ctxt->argument(3).toNumber();
- if (w < 0 || h < 0)
- return engine->nullValue();
-
return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QRectF(x, y, w, h)));
}
diff --git a/src/declarative/scenegraph/qsgdefaultimagenode.cpp b/src/declarative/scenegraph/qsgdefaultimagenode.cpp
index a705e822c3..aa30d009da 100644
--- a/src/declarative/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/declarative/scenegraph/qsgdefaultimagenode.cpp
@@ -97,7 +97,6 @@ void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
markDirty(DirtyMaterial);
}
-
void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
{
if (m_material.verticalWrapMode() == wrapMode)
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
index c40df75084..5801311be4 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache.cpp
@@ -531,26 +531,14 @@ static bool fontHasNarrowOutlines(const QRawFont &f)
DEFINE_BOOL_CONFIG_OPTION(disableDistanceField, QML_DISABLE_DISTANCEFIELD)
-QHash<QString, QSGDistanceFieldGlyphCache *> QSGDistanceFieldGlyphCache::m_caches;
-QHash<QString, QGLContextGroupResource<QSGDistanceFieldGlyphCache::DistanceFieldTextureData> > QSGDistanceFieldGlyphCache::m_textures_data;
-
-static QString fontKey(const QRawFont &font)
-{
- QString key;
-
- key = font.familyName();
- key.remove(QLatin1String(" "));
- QString italic = font.style() == QFont::StyleItalic ? QLatin1String("i") : QLatin1String("");
- QString bold = font.weight() > QFont::Normal ? QLatin1String("b") : QLatin1String("");
- key += bold + italic + QString::number(qreal(font.pixelSize()));
-
- return key;
-}
+QHash<QPair<const QGLContext *, QFontEngine *>, QSGDistanceFieldGlyphCache *> QSGDistanceFieldGlyphCache::m_caches;
+QHash<QFontEngine *, QGLContextGroupResource<QSGDistanceFieldGlyphCache::DistanceFieldTextureData> > QSGDistanceFieldGlyphCache::m_textures_data;
QSGDistanceFieldGlyphCache *QSGDistanceFieldGlyphCache::get(const QGLContext *ctx, const QRawFont &font)
{
- QString key = QString::number(long(ctx), 16) + fontKey(font);
- QHash<QString, QSGDistanceFieldGlyphCache *>::iterator atlas = m_caches.find(key);
+ QRawFontPrivate *fontD = QRawFontPrivate::get(font);
+ QPair<const QGLContext *, QFontEngine *> key(ctx, fontD->fontEngine);
+ QHash<QPair<const QGLContext *, QFontEngine *>, QSGDistanceFieldGlyphCache *>::iterator atlas = m_caches.find(key);
if (atlas == m_caches.end())
atlas = m_caches.insert(key, new QSGDistanceFieldGlyphCache(ctx, font));
@@ -559,7 +547,7 @@ QSGDistanceFieldGlyphCache *QSGDistanceFieldGlyphCache::get(const QGLContext *ct
QSGDistanceFieldGlyphCache::DistanceFieldTextureData *QSGDistanceFieldGlyphCache::textureData()
{
- return m_textures_data[m_distanceFieldKey].value(ctx);
+ return m_textures_data[QRawFontPrivate::get(m_font)->fontEngine].value(ctx);
}
QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(const QGLContext *c, const QRawFont &font)
@@ -571,11 +559,6 @@ QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(const QGLContext *c, cons
Q_ASSERT(font.isValid());
m_font = font;
- QString basename = m_font.familyName();
- basename.remove(QLatin1String(" "));
- QString italic = m_font.style() == QFont::StyleItalic ? QLatin1String("i") : QLatin1String("");
- QString bold = m_font.weight() > QFont::Normal ? QLatin1String("b") : QLatin1String("");
- m_distanceFieldKey = basename + bold + italic;
m_textureData = textureData();
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
@@ -619,7 +602,8 @@ void QSGDistanceFieldGlyphCache::onContextDestroyed(const QGLContext *context)
if (context != ctx)
return;
- QString key = QString::number(long(context), 16) + fontKey(m_font);
+ QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
+ QPair<const QGLContext *, QFontEngine *> key(context, fontD->fontEngine);
m_caches.remove(key);
deleteLater();
}
diff --git a/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h b/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
index 60e5b5921a..5ee439552a 100644
--- a/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
+++ b/src/declarative/scenegraph/qsgdistancefieldglyphcache_p.h
@@ -112,12 +112,11 @@ private:
void createTexture(int width, int height);
void resizeTexture(int width, int height);
- static QHash<QString, QSGDistanceFieldGlyphCache *> m_caches;
+ static QHash<QPair<const QGLContext *, QFontEngine *>, QSGDistanceFieldGlyphCache *> m_caches;
QRawFont m_font;
QRawFont m_referenceFont;
- QString m_distanceFieldKey;
int m_glyphCount;
QHash<glyph_t, Metrics> m_metrics;
mutable int m_maxTextureSize;
@@ -145,7 +144,7 @@ private:
};
DistanceFieldTextureData *textureData();
DistanceFieldTextureData *m_textureData;
- static QHash<QString, QGLContextGroupResource<DistanceFieldTextureData> > m_textures_data;
+ static QHash<QFontEngine *, QGLContextGroupResource<DistanceFieldTextureData> > m_textures_data;
const QGLContext *ctx;
QGLShaderProgram *m_blitProgram;
diff --git a/src/declarative/scenegraph/util/qsgtexture.cpp b/src/declarative/scenegraph/util/qsgtexture.cpp
index 6112e777e4..9362ba8bf6 100644
--- a/src/declarative/scenegraph/util/qsgtexture.cpp
+++ b/src/declarative/scenegraph/util/qsgtexture.cpp
@@ -356,13 +356,9 @@ void QSGPlainTexture::bind()
int h = m_image.height();
#ifdef QT_OPENGL_ES
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- for (int i = 0; i < m_image.height(); ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, w, 1, GL_RGBA, GL_UNSIGNED_BYTE, m_image.constScanLine(h - 1 - i));
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_image.constBits());
#else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0);
- for (int i = 0; i < m_image.height(); ++i)
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, w, 1, GL_BGRA, GL_UNSIGNED_BYTE, m_image.constScanLine(h - 1 - i));
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, m_image.constBits());
#endif
if (m_has_mipmaps) {
@@ -372,6 +368,7 @@ void QSGPlainTexture::bind()
}
m_texture_size = QSize(w, h);
+ m_texture_rect = QRectF(0, 0, 1, 1);
updateBindOptions(m_dirty_bind_options);
m_dirty_bind_options = false;
diff --git a/src/declarative/scenegraph/util/qsgtexture.h b/src/declarative/scenegraph/util/qsgtexture.h
index 807dbecae5..9b95ef36ad 100644
--- a/src/declarative/scenegraph/util/qsgtexture.h
+++ b/src/declarative/scenegraph/util/qsgtexture.h
@@ -123,9 +123,6 @@ class QSGDynamicTexture : public QSGTexture
Q_OBJECT
public:
virtual bool updateTexture() = 0;
-
-Q_SIGNALS:
- void textureChanged();
};
QT_END_NAMESPACE
diff --git a/src/declarative/scenegraph/util/qsgtexture_p.h b/src/declarative/scenegraph/util/qsgtexture_p.h
index 8ea0930235..2c142f5746 100644
--- a/src/declarative/scenegraph/util/qsgtexture_p.h
+++ b/src/declarative/scenegraph/util/qsgtexture_p.h
@@ -97,6 +97,7 @@ protected:
GLuint m_texture_id;
QSize m_texture_size;
+ QRectF m_texture_rect;
uint m_has_alpha : 1;
uint m_has_mipmaps : 1;
diff --git a/src/declarative/scenegraph/util/qsgtextureprovider_p.h b/src/declarative/scenegraph/util/qsgtextureprovider_p.h
index 1e0e9f6c68..486e7d5882 100644
--- a/src/declarative/scenegraph/util/qsgtextureprovider_p.h
+++ b/src/declarative/scenegraph/util/qsgtextureprovider_p.h
@@ -57,7 +57,7 @@ class QSGTextureProvider
{
public:
virtual QSGTexture *texture() const = 0;
- virtual const char *textureChangedSignal() { return 0; }
+ virtual const char *textureChangedSignal() const { return 0; }
static QSGTextureProvider *from(QObject *object);
};