summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-12-01 19:28:51 +0100
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-12-01 19:28:51 +0100
commit1c8d3423741ce9f9b7a1a193c8bab89c018b54ee (patch)
treec1a6e51de96b652450ccad2841c7b4fcda7c01b9
parentcbe801b88ab794db7ba792a1f23767bfba70e49a (diff)
started work on new texture manager
-rw-r--r--TODO33
-rw-r--r--src/adaptationlayers/adaptationinterfaces.cpp (renamed from src/adaptationlayers/default/default_pixmapnode.h)54
-rw-r--r--src/adaptationlayers/adaptationinterfaces.h97
-rw-r--r--src/adaptationlayers/adaptationlayers.pri9
-rw-r--r--src/adaptationlayers/default/default_adaptationlayer.cpp19
-rw-r--r--src/adaptationlayers/default/default_adaptationlayer.h12
-rw-r--r--src/adaptationlayers/default/default_glyphnode_p.cpp9
-rw-r--r--src/adaptationlayers/default/default_glyphnode_p.h4
-rw-r--r--src/adaptationlayers/default/default_pixmapnode.cpp277
-rw-r--r--src/adaptationlayers/default/default_rectanglenode.cpp31
-rw-r--r--src/adaptationlayers/default/default_rectanglenode.h2
-rw-r--r--src/adaptationlayers/default/default_textureatlas.h1
-rw-r--r--src/effects/shadereffectitem.cpp60
-rw-r--r--src/effects/shadereffectitem.h2
-rw-r--r--src/graphicsitems/graphicsitems.pri7
-rw-r--r--src/graphicsitems/nodes/qxninepatchnode.cpp23
-rw-r--r--src/graphicsitems/nodes/qxninepatchnode_p.h7
-rw-r--r--src/graphicsitems/nodes/qxpainternode.cpp16
-rw-r--r--src/graphicsitems/qxborderimage.cpp10
-rw-r--r--src/graphicsitems/qxborderimage_p_p.h3
-rw-r--r--src/graphicsitems/qximage.cpp12
-rw-r--r--src/graphicsitems/qximage_p_p.h3
-rw-r--r--src/graphicsitems/qximagebase_p_p.h3
-rw-r--r--src/graphicsitems/qxpainteditem_p_p.h2
-rw-r--r--src/graphicsitems/qxparticles.cpp2
-rw-r--r--src/qmlscene_global.cpp27
-rw-r--r--src/scenegraph/3d/qgltextureutils.cpp2
-rw-r--r--src/scenegraph/convenience/pixmapnode.h1
-rw-r--r--src/scenegraph/convenience/textnode.cpp6
-rw-r--r--src/scenegraph/convenience/texturematerial.cpp9
-rw-r--r--src/scenegraph/convenience/texturematerial.h10
-rw-r--r--src/scenegraph/convenience/utilities.cpp260
-rw-r--r--src/scenegraph/convenience/utilities.h40
-rw-r--r--src/scenegraph/coreapi/renderer.cpp10
-rw-r--r--src/scenegraph/coreapi/renderer.h5
-rw-r--r--src/scenegraph/scenegraph.pri10
36 files changed, 457 insertions, 621 deletions
diff --git a/TODO b/TODO
index e071642..60bf747 100644
--- a/TODO
+++ b/TODO
@@ -3,3 +3,36 @@
-tiling modes in borderimage
-anywhere there is a XXX
-there have been numerous fixes in qt-qml (+ some API changes) that need to be integrated
+
+- Remove the unused nodes in src/scenegraph/convenience, like SolidRectnode...
+- Move QxParticles into its own plugin as it is not part of the QML core API
+- Remove QxPaintedItem and friends from sourcertree..
+
+- New directory structure perhaps?
+ declarative/
+ canvas/
+ view
+ animation driver
+ items/
+ all the qxitems
+ scenegraph/
+ coreapi/
+ node
+ material
+ renderer
+
+ materials/
+ TextureMaterial
+ FlatColorMaterial
+ VertexColorMaterial
+
+ nodes/
+ VertexColorRectNode
+ TextureColorRectNode
+
+ qmladaptation/
+ adaptation interfaces
+ default implementations
+ qmlrenderer
+
+
diff --git a/src/adaptationlayers/default/default_pixmapnode.h b/src/adaptationlayers/adaptationinterfaces.cpp
index 7c4dadc..024bc3c 100644
--- a/src/adaptationlayers/default/default_pixmapnode.h
+++ b/src/adaptationlayers/adaptationinterfaces.cpp
@@ -39,43 +39,31 @@
**
****************************************************************************/
-
-#ifndef DEFAULT_PIXMAPNODE_H
-#define DEFAULT_PIXMAPNODE_H
-
#include "adaptationinterfaces.h"
-#include "texturematerial.h"
-#include "utilities.h"
-#include <QtGui/QPixmap>
-
-class DefaultPixmapNode : public PixmapNodeInterface
+/*!
+ Constructs a new texture reference with status set to Null
+ */
+TextureReference::TextureReference()
+ : m_status(Null)
+ , m_texture_id(0)
+ , m_has_alpha(false)
{
-public:
- DefaultPixmapNode();
- virtual void setRect(const QRectF &rect);
- virtual void setSourceRect(const QRectF &rect);
- virtual void setOpacity(qreal opacity);
- virtual void setPixmap(const QPixmap &pixmap, bool dynamic);
- virtual void setClampToEdge(bool clampToEdge);
- virtual void setLinearFiltering(bool linearFiltering);
- virtual void update(uint updateFlags);
-private:
- enum UpdateFlag
- {
- UpdateTexture = 0x01,
- UpdateGeometry = 0x02
- };
+}
- void updateGeometry();
- void updateTexture();
- QPixmap m_pixmap;
- bool m_dynamic;
- TextureMaterial m_material;
- TextureMaterialWithOpacity m_materialO;
- SubTexture2DPtr m_texture;
-};
+/*!
+ Constructs a new texture reference with texture set to
+ \a textureId and status set to Ready. \a textureRect specifies which
+ part of the texture to source from. \a hasAlpha indicates wether the
+ texture contains an alpha channel or not.
+ */
+TextureReference::TextureReference(int textureId, const QRectF &textureRect, bool hasAlpha)
+ : m_status(Ready)
+ , m_texture_id(textureId)
+ , m_texture_rect(textureRect)
+ , m_has_alpha(hasAlpha)
+{
+}
-#endif
diff --git a/src/adaptationlayers/adaptationinterfaces.h b/src/adaptationlayers/adaptationinterfaces.h
index 4b15647..b5fa295 100644
--- a/src/adaptationlayers/adaptationinterfaces.h
+++ b/src/adaptationlayers/adaptationinterfaces.h
@@ -52,9 +52,8 @@
#include "node.h"
class Node;
-class QPixmap;
-class QGLTexture2D;
class QImage;
+class TextureReference;
// TODO: Rename from XInterface to AbstractX.
@@ -83,6 +82,7 @@ public:
virtual void setRadius(qreal radius) = 0;
qreal radius() const { return m_radius; }
+
protected:
QRectF m_rect;
QGradientStops m_gradient_stops;
@@ -93,10 +93,10 @@ protected:
int m_pen_width;
};
-class PixmapNodeInterface : public GeometryNode
+class TextureNodeInterface : public GeometryNode
{
public:
- PixmapNodeInterface() : m_opacity(1), m_clamp_to_edge(true), m_linear_filtering(false) { }
+ TextureNodeInterface() : m_texture(0), m_opacity(1), m_clamp_to_edge(true), m_linear_filtering(false) { }
virtual void setRect(const QRectF &rect) = 0;
QRectF rect() const { return m_rect; }
@@ -107,45 +107,98 @@ public:
virtual void setOpacity(qreal opacity) = 0;
qreal opacity() const { return m_opacity; }
- virtual void setPixmap(const QPixmap &pixmap, bool dynamic) = 0;
- void setPixmap(const QPixmap &pixmap) { setPixmap(pixmap, true); }
+ virtual void setTexture(TextureReference *ref) = 0;
+ TextureReference *texture() const;
virtual void setClampToEdge(bool clampToEdge) = 0;
bool clampToEdge() const { return m_clamp_to_edge; }
virtual void setLinearFiltering(bool linearFiltering) = 0;
bool linearFiltering() const { return m_linear_filtering; }
+
protected:
+ TextureReference *m_texture;
QRectF m_rect;
QRectF m_source_rect;
qreal m_opacity;
bool m_clamp_to_edge;
bool m_linear_filtering;
-};
-typedef QSharedPointer<const QGLTexture2D> QGLTexture2DConstPtr;
-typedef QSharedPointer<QGLTexture2D> QGLTexture2DPtr;
+};
-class TextureAtlasInterface
+class TextureReference : public QObject
{
+ Q_OBJECT
public:
- enum Flag
- {
- DynamicFlag = 0x01 // Set if images are added to the texture atlas every few frames.
+ enum Status {
+ Null,
+ Ready,
+ Loading,
+ Error
};
- TextureAtlasInterface(uint flags) : m_flags(flags) { }
- virtual ~TextureAtlasInterface() { }
+ TextureReference();
+ TextureReference(int id, const QRectF &rect, bool hasAlpha);
+
+ virtual int textureId() const { return m_texture_id; }
+ virtual QRectF textureRect() const { return m_texture_rect; }
+
+ bool hasAlphaChannel() const { return m_has_alpha; }
- virtual QGLTexture2DConstPtr texture() = 0;
- virtual QRect allocate(const QImage &image, bool clampToEdge) = 0;
- virtual void deallocate(const QRect &rect) = 0;
+ Status status() const { return m_status; }
+
+signals:
+ void statusChanged(Status status);
- uint flags() const { return m_flags; }
protected:
- uint m_flags;
+ Status m_status;
+ int m_texture_id;
+ QRectF m_texture_rect;
+
+ uint m_has_alpha : 1;
};
+class TextureManager
+{
+public:
+ enum UploadHint {
+ SynchronousUploadHint = 0x0001,
+ CanUseAtlasUploadHint = 0x0002,
+
+ DefaultUploadHints = 0
+ };
+ Q_DECLARE_FLAGS(UploadHints, UploadHint);
+
+ virtual ~TextureManager() { };
+
+ virtual TextureReference *requestUploadedTexture(const QImage &image, UploadHints hints = DefaultUploadHints) = 0;
+};
+
+
+//typedef QSharedPointer<const QGLTexture2D> QGLTexture2DConstPtr;
+//typedef QSharedPointer<QGLTexture2D> QGLTexture2DPtr;
+
+//class TextureAtlasInterface
+//{
+//public:
+// enum Flag
+// {
+// DynamicFlag = 0x01 // Set if images are added to the texture atlas every few frames.
+// };
+
+// TextureAtlasInterface(uint flags) : m_flags(flags) { }
+// virtual ~TextureAtlasInterface() { }
+
+// virtual QGLTexture2DConstPtr texture() = 0;
+// virtual QRect allocate(const QImage &image, bool clampToEdge) = 0;
+// virtual void deallocate(const QRect &rect) = 0;
+
+// uint flags() const { return m_flags; }
+//protected:
+// uint m_flags;
+//};
+
+
class GlyphNodeInterface: public GeometryNode
{
public:
@@ -174,10 +227,10 @@ class AdaptationLayerInterface
{
public:
virtual RectangleNodeInterface *createRectangleNode() = 0;
- virtual PixmapNodeInterface *createPixmapNode() = 0;
- virtual TextureAtlasInterface *createTextureAtlas(uint flags) = 0;
+ virtual TextureNodeInterface *createTextureNode() = 0;
virtual GlyphNodeInterface *createGlyphNode() = 0;
virtual Renderer *createRenderer() = 0;
+ virtual TextureManager *textureManager() = 0;
};
#endif
diff --git a/src/adaptationlayers/adaptationlayers.pri b/src/adaptationlayers/adaptationlayers.pri
index e67729f..cc2ed71 100644
--- a/src/adaptationlayers/adaptationlayers.pri
+++ b/src/adaptationlayers/adaptationlayers.pri
@@ -4,17 +4,18 @@ HEADERS += \
$$PWD/adaptationinterfaces.h \
$$PWD/adaptationlayer.h \
$$PWD/default/default_adaptationlayer.h \
- $$PWD/default/default_pixmapnode.h \
+ $$PWD/default/default_texturenode.h \
$$PWD/default/default_rectanglenode.h \
- $$PWD/default/default_textureatlas.h \
$$PWD/default/default_glyphnode.h \
$$PWD/default/default_glyphnode_p.h \
+ $$PWD/default/default_texturemanager.h \
SOURCES += \
$$PWD/adaptationlayer.cpp \
$$PWD/default/default_adaptationlayer.cpp \
- $$PWD/default/default_pixmapnode.cpp \
+ $$PWD/default/default_texturenode.cpp \
$$PWD/default/default_rectanglenode.cpp \
- $$PWD/default/default_textureatlas.cpp \
$$PWD/default/default_glyphnode.cpp \
$$PWD/default/default_glyphnode_p.cpp \
+ $$PWD/default/default_texturemanager.cpp \
+ adaptationlayers/adaptationinterfaces.cpp
diff --git a/src/adaptationlayers/default/default_adaptationlayer.cpp b/src/adaptationlayers/default/default_adaptationlayer.cpp
index 2a4c168..b43f72d 100644
--- a/src/adaptationlayers/default/default_adaptationlayer.cpp
+++ b/src/adaptationlayers/default/default_adaptationlayer.cpp
@@ -41,27 +41,34 @@
#include "default_adaptationlayer.h"
-#include "default_textureatlas.h"
-#include "default_pixmapnode.h"
+#include "default_texturenode.h"
+#include "default_texturemanager.h"
#include "default_rectanglenode.h"
#include "default_glyphnode.h"
#include "qmlrenderer.h"
#include "geometry.h"
+DefaultAdaptationLayer::DefaultAdaptationLayer()
+ : m_texture_manager(0)
+{
+}
+
RectangleNodeInterface *DefaultAdaptationLayer::createRectangleNode()
{
return new DefaultRectangleNode(DefaultRectangleNode::PreferTextureMaterial);
}
-PixmapNodeInterface *DefaultAdaptationLayer::createPixmapNode()
+TextureNodeInterface *DefaultAdaptationLayer::createTextureNode()
{
- return new DefaultPixmapNode;
+ return new DefaultTextureNode;
}
-TextureAtlasInterface *DefaultAdaptationLayer::createTextureAtlas(uint flags)
+TextureManager *DefaultAdaptationLayer::textureManager()
{
- return new DefaultTextureAtlas(flags & TextureAtlasInterface::DynamicFlag ? QSize(256, 256) : QSize(1024, 1024), flags);
+ if (!m_texture_manager)
+ m_texture_manager = new DefaultTextureManager();
+ return m_texture_manager;
}
GlyphNodeInterface *DefaultAdaptationLayer::createGlyphNode()
diff --git a/src/adaptationlayers/default/default_adaptationlayer.h b/src/adaptationlayers/default/default_adaptationlayer.h
index a10699c..f2a9e3b 100644
--- a/src/adaptationlayers/default/default_adaptationlayer.h
+++ b/src/adaptationlayers/default/default_adaptationlayer.h
@@ -44,14 +44,22 @@
#include "adaptationinterfaces.h"
+class DefaultTextureManager;
+
class DefaultAdaptationLayer : public AdaptationLayerInterface
{
public:
+ DefaultAdaptationLayer();
+
virtual RectangleNodeInterface *createRectangleNode();
- virtual PixmapNodeInterface *createPixmapNode();
- virtual TextureAtlasInterface *createTextureAtlas(uint flags);
+ virtual TextureNodeInterface *createTextureNode();
virtual GlyphNodeInterface *createGlyphNode();
virtual Renderer *createRenderer();
+
+ virtual TextureManager *textureManager();
+
+private:
+ DefaultTextureManager *m_texture_manager;
};
#endif
diff --git a/src/adaptationlayers/default/default_glyphnode_p.cpp b/src/adaptationlayers/default/default_glyphnode_p.cpp
index bacaf1a..5d2bdc6 100644
--- a/src/adaptationlayers/default/default_glyphnode_p.cpp
+++ b/src/adaptationlayers/default/default_glyphnode_p.cpp
@@ -141,7 +141,7 @@ void TextMaskMaterialData::updateEffectState(Renderer *renderer, AbstractEffect
|| oldMaterial->texture()->textureId() != material->texture()->textureId()) {
m_program.setUniformValue(m_textureScale_id, QVector2D(1.0 / material->cacheTextureWidth(),
1.0 / material->cacheTextureHeight()));
- renderer->setTexture(0, material->texture().data());
+ renderer->setTexture(0, material->texture());
// Set the mag/min filters to be linear. We only need to do this when the texture
// has been recreated.
@@ -313,9 +313,10 @@ bool TextMaskMaterial::ensureUpToDate()
{
QSize glyphCacheSize(glyphCache()->width(), glyphCache()->height());
if (glyphCacheSize != m_size) {
- m_texture = QGLTexture2DPtr(QGLTexture2D::fromTextureId(glyphCache()->texture(),
- QSize(glyphCache()->width(),
- glyphCache()->height())));
+ // ### gunnar: port properly..
+// m_texture = QGLTexture2DPtr(QGLTexture2D::fromTextureId(glyphCache()->texture(),
+// QSize(glyphCache()->width(),
+// glyphCache()->height())));
m_size = glyphCacheSize;
return true;
diff --git a/src/adaptationlayers/default/default_glyphnode_p.h b/src/adaptationlayers/default/default_glyphnode_p.h
index c76ebd2..32907d0 100644
--- a/src/adaptationlayers/default/default_glyphnode_p.h
+++ b/src/adaptationlayers/default/default_glyphnode_p.h
@@ -63,7 +63,7 @@ public:
void setColor(const QColor &color) { m_color = color; }
const QColor &color() const { return m_color; }
- QGLTexture2DConstPtr texture() const { return m_texture; }
+ TextureReference *texture() const { return m_texture; }
void updateGlyphCache(const QGLContext *context);
@@ -83,7 +83,7 @@ public:
private:
void init();
- QGLTexture2DPtr m_texture;
+ TextureReference *m_texture;
QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache;
QFontEngine *m_fontEngine;
QFontEngine *m_originalFontEngine;
diff --git a/src/adaptationlayers/default/default_pixmapnode.cpp b/src/adaptationlayers/default/default_pixmapnode.cpp
deleted file mode 100644
index af31c02..0000000
--- a/src/adaptationlayers/default/default_pixmapnode.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt scene graph research project.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "adaptationinterfaces.h"
-
-#include "default_pixmapnode.h"
-#include "adaptationlayer.h"
-
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt scene graph research project.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmath.h>
-#include <qvarlengtharray.h>
-
-DefaultPixmapNode::DefaultPixmapNode()
-{
- m_material.setLinearFiltering(m_linear_filtering);
- m_materialO.setLinearFiltering(m_linear_filtering);
- m_materialO.setOpacity(m_opacity);
- setMaterial(&m_material);
-
- updateGeometryDescription(Utilities::getTexturedRectGeometryDescription(), GL_UNSIGNED_SHORT);
-
-#ifdef QML_RUNTIME_TESTING
- description = "pixmap";
-#endif
-}
-
-void DefaultPixmapNode::setRect(const QRectF &rect)
-{
- if (m_rect == rect)
- return;
- m_rect = rect;
- setBoundingRect(rect);
- setUpdateFlag(UpdateGeometry);
-}
-
-void DefaultPixmapNode::setSourceRect(const QRectF &rect)
-{
- if (m_source_rect == rect)
- return;
- m_source_rect = rect;
- setUpdateFlag(UpdateGeometry);
-}
-
-void DefaultPixmapNode::setOpacity(qreal opacity)
-{
- if (m_opacity == opacity)
- return;
- m_materialO.setOpacity(opacity);
- m_opacity = opacity;
- setMaterial(opacity == 1 ? &m_material : &m_materialO); // Indicate that the material state has changed.
-}
-
-void DefaultPixmapNode::setPixmap(const QPixmap &pixmap, bool dynamic)
-{
- if (pixmap.cacheKey() == m_pixmap.cacheKey())
- return;
- m_pixmap = pixmap;
- m_dynamic = dynamic;
- setUpdateFlag(UpdateTexture);
-}
-
-void DefaultPixmapNode::setClampToEdge(bool clampToEdge)
-{
- if (m_clamp_to_edge == clampToEdge)
- return;
- m_clamp_to_edge = clampToEdge;
- setUpdateFlag(UpdateTexture);
-}
-
-void DefaultPixmapNode::setLinearFiltering(bool linearFiltering)
-{
- if (m_linear_filtering == linearFiltering)
- return;
- m_material.setLinearFiltering(linearFiltering);
- m_materialO.setLinearFiltering(linearFiltering);
- m_linear_filtering = linearFiltering;
- setMaterial(m_opacity == 1 ? &m_material : &m_materialO); // Indicate that the material state has changed.
-}
-
-void DefaultPixmapNode::update(uint updateFlags)
-{
- if (updateFlags & UpdateTexture)
- updateTexture();
- // A texture update causes the source rectangle to change, so update geometry too.
- if (updateFlags & (UpdateTexture | UpdateGeometry))
- updateGeometry();
-}
-
-void DefaultPixmapNode::updateGeometry()
-{
- if (m_source_rect.isEmpty())
- m_source_rect = m_pixmap.rect();
-
- Geometry *g = geometry();
-
- QRectF normalizedSource(0, 0, 1, 1);
- if (!m_pixmap.isNull()) {
- normalizedSource = QRectF(m_source_rect.left() / m_pixmap.width(), m_source_rect.top() / m_pixmap.height(),
- m_source_rect.width() / m_pixmap.width(), m_source_rect.height() / m_pixmap.height());
- }
-
- QVarLengthArray<qreal> xSrc, xDst;
- xSrc.append(normalizedSource.left());
- xDst.append(m_rect.left());
- if (!m_texture.isNull() && !m_texture->hasOwnTexture()) {
- for (int i = qFloor(normalizedSource.left()) + 1; i <= qCeil(normalizedSource.right()) - 1; ++i) {
- xSrc.append(i);
- xDst.append(m_rect.left() + m_rect.width() * (i - normalizedSource.left()) / normalizedSource.width());
- }
- }
- xSrc.append(normalizedSource.right());
- xDst.append(m_rect.right());
-
- QVarLengthArray<qreal> ySrc, yDst;
- ySrc.append(normalizedSource.top());
- yDst.append(m_rect.top());
- if (!m_texture.isNull() && !m_texture->hasOwnTexture()) {
- for (int i = qFloor(normalizedSource.top()) + 1; i <= qCeil(normalizedSource.bottom()) - 1; ++i) {
- ySrc.append(i);
- yDst.append(m_rect.top() + m_rect.height() * (i - normalizedSource.top()) / normalizedSource.height());
- }
- }
- ySrc.append(normalizedSource.bottom());
- yDst.append(m_rect.bottom());
-
- if (xSrc.size() == 2 && ySrc.size() == 2) {
- g->setDrawingMode(QGL::TriangleStrip);
- g->setVertexCount(4);
- if (!m_clamp_to_edge) {
- g->setIndexCount(4);
- for (int i=0; i<4; ++i)
- g->ushortIndexData()[i] = i;
- }
- } else {
- g->setDrawingMode(QGL::Triangles);
- int cellCount = (xSrc.size() - 1) * (ySrc.size() - 1);
- int vertexCount = cellCount * 4; // Four vertices per grid cell.
- if (vertexCount > 0x10000)
- qWarning("QxPixmapNode::updateGeometry: Number of vertices exceeds 65536.");
- g->setVertexCount(vertexCount);
-
- if (!m_clamp_to_edge) {
- int indexCount = cellCount * 6; // Six indices per grid cell.
- g->setIndexCount(indexCount);
-
- for (int i = 0; i < cellCount; ++i) {
- g->ushortIndexData()[6 * i + 0] = i * 4 + 0;
- g->ushortIndexData()[6 * i + 1] = i * 4 + 1;
- g->ushortIndexData()[6 * i + 2] = i * 4 + 3;
- g->ushortIndexData()[6 * i + 3] = i * 4 + 3;
- g->ushortIndexData()[6 * i + 4] = i * 4 + 2;
- g->ushortIndexData()[6 * i + 5] = i * 4 + 0;
- }
- }
- }
-
- struct V {
- float x, y, tx, ty;
- };
-
- V *v = (V *) g->vertexData();
-
- qreal xSrcOffset = qFloor(normalizedSource.left());
- qreal ySrcOffset = qFloor(normalizedSource.top());
- QRectF texSrcRect;
- if (!m_texture.isNull())
- texSrcRect = m_texture->sourceRect();
-
- for (int j = 0; j < ySrc.size() - 1; ++j) {
- for (int i = 0; i < xSrc.size() - 1; ++i) {
- v[0].x = v[1].x = xDst.at(i);
- v[2].x = v[3].x = xDst.at(i + 1);
- v[0].y = v[2].y = yDst.at(j);
- v[1].y = v[3].y = yDst.at(j + 1);
-
- QRectF src(texSrcRect.x() + (xSrc.at(i) - i - xSrcOffset) * texSrcRect.width(),
- texSrcRect.y() + (ySrc.at(j) - j - ySrcOffset) * texSrcRect.height(),
- (xSrc.at(i + 1) - xSrc.at(i)) * texSrcRect.width(),
- (ySrc.at(j + 1) - ySrc.at(j)) * texSrcRect.height());
-
- v[0].tx = v[1].tx = src.left();
- v[2].tx = v[3].tx = src.right();
- v[0].ty = v[2].ty = src.top();
- v[1].ty = v[3].ty = src.bottom();
- v += 4;
- }
- }
-
- markDirty(DirtyGeometry);
-}
-
-void DefaultPixmapNode::updateTexture()
-{
- m_texture = Utilities::getTextureForPixmap(m_pixmap, m_clamp_to_edge, m_dynamic);
- bool opaque = !m_pixmap.hasAlphaChannel();
- m_material.setTexture(m_texture->texture(), opaque);
- m_materialO.setTexture(m_texture->texture(), opaque);
- setMaterial(m_opacity == 1 ? &m_material : &m_materialO); // Indicate that the material state has changed.
-}
diff --git a/src/adaptationlayers/default/default_rectanglenode.cpp b/src/adaptationlayers/default/default_rectanglenode.cpp
index 70b9647..ed5094b 100644
--- a/src/adaptationlayers/default/default_rectanglenode.cpp
+++ b/src/adaptationlayers/default/default_rectanglenode.cpp
@@ -52,6 +52,7 @@
DefaultRectangleNode::DefaultRectangleNode(MaterialPreference preference)
: m_material_preference(preference)
+ , m_gradient_texture(0)
, m_gradient_is_opaque(true)
{
m_border_material.setColor(m_pen_color);
@@ -144,8 +145,8 @@ void DefaultRectangleNode::setOpacity(qreal opacity)
if (opacity < 1) {
delete m_fill_material;
TextureMaterialWithOpacity *material = new TextureMaterialWithOpacity;
- if (!m_gradient_texture.isNull())
- material->setTexture(m_gradient_texture->texture(), m_gradient_is_opaque);
+ if (m_gradient_texture)
+ material->setTexture(m_gradient_texture, m_gradient_is_opaque);
material->setLinearFiltering(true);
material->setOpacity(opacity);
m_fill_material = material;
@@ -155,8 +156,8 @@ void DefaultRectangleNode::setOpacity(qreal opacity)
if (opacity >= 1) {
delete m_fill_material;
TextureMaterial *material = new TextureMaterial;
- if (!m_gradient_texture.isNull())
- material->setTexture(m_gradient_texture->texture(), m_gradient_is_opaque);
+ if (m_gradient_texture)
+ material->setTexture(m_gradient_texture, m_gradient_is_opaque);
material->setLinearFiltering(true);
m_fill_material = material;
} else {
@@ -179,7 +180,6 @@ void DefaultRectangleNode::setGradientStops(const QGradientStops &stops)
if (stops.isEmpty()) {
// No gradient specified, use flat color.
- m_gradient_texture.clear();
if (!FlatColorMaterial::is(m_fill_material)) {
delete m_fill_material;
FlatColorMaterial *material = new FlatColorMaterial;
@@ -280,12 +280,13 @@ void DefaultRectangleNode::updateGeometry()
// Calculate from where in the texture to sample gradient colours.
qreal gradientSourceX0 = 0, gradientSourceDX = 0, gradientSourceY = 0;
- if (!m_gradient_texture.isNull()) {
- QRectF src = m_gradient_texture->sourceRect();
- gradientSourceY = qreal(0.5) * (src.top() + src.bottom());
- gradientSourceDX = src.width() / stops.size();
- gradientSourceX0 = src.left() + qreal(0.5) * gradientSourceDX;
- }
+ // ### gunnar: port properly...
+// if (m_gradient_texture) {
+// QRectF src = m_gradient_texture->sourceRect();
+// gradientSourceY = qreal(0.5) * (src.top() + src.bottom());
+// gradientSourceDX = src.width() / stops.size();
+// gradientSourceX0 = src.left() + qreal(0.5) * gradientSourceDX;
+// }
if (m_radius > 0) {
// Rounded corners.
@@ -676,15 +677,17 @@ void DefaultRectangleNode::updateGradientTexture()
line[i] = QColor::fromRgbF(c.redF() * c.alphaF(), c.greenF() * c.alphaF(), c.blueF() * c.alphaF(), c.alphaF()).rgba();
}
- m_gradient_texture = Utilities::getTextureForImage(image, true);
+ m_gradient_texture =
+ qt_adaptation_layer()->textureManager()->requestUploadedTexture(image,
+ TextureManager::SynchronousUploadHint);
Q_ASSERT(TextureMaterial::is(m_fill_material) || TextureMaterialWithOpacity::is(m_fill_material));
// TextureMaterial and TextureMaterialWithOpacity have different (non-virtual) setTexture() implementations.
if (TextureMaterial::is(m_fill_material))
- static_cast<TextureMaterial *>(m_fill_material)->setTexture(m_gradient_texture->texture(), m_gradient_is_opaque);
+ static_cast<TextureMaterial *>(m_fill_material)->setTexture(m_gradient_texture, m_gradient_is_opaque);
else
- static_cast<TextureMaterialWithOpacity *>(m_fill_material)->setTexture(m_gradient_texture->texture(), m_gradient_is_opaque);
+ static_cast<TextureMaterialWithOpacity *>(m_fill_material)->setTexture(m_gradient_texture, m_gradient_is_opaque);
}
QRectF DefaultRectangleNode::calculateBoundingRect()
diff --git a/src/adaptationlayers/default/default_rectanglenode.h b/src/adaptationlayers/default/default_rectanglenode.h
index e11a0d5..c18d0be 100644
--- a/src/adaptationlayers/default/default_rectanglenode.h
+++ b/src/adaptationlayers/default/default_rectanglenode.h
@@ -84,7 +84,7 @@ private:
GeometryNode m_border;
AbstractEffect *m_fill_material; // Can be FlatColorMaterial, VertexColorMaterial, TextureMaterial or TextureMaterialWithOpacity.
FlatColorMaterial m_border_material;
- SubTexture2DConstPtr m_gradient_texture;
+ TextureReference *m_gradient_texture;
bool m_gradient_is_opaque;
};
diff --git a/src/adaptationlayers/default/default_textureatlas.h b/src/adaptationlayers/default/default_textureatlas.h
index d94b43d..0e1c4be 100644
--- a/src/adaptationlayers/default/default_textureatlas.h
+++ b/src/adaptationlayers/default/default_textureatlas.h
@@ -39,7 +39,6 @@
**
****************************************************************************/
-
#ifndef DEFAULT_TEXTUREATLAS_H
#define DEFAULT_TEXTUREATLAS_H
diff --git a/src/effects/shadereffectitem.cpp b/src/effects/shadereffectitem.cpp
index 8c179d8..eda7256 100644
--- a/src/effects/shadereffectitem.cpp
+++ b/src/effects/shadereffectitem.cpp
@@ -258,12 +258,13 @@ void ShaderEffectSource::setMipmap(FilterMode mode)
Q_ASSERT(m_sourceItem);
delete m_fbo;
m_fbo = 0;
- } else if (!m_texture.isNull()) {
- Q_ASSERT(!m_sourceImage.isEmpty());
- if (~m_texture->bindOptions() & QGLContext::MipmapBindOption) {
- m_texture.clear();
- updateSizeAndTexture();
- }
+ } else if (m_texture) {
+ // ### gunnar: port properly
+// Q_ASSERT(!m_sourceImage.isEmpty());
+// if (~m_texture->bindOptions() & QGLContext::MipmapBindOption) {
+// m_texture.clear();
+// updateSizeAndTexture();
+// }
}
m_dirtyTexture = true;
}
@@ -352,8 +353,8 @@ void ShaderEffectSource::bind() const
#endif
if (m_fbo) {
glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
- } else if (!m_texture.isNull()) {
- m_texture->bind();
+ } else if (m_texture) {
+ glBindTexture(GL_TEXTURE_2D, m_texture->textureId());
} else {
glBindTexture(GL_TEXTURE_2D, 0);
}
@@ -475,27 +476,28 @@ void ShaderEffectSource::updateSizeAndTexture()
m_fbo = 0;
}
if (!m_sourceImage.isEmpty()) {
- m_texture = QGLTexture2DPtr(new QGLTexture2D);
- QGLContext::BindOption mipmap = m_mipmap != None
- ? QGLContext::MipmapBindOption : QGLContext::BindOption(0);
- m_texture->setBindOptions(QGLContext::InternalBindOption | mipmap);
-
- // TODO: Implement async loading and loading over network.
- QImageReader reader(m_sourceImage.toLocalFile());
- if (!m_textureSize.isEmpty())
- reader.setScaledSize(m_textureSize);
- QImage image = reader.read();
- if (image.isNull())
- qWarning() << reader.errorString();
- m_texture->setImage(image.mirrored());
- if (m_size.width() != image.width()) {
- m_size.setWidth(image.width());
- emit widthChanged();
- }
- if (m_size.height() != image.height()) {
- m_size.setHeight(image.height());
- emit heightChanged();
- }
+ // ### gunnar: port properly
+// m_texture = QGLTexture2DPtr(new QGLTexture2D);
+// QGLContext::BindOption mipmap = m_mipmap != None
+// ? QGLContext::MipmapBindOption : QGLContext::BindOption(0);
+// m_texture->setBindOptions(QGLContext::InternalBindOption | mipmap);
+
+// // TODO: Implement async loading and loading over network.
+// QImageReader reader(m_sourceImage.toLocalFile());
+// if (!m_textureSize.isEmpty())
+// reader.setScaledSize(m_textureSize);
+// QImage image = reader.read();
+// if (image.isNull())
+// qWarning() << reader.errorString();
+// m_texture->setImage(image.mirrored());
+// if (m_size.width() != image.width()) {
+// m_size.setWidth(image.width());
+// emit widthChanged();
+// }
+// if (m_size.height() != image.height()) {
+// m_size.setHeight(image.height());
+// emit heightChanged();
+// }
} else {
if (m_size.width() != 0) {
m_size.setWidth(0);
diff --git a/src/effects/shadereffectitem.h b/src/effects/shadereffectitem.h
index 689ef64..b490235 100644
--- a/src/effects/shadereffectitem.h
+++ b/src/effects/shadereffectitem.h
@@ -162,7 +162,7 @@ private:
QSize m_size;
bool m_static;
- QGLTexture2DPtr m_texture;
+ TextureReference *m_texture;
QGLFramebufferObject *m_fbo;
Renderer *m_renderer;
int m_refs;
diff --git a/src/graphicsitems/graphicsitems.pri b/src/graphicsitems/graphicsitems.pri
index a03df6e..24239b0 100644
--- a/src/graphicsitems/graphicsitems.pri
+++ b/src/graphicsitems/graphicsitems.pri
@@ -3,7 +3,6 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qxrectangle_p.h \
$$PWD/qxrectangle_p_p.h \
- $$PWD/qxparticles_p.h \
$$PWD/qxitem.h \
$$PWD/qxitem_p.h \
$$PWD/qxanchors_p.h \
@@ -30,8 +29,6 @@ HEADERS += \
$$PWD/qxpathview_p_p.h \
$$PWD/qxpositioners_p.h \
$$PWD/qxpositioners_p_p.h \
- $$PWD/qxpainteditem_p_p.h \
- $$PWD/qxpainteditem_p.h \
$$PWD/qxtextedit_p_p.h \
$$PWD/qxtextedit_p.h \
$$PWD/qxtextinput_p_p.h \
@@ -48,13 +45,11 @@ HEADERS += \
$$PWD/qxfocusscope_p.h \
$$PWD/qxpaintitem.h \
$$PWD/qxpaintitem_p.h \
- $$PWD/nodes/qxparticlenode_p.h \
$$PWD/nodes/qxninepatchnode_p.h \
$$PWD/nodes/qxpainternode.h
SOURCES += \
$$PWD/qxrectangle.cpp \
- $$PWD/qxparticles.cpp \
$$PWD/qxitem.cpp \
$$PWD/qxanchors.cpp \
$$PWD/qxmousearea.cpp \
@@ -69,7 +64,6 @@ SOURCES += \
$$PWD/qxgridview.cpp \
$$PWD/qxpathview.cpp \
$$PWD/qxpositioners.cpp \
- $$PWD/qxpainteditem.cpp \
$$PWD/qxtextedit.cpp \
$$PWD/qxtextinput.cpp \
$$PWD/qxloader.cpp \
@@ -79,6 +73,5 @@ SOURCES += \
$$PWD/qxparentanimation.cpp \
$$PWD/qxfocusscope.cpp \
$$PWD/qxpaintitem.cpp \
- $$PWD/nodes/qxparticlenode.cpp \
$$PWD/nodes/qxninepatchnode.cpp \
$$PWD/nodes/qxpainternode.cpp
diff --git a/src/graphicsitems/nodes/qxninepatchnode.cpp b/src/graphicsitems/nodes/qxninepatchnode.cpp
index 6de5ef6..e7bbe11 100644
--- a/src/graphicsitems/nodes/qxninepatchnode.cpp
+++ b/src/graphicsitems/nodes/qxninepatchnode.cpp
@@ -43,15 +43,15 @@
#include "utilities.h"
#include "adaptationlayer.h"
-QxNinePatchNode::QxNinePatchNode(const QRectF &targetRect, const QPixmap &pixmap,
+QxNinePatchNode::QxNinePatchNode(const QRectF &targetRect, TextureReference *texture,
const QRect &innerRect, qreal opacity, bool linearFiltering)
-: m_targetRect(targetRect), m_pixmap(pixmap), m_innerRect(innerRect), m_opacity(opacity), m_linearFiltering(linearFiltering)
+: m_targetRect(targetRect), m_innerRect(innerRect), m_opacity(opacity), m_linearFiltering(linearFiltering)
{
- m_texture = Utilities::getTextureForPixmap(pixmap, true);
- bool alpha = pixmap.hasAlphaChannel();
- m_material.setTexture(m_texture->texture(), !alpha);
+ m_texture = texture;
+ bool alpha = texture->hasAlphaChannel();
+ m_material.setTexture(m_texture, !alpha);
m_material.setLinearFiltering(linearFiltering);
- m_materialO.setTexture(m_texture->texture(), !alpha);
+ m_materialO.setTexture(m_texture, !alpha);
m_materialO.setOpacity(m_opacity);
m_materialO.setLinearFiltering(linearFiltering);
@@ -135,12 +135,13 @@ void QxNinePatchNode::updateGeometry()
V *vertices = (V *)g->vertexData();
qreal x[6], y[6], u[6], v[6];
+ QRectF texRect = m_texture->textureRect();
x[0] = m_targetRect.x();
x[1] = m_targetRect.x() + m_innerRect.x();
x[2] = x[1] + 0.5;
x[3] = m_targetRect.x() + m_targetRect.width() -
- (m_pixmap.width() - (m_innerRect.x() + m_innerRect.width()));
+ (texRect.width() - (m_innerRect.x() + m_innerRect.width()));
x[4] = x[3] - 0.5;
x[5] = m_targetRect.x() + m_targetRect.width();
@@ -148,14 +149,14 @@ void QxNinePatchNode::updateGeometry()
y[1] = m_targetRect.y() + m_innerRect.y();
y[2] = y[1] + 0.5;
y[3] = m_targetRect.y() + m_targetRect.height() -
- (m_pixmap.height() - (m_innerRect.y() + m_innerRect.height()));
+ (texRect.height() - (m_innerRect.y() + m_innerRect.height()));
y[4] = y[3] - 0.5;
y[5] = m_targetRect.y() + m_targetRect.height();
- qreal pw = m_pixmap.width();
- qreal ph = m_pixmap.height();
+ qreal pw = texRect.width();
+ qreal ph = texRect.height();
- QRectF src = m_texture->sourceRect();
+ QRectF src = texRect;
u[0] = src.left();
u[1] = src.left() + m_innerRect.x() / pw * src.width();
u[2] = u[1] + 0.5 / pw * src.width();
diff --git a/src/graphicsitems/nodes/qxninepatchnode_p.h b/src/graphicsitems/nodes/qxninepatchnode_p.h
index 9484a60..1ad2fcc 100644
--- a/src/graphicsitems/nodes/qxninepatchnode_p.h
+++ b/src/graphicsitems/nodes/qxninepatchnode_p.h
@@ -45,10 +45,12 @@
#include "node.h"
#include "texturematerial.h"
+class TextureReference;
+
class QxNinePatchNode : public GeometryNode
{
public:
- QxNinePatchNode(const QRectF &targetRect, const QPixmap &, const QRect &innerRect, qreal opacity = 1., bool linearFiltering = false);
+ QxNinePatchNode(const QRectF &targetRect, TextureReference *texture, const QRect &innerRect, qreal opacity = 1., bool linearFiltering = false);
void setData(const QRectF &rect, qreal opacity);
@@ -64,13 +66,12 @@ public:
private:
void updateGeometry();
QRectF m_targetRect;
- QPixmap m_pixmap;
QRect m_innerRect;
qreal m_opacity;
bool m_linearFiltering;
TextureMaterial m_material;
TextureMaterialWithOpacity m_materialO;
- SubTexture2DPtr m_texture;
+ TextureReference *m_texture;
};
#if 0
diff --git a/src/graphicsitems/nodes/qxpainternode.cpp b/src/graphicsitems/nodes/qxpainternode.cpp
index 762b98f..575ac1d 100644
--- a/src/graphicsitems/nodes/qxpainternode.cpp
+++ b/src/graphicsitems/nodes/qxpainternode.cpp
@@ -89,13 +89,15 @@ void QxPainterNode::preprocess()
void QxPainterNode::updateTexture()
{
- QGLTexture2DPtr ptr(QGLTexture2D::fromTextureId(m_fbo->texture(), m_fbo->size()));
- m_material.setTexture(ptr, m_item->opaquePainting());
- m_material.setLinearFiltering(m_linear_filtering);
- m_materialO.setTexture(ptr, m_item->opaquePainting());
- m_materialO.setLinearFiltering(m_linear_filtering);
- m_materialO.setOpacity(m_opacity);
- setMaterial(m_opacity == 1 ? &m_material : &m_materialO);
+ // ### gunnar: port properly..
+ // If we just made the DefaultTextureReference available in adapt.h, then this should be easy..
+// QGLTexture2DPtr ptr(QGLTexture2D::fromTextureId(m_fbo->texture(), m_fbo->size()));
+// m_material.setTexture(ptr, m_item->opaquePainting());
+// m_material.setLinearFiltering(m_linear_filtering);
+// m_materialO.setTexture(ptr, m_item->opaquePainting());
+// m_materialO.setLinearFiltering(m_linear_filtering);
+// m_materialO.setOpacity(m_opacity);
+// setMaterial(m_opacity == 1 ? &m_material : &m_materialO);
}
void QxPainterNode::setSize(const QSize &size)
diff --git a/src/graphicsitems/qxborderimage.cpp b/src/graphicsitems/qxborderimage.cpp
index 4224382..76e377a 100644
--- a/src/graphicsitems/qxborderimage.cpp
+++ b/src/graphicsitems/qxborderimage.cpp
@@ -44,6 +44,8 @@
#include "nodes/qxninepatchnode_p.h"
+#include "adaptationlayer.h"
+
#include <QtDeclarative/qdeclarativeinfo.h>
#include <private/qdeclarativeengine_p.h>
@@ -336,7 +338,13 @@ void QxBorderImagePrivate::updatePixmap()
const QDeclarativeScaleGrid *border = getScaleGrid();
QRect inner(border->left(), border->top(), pix.width() - border->right() - border->left(),
pix.height() - border->bottom() - border->top());
- node = new QxNinePatchNode(QRectF(0, 0, q->width(), q->height()), pix, inner, q->renderOpacity(), smooth);
+
+ if (!texture) {
+ texture = qt_adaptation_layer()->textureManager()->requestUploadedTexture(pix.pixmap().toImage(),
+ TextureManager::SynchronousUploadHint);
+ } // ### gunnar: does not support changing images...
+
+ node = new QxNinePatchNode(QRectF(0, 0, q->width(), q->height()), texture, inner, q->renderOpacity(), smooth);
q->setPaintNode(node);
}
}
diff --git a/src/graphicsitems/qxborderimage_p_p.h b/src/graphicsitems/qxborderimage_p_p.h
index 129d861..0fc0036 100644
--- a/src/graphicsitems/qxborderimage_p_p.h
+++ b/src/graphicsitems/qxborderimage_p_p.h
@@ -68,7 +68,7 @@ public:
: border(0), sciReply(0),
horizontalTileMode(QxBorderImage::Stretch),
verticalTileMode(QxBorderImage::Stretch),
- redirectCount(0), node(0)
+ redirectCount(0), node(0), texture(0)
{
}
@@ -90,6 +90,7 @@ public:
void updateNode();
void updatePixmap();
QxNinePatchNode *node;
+ TextureReference *texture;
};
#endif // QXBORDERIMAGE_P_H
diff --git a/src/graphicsitems/qximage.cpp b/src/graphicsitems/qximage.cpp
index 03ea51e..9366bf0 100644
--- a/src/graphicsitems/qximage.cpp
+++ b/src/graphicsitems/qximage.cpp
@@ -61,6 +61,7 @@ QxImage::~QxImage()
{
Q_D(QxImage);
delete d->node;
+ delete d->texture;
}
QPixmap QxImage::pixmap() const
@@ -193,9 +194,14 @@ void QxImagePrivate::update()
}
if (!node) {
- node = qt_adaptation_layer()->createPixmapNode();
- node->setPixmap(pix);
+ node = qt_adaptation_layer()->createTextureNode();
}
+
+ if (!texture) {
+ texture = qt_adaptation_layer()->textureManager()->requestUploadedTexture(pix.pixmap().toImage(),
+ TextureManager::SynchronousUploadHint);
+ }
+
node->setRect(targetRect);
node->setSourceRect(sourceRect);
node->setOpacity(renderOpacity);
@@ -232,6 +238,8 @@ void QxImage::pixmapChange()
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
d->status = d->pix.isNull() ? QxImageBase::Null : QxImageBase::Ready;
+ delete d->texture;
+ d->texture = 0;
d->pixmapDirty = true;
d->update();
emit pixmapChanged();
diff --git a/src/graphicsitems/qximage_p_p.h b/src/graphicsitems/qximage_p_p.h
index 34783f3..07d0154 100644
--- a/src/graphicsitems/qximage_p_p.h
+++ b/src/graphicsitems/qximage_p_p.h
@@ -75,7 +75,8 @@ public:
void update();
void updateOpacity();
bool pixmapDirty;
- PixmapNodeInterface *node;
+ TextureNodeInterface *node;
+ TextureReference *texture;
};
#endif // QXIMAGE_P_H
diff --git a/src/graphicsitems/qximagebase_p_p.h b/src/graphicsitems/qximagebase_p_p.h
index 8c136ad..103d847 100644
--- a/src/graphicsitems/qximagebase_p_p.h
+++ b/src/graphicsitems/qximagebase_p_p.h
@@ -55,6 +55,7 @@
#include "qxitem_p.h"
#include "private/qdeclarativepixmapcache_p.h"
+#include "adaptationinterfaces.h"
#include <QtCore/QPointer>
class QNetworkReply;
@@ -66,6 +67,7 @@ public:
QxImageBasePrivate()
: status(QxImageBase::Null),
progress(0.0),
+ texture(0),
explicitSourceSize(false),
async(false)
{
@@ -76,6 +78,7 @@ public:
QUrl url;
qreal progress;
QSize sourcesize;
+ TextureReference *texture;
bool explicitSourceSize : 1;
bool async : 1;
};
diff --git a/src/graphicsitems/qxpainteditem_p_p.h b/src/graphicsitems/qxpainteditem_p_p.h
index 2f02bbb..f4ee6f4 100644
--- a/src/graphicsitems/qxpainteditem_p_p.h
+++ b/src/graphicsitems/qxpainteditem_p_p.h
@@ -73,7 +73,7 @@ public:
QRect area;
QRect dirty; // one dirty area (allows optimization of common cases)
QPixmap image;
- PixmapNodeInterface *node;
+ TextureNodeInterface *node;
};
QList<ImageCacheItem*> imagecache;
diff --git a/src/graphicsitems/qxparticles.cpp b/src/graphicsitems/qxparticles.cpp
index ee48929..4fb3c54 100644
--- a/src/graphicsitems/qxparticles.cpp
+++ b/src/graphicsitems/qxparticles.cpp
@@ -906,7 +906,7 @@ void QxParticlesPainter::setSource(const QUrl &name)
if (image.isLoading()) {
image.connectFinished(this, SLOT(imageLoaded()));
} else {
- if (image.isError())
+ if (image.isError())
qmlInfo(this) << image.error();
//### unify with imageLoaded
update();
diff --git a/src/qmlscene_global.cpp b/src/qmlscene_global.cpp
index dea3cd9..1734b32 100644
--- a/src/qmlscene_global.cpp
+++ b/src/qmlscene_global.cpp
@@ -52,7 +52,6 @@
#include <graphicsitems/qxevents_p.h>
#include <graphicsitems/qxmousearea_p.h>
#include <graphicsitems/qxrectangle_p.h>
-#include <graphicsitems/qxparticles_p.h>
#include <graphicsitems/qximage_p.h>
#include <graphicsitems/qxborderimage_p.h>
#include <graphicsitems/qxtext_p.h>
@@ -162,19 +161,19 @@ void qt_scenegraph_register_types()
qmlRegisterType<QxAnchorAnimation>(name, majorVersion, minorVersion,"AnchorAnimation");
qmlRegisterType<QxParentAnimation>(name, majorVersion, minorVersion,"ParentAnimation");
- qmlRegisterType<QxParticleMotion>();
- qmlRegisterType<QxParticleMotionGravity>("Qt.particles",1,0,"ParticleMotionGravity");
- qmlRegisterType<QxParticleMotionLinear>("Qt.particles",1,0,"ParticleMotionLinear");
- qmlRegisterType<QxParticleMotionWander>("Qt.particles",1,0,"ParticleMotionWander");
- qmlRegisterType<QxParticleMotionRandomDrift>("Qt.particles",1,0,"ParticleMotionRandomDrift");
- qmlRegisterType<QxParticleKillZone>("Qt.particles",1,0,"ParticleKillZone");
- qmlRegisterType<QxParticleMotionAcceleration>("Qt.particles",1,0,"ParticleMotionAcceleration");
- qmlRegisterType<QxParticleMotionFriction>("Qt.particles",1,0,"ParticleMotionFriction");
- qmlRegisterType<QxParticleMotionGravityWell>("Qt.particles",1,0,"ParticleMotionGravityWell");
- qmlRegisterType<QxParticleMotionAntiGravity>("Qt.particles",1,0,"ParticleMotionAntiGravity");
- qmlRegisterType<QxParticles>("Qt.particles",1,0,"ParticleEmitter");
- qmlRegisterType<QxParticlesPainter>("Qt.particles",1,0,"ParticlePainter");
- qmlRegisterType<QxParticleField>("Qt.particles",1,0,"ParticleField");
+// qmlRegisterType<QxParticleMotion>();
+// qmlRegisterType<QxParticleMotionGravity>("Qt.particles",1,0,"ParticleMotionGravity");
+// qmlRegisterType<QxParticleMotionLinear>("Qt.particles",1,0,"ParticleMotionLinear");
+// qmlRegisterType<QxParticleMotionWander>("Qt.particles",1,0,"ParticleMotionWander");
+// qmlRegisterType<QxParticleMotionRandomDrift>("Qt.particles",1,0,"ParticleMotionRandomDrift");
+// qmlRegisterType<QxParticleKillZone>("Qt.particles",1,0,"ParticleKillZone");
+// qmlRegisterType<QxParticleMotionAcceleration>("Qt.particles",1,0,"ParticleMotionAcceleration");
+// qmlRegisterType<QxParticleMotionFriction>("Qt.particles",1,0,"ParticleMotionFriction");
+// qmlRegisterType<QxParticleMotionGravityWell>("Qt.particles",1,0,"ParticleMotionGravityWell");
+// qmlRegisterType<QxParticleMotionAntiGravity>("Qt.particles",1,0,"ParticleMotionAntiGravity");
+// qmlRegisterType<QxParticles>("Qt.particles",1,0,"ParticleEmitter");
+// qmlRegisterType<QxParticlesPainter>("Qt.particles",1,0,"ParticlePainter");
+// qmlRegisterType<QxParticleField>("Qt.particles",1,0,"ParticleField");
qmlRegisterType<ShaderEffectItem>("QtQuick", 2, 0, "ShaderEffectItem");
qmlRegisterType<ShaderEffectSource>("QtQuick", 2, 0, "ShaderEffectSource");
diff --git a/src/scenegraph/3d/qgltextureutils.cpp b/src/scenegraph/3d/qgltextureutils.cpp
index a098bb7..62564a8 100644
--- a/src/scenegraph/3d/qgltextureutils.cpp
+++ b/src/scenegraph/3d/qgltextureutils.cpp
@@ -175,7 +175,7 @@ QGLBoundTexture::~QGLBoundTexture()
{
}
-// #define QGL_BIND_TEXTURE_DEBUG
+#define QGL_BIND_TEXTURE_DEBUG
void QGLBoundTexture::startUpload(GLenum target, const QSize &imageSize)
{
diff --git a/src/scenegraph/convenience/pixmapnode.h b/src/scenegraph/convenience/pixmapnode.h
index d6a0016..c5854fc 100644
--- a/src/scenegraph/convenience/pixmapnode.h
+++ b/src/scenegraph/convenience/pixmapnode.h
@@ -67,7 +67,6 @@ private:
QPixmap m_pixmap;
QRectF m_source_rect;
TextureMaterial m_material;
- SubTexture2DPtr m_texture;
};
diff --git a/src/scenegraph/convenience/textnode.cpp b/src/scenegraph/convenience/textnode.cpp
index 2ca3f9e..9d3880c 100644
--- a/src/scenegraph/convenience/textnode.cpp
+++ b/src/scenegraph/convenience/textnode.cpp
@@ -389,7 +389,7 @@ void TextNode::setOpacity(qreal opacity)
SolidRectNode *solidRectNode = static_cast<SolidRectNode *>(node);
solidRectNode->setOpacity(opacity);
} else if (node->subType() == PixmapNodeSubType) {
- PixmapNodeInterface *pixmapNode = static_cast<PixmapNodeInterface *>(node);
+ TextureNodeInterface *pixmapNode = static_cast<TextureNodeInterface *>(node);
pixmapNode->setOpacity(opacity);
}
}
@@ -821,8 +821,8 @@ void TextNode::updateNodes()
if (pixmap.isNull())
return;
- PixmapNodeInterface *pixmapNode = qt_adaptation_layer()->createPixmapNode();
- pixmapNode->setPixmap(pixmap);
+ TextureNodeInterface *pixmapNode = qt_adaptation_layer()->createTextureNode();
+ // ### gunnar: port properly
pixmapNode->setRect(pixmap.rect());
pixmapNode->setSourceRect(pixmap.rect());
pixmapNode->setOpacity(m_opacity);
diff --git a/src/scenegraph/convenience/texturematerial.cpp b/src/scenegraph/convenience/texturematerial.cpp
index bf120ee..84d341e 100644
--- a/src/scenegraph/convenience/texturematerial.cpp
+++ b/src/scenegraph/convenience/texturematerial.cpp
@@ -120,9 +120,10 @@ void TextureMaterialData::updateEffectState(Renderer *renderer, AbstractEffect *
TextureMaterial *oldTx = static_cast<TextureMaterial *>(oldEffect);
if (oldEffect == 0 || tx->texture() != oldTx->texture()) {
- renderer->setTexture(0, tx->texture().data());
+ renderer->setTexture(0, tx->texture());
oldEffect = 0; // Force filtering update.
}
+
if (oldEffect == 0 || tx->linearFiltering() != oldTx->linearFiltering()) {
int filtering = tx->linearFiltering() ? GL_LINEAR : GL_NEAREST;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
@@ -131,7 +132,7 @@ void TextureMaterialData::updateEffectState(Renderer *renderer, AbstractEffect *
}
-void TextureMaterial::setTexture(QGLTexture2DConstPtr texture, bool opaque)
+void TextureMaterial::setTexture(TextureReference *texture, bool opaque)
{
m_texture = texture;
m_opaque = opaque;
@@ -212,7 +213,7 @@ int TextureMaterialWithOpacity::compare(const AbstractEffect *o) const
return int(other->m_opacity < m_opacity) - int(m_opacity < other->m_opacity);
}
-void TextureMaterialWithOpacity::setTexture(QGLTexture2DConstPtr texture, bool opaque)
+void TextureMaterialWithOpacity::setTexture(TextureReference *texture, bool opaque)
{
m_texture = texture;
m_opaque = opaque;
@@ -231,7 +232,7 @@ void TextureMaterialWithOpacityData::updateEffectState(Renderer *renderer, Abstr
TextureMaterialWithOpacity *oldTx = static_cast<TextureMaterialWithOpacity *>(oldEffect);
if (oldEffect == 0 || tx->texture() != oldTx->texture()) {
- renderer->setTexture(0, tx->texture().data());
+ renderer->setTexture(0, tx->texture());
oldEffect = 0; // Force filtering update.
}
if (oldEffect == 0 || tx->linearFiltering() != oldTx->linearFiltering()) {
diff --git a/src/scenegraph/convenience/texturematerial.h b/src/scenegraph/convenience/texturematerial.h
index c4007e8..905e85b 100644
--- a/src/scenegraph/convenience/texturematerial.h
+++ b/src/scenegraph/convenience/texturematerial.h
@@ -54,8 +54,9 @@ public:
virtual AbstractEffectProgram *createProgram() const;
virtual int compare(const AbstractEffect *other) const;
- void setTexture(QGLTexture2DConstPtr texture, bool opaque = false);
- QGLTexture2DConstPtr texture() const { return m_texture; }
+ // ### gunnar: opaque -> alpha, as "hasAlphaChannel()" is what we normally use
+ void setTexture(TextureReference *texture, bool opaque = false);
+ TextureReference *texture() const { return m_texture; }
void setLinearFiltering(bool linearFiltering) { m_linear_filtering = linearFiltering; }
bool linearFiltering() const { return m_linear_filtering; }
@@ -63,7 +64,7 @@ public:
static bool is(const AbstractEffect *effect);
protected:
- QGLTexture2DConstPtr m_texture;
+ TextureReference *m_texture;
bool m_opaque;
bool m_linear_filtering;
};
@@ -95,8 +96,7 @@ public:
virtual AbstractEffectType *type() const;
virtual AbstractEffectProgram *createProgram() const;
virtual int compare(const AbstractEffect *other) const;
-
- void setTexture(QGLTexture2DConstPtr texture, bool opaque = false);
+ void setTexture(TextureReference *texture, bool opaque = false);
void setOpacity(qreal opacity);
qreal opacity() const { return m_opacity; }
diff --git a/src/scenegraph/convenience/utilities.cpp b/src/scenegraph/convenience/utilities.cpp
index ca6d2bb..ea36666 100644
--- a/src/scenegraph/convenience/utilities.cpp
+++ b/src/scenegraph/convenience/utilities.cpp
@@ -50,30 +50,30 @@
#include <QGLShaderProgram>
-SubTexture2D::SubTexture2D(TextureAtlasInterface *atlas, const QRect &allocatedRect)
- : m_allocated(allocatedRect)
- , m_atlas(atlas)
- , m_texture(atlas->texture())
-{
- qreal w = m_texture->size().width();
- qreal h = m_texture->size().height();
- m_source = QRectF(m_allocated.x() / w, m_allocated.y() / h, m_allocated.width() / w, m_allocated.height() / h);
-}
+//SubTexture2D::SubTexture2D(TextureAtlasInterface *atlas, const QRect &allocatedRect)
+// : m_allocated(allocatedRect)
+// , m_atlas(atlas)
+// , m_texture(atlas->texture())
+//{
+// qreal w = m_texture->size().width();
+// qreal h = m_texture->size().height();
+// m_source = QRectF(m_allocated.x() / w, m_allocated.y() / h, m_allocated.width() / w, m_allocated.height() / h);
+//}
-SubTexture2D::SubTexture2D(const QGLTexture2DConstPtr &texture)
- : m_source(0, 0, 1, 1)
- , m_atlas(0)
- , m_texture(texture)
-{
-}
+//SubTexture2D::SubTexture2D(const QGLTexture2DConstPtr &texture)
+// : m_source(0, 0, 1, 1)
+// , m_atlas(0)
+// , m_texture(texture)
+//{
+//}
-SubTexture2D::~SubTexture2D()
-{
- if (m_atlas) {
- Q_ASSERT(!m_allocated.isNull());
- m_atlas->deallocate(m_allocated);
- }
-}
+//SubTexture2D::~SubTexture2D()
+//{
+// if (m_atlas) {
+// Q_ASSERT(!m_allocated.isNull());
+// m_atlas->deallocate(m_allocated);
+// }
+//}
void Utilities::setupRectGeometry(Geometry *geometry, const QRectF &rect, const QSize &textureSize, const QRectF &sourceRect)
@@ -155,125 +155,125 @@ Geometry *Utilities::createTexturedRectGeometry(const QRectF &rect, const QSize
return g;
}
-static struct TextureCache
-{
- ~TextureCache()
- {
- QList<QWeakPointer<SubTexture2D> > t = textures.values();
- int count = 0;
- for (int i = 0; i < t.size(); ++i) {
- if (!t.at(i).isNull())
- ++count;
- }
- qDebug("Textures left in the texture cache: %i", count);
- count = 0;
- for (int i = 0; i < AtlasTypeCount; ++i) {
- count += atlases[i].size();
- qDeleteAll(atlases[i]);
- }
- qDebug("Number of texture atlases used: %i", count);
- }
+//static struct TextureCache
+//{
+// ~TextureCache()
+// {
+// QList<QWeakPointer<SubTexture2D> > t = textures.values();
+// int count = 0;
+// for (int i = 0; i < t.size(); ++i) {
+// if (!t.at(i).isNull())
+// ++count;
+// }
+// qDebug("Textures left in the texture cache: %i", count);
+// count = 0;
+// for (int i = 0; i < AtlasTypeCount; ++i) {
+// count += atlases[i].size();
+// qDeleteAll(atlases[i]);
+// }
+// qDebug("Number of texture atlases used: %i", count);
+// }
- struct Key {
- qint64 imageKey;
- uint clampToEdge : 1;
- bool operator == (const Key &other) const
- {
- return imageKey == other.imageKey && clampToEdge == other.clampToEdge;
- }
- };
+// struct Key {
+// qint64 imageKey;
+// uint clampToEdge : 1;
+// bool operator == (const Key &other) const
+// {
+// return imageKey == other.imageKey && clampToEdge == other.clampToEdge;
+// }
+// };
- enum AtlasType
- {
- StaticAtlasType,
- DynamicAtlasType,
- AtlasTypeCount
- };
+// enum AtlasType
+// {
+// StaticAtlasType,
+// DynamicAtlasType,
+// AtlasTypeCount
+// };
- typedef QHash<Key, QWeakPointer<SubTexture2D> > Hash;
+// typedef QHash<Key, QWeakPointer<SubTexture2D> > Hash;
- static SubTexture2DPtr insert(const TextureCache::Key &key, const QImage &image, bool clampToEdge, bool dynamic);
+// static SubTexture2DPtr insert(const TextureCache::Key &key, const QImage &image, bool clampToEdge, bool dynamic);
- // ### Replace with a QCache or something to avoid growing to infinity and beyond.
- Hash textures;
- QVector<TextureAtlasInterface *> atlases[AtlasTypeCount];
-} textureCache;
+// // ### Replace with a QCache or something to avoid growing to infinity and beyond.
+// Hash textures;
+// QVector<TextureAtlasInterface *> atlases[AtlasTypeCount];
+//} textureCache;
-uint qHash(const TextureCache::Key &key)
-{
- return qHash(key.imageKey) ^ uint(key.clampToEdge << 31);
-}
+//uint qHash(const TextureCache::Key &key)
+//{
+// return qHash(key.imageKey) ^ uint(key.clampToEdge << 31);
+//}
-SubTexture2DPtr TextureCache::insert(const TextureCache::Key &key, const QImage &image, bool clampToEdge, bool dynamic)
-{
- AtlasType type = (dynamic ? DynamicAtlasType : StaticAtlasType);
- uint flags = (dynamic ? TextureAtlasInterface::DynamicFlag : 0);
+//SubTexture2DPtr TextureCache::insert(const TextureCache::Key &key, const QImage &image, bool clampToEdge, bool dynamic)
+//{
+// AtlasType type = (dynamic ? DynamicAtlasType : StaticAtlasType);
+// uint flags = (dynamic ? TextureAtlasInterface::DynamicFlag : 0);
- // Make sure that there is at least one texture atlas.
- if (textureCache.atlases[type].isEmpty())
- textureCache.atlases[type].append(qt_adaptation_layer()->createTextureAtlas(flags));
+// // Make sure that there is at least one texture atlas.
+// if (textureCache.atlases[type].isEmpty())
+// textureCache.atlases[type].append(qt_adaptation_layer()->createTextureAtlas(flags));
- // The texture atlas is used for many small images. If the image is somewhat big, create a separate texture for it.
- QSize size = textureCache.atlases[type].first()->texture()->size();
- if (image.width() > size.width() / 4 || image.height() > size.height() / 4) {
- QGLTexture2DPtr texture(new QGLTexture2D);
- texture->setImage(image);
- texture->setBindOptions(QGLContext::InternalBindOption);
- QGL::TextureWrap wrap = clampToEdge ? QGL::ClampToEdge : QGL::Repeat;
- texture->setVerticalWrap(wrap);
- texture->setHorizontalWrap(wrap);
- SubTexture2DPtr subtex(new SubTexture2D(texture.constCast<const QGLTexture2D>()));
- textureCache.textures.insert(key, subtex.toWeakRef());
- return subtex;
- }
+// // The texture atlas is used for many small images. If the image is somewhat big, create a separate texture for it.
+// QSize size = textureCache.atlases[type].first()->texture()->size();
+// if (image.width() > size.width() / 4 || image.height() > size.height() / 4) {
+// QGLTexture2DPtr texture(new QGLTexture2D);
+// texture->setImage(image);
+// texture->setBindOptions(QGLContext::InternalBindOption);
+// QGL::TextureWrap wrap = clampToEdge ? QGL::ClampToEdge : QGL::Repeat;
+// texture->setVerticalWrap(wrap);
+// texture->setHorizontalWrap(wrap);
+// SubTexture2DPtr subtex(new SubTexture2D(texture.constCast<const QGLTexture2D>()));
+// textureCache.textures.insert(key, subtex.toWeakRef());
+// return subtex;
+// }
- // Look for an atlas with room for the image.
- TextureAtlasInterface *atlas;
- QRect allocated;
- int i = 0;
- do {
- atlas = textureCache.atlases[type].at(i);
- allocated = atlas->allocate(image, clampToEdge);
- ++i;
- } while (i < textureCache.atlases[type].size() && allocated.isNull());
+// // Look for an atlas with room for the image.
+// TextureAtlasInterface *atlas;
+// QRect allocated;
+// int i = 0;
+// do {
+// atlas = textureCache.atlases[type].at(i);
+// allocated = atlas->allocate(image, clampToEdge);
+// ++i;
+// } while (i < textureCache.atlases[type].size() && allocated.isNull());
- // No room in the atlases, make a new atlas.
- if (allocated.isNull()) {
- atlas = qt_adaptation_layer()->createTextureAtlas(flags);
- textureCache.atlases[type].append(atlas);
- allocated = atlas->allocate(image, clampToEdge);
- }
+// // No room in the atlases, make a new atlas.
+// if (allocated.isNull()) {
+// atlas = qt_adaptation_layer()->createTextureAtlas(flags);
+// textureCache.atlases[type].append(atlas);
+// allocated = atlas->allocate(image, clampToEdge);
+// }
- // ### Need to add out-of-memory handling.
- Q_ASSERT(!allocated.isNull());
- SubTexture2DPtr subtex(new SubTexture2D(atlas, allocated));
- textureCache.textures.insert(key, subtex.toWeakRef());
- return subtex;
-}
+// // ### Need to add out-of-memory handling.
+// Q_ASSERT(!allocated.isNull());
+// SubTexture2DPtr subtex(new SubTexture2D(atlas, allocated));
+// textureCache.textures.insert(key, subtex.toWeakRef());
+// return subtex;
+//}
-SubTexture2DPtr Utilities::getTextureForImage(const QImage &image, bool clampToEdge, bool dynamic)
-{
- TextureCache::Key key = {image.cacheKey(), clampToEdge};
- TextureCache::Hash::const_iterator it = textureCache.textures.find(key);
- SubTexture2DPtr texture;
- if (it != textureCache.textures.end()) {
- texture = it.value().toStrongRef();
- if (!texture.isNull())
- return texture;
- }
- return textureCache.insert(key, image, clampToEdge, dynamic);
-}
+//SubTexture2DPtr Utilities::getTextureForImage(const QImage &image, bool clampToEdge, bool dynamic)
+//{
+// TextureCache::Key key = {image.cacheKey(), clampToEdge};
+// TextureCache::Hash::const_iterator it = textureCache.textures.find(key);
+// SubTexture2DPtr texture;
+// if (it != textureCache.textures.end()) {
+// texture = it.value().toStrongRef();
+// if (!texture.isNull())
+// return texture;
+// }
+// return textureCache.insert(key, image, clampToEdge, dynamic);
+//}
-SubTexture2DPtr Utilities::getTextureForPixmap(const QPixmap &pixmap, bool clampToEdge, bool dynamic)
-{
- TextureCache::Key key = {pixmap.cacheKey(), clampToEdge};
- TextureCache::Hash::const_iterator it = textureCache.textures.find(key);
- SubTexture2DPtr texture;
- if (it != textureCache.textures.end()) {
- texture = it.value().toStrongRef();
- if (!texture.isNull())
- return texture;
- }
- QImage image = pixmap.toImage();
- return textureCache.insert(key, image, clampToEdge, dynamic);
-}
+//SubTexture2DPtr Utilities::getTextureForPixmap(const QPixmap &pixmap, bool clampToEdge, bool dynamic)
+//{
+// TextureCache::Key key = {pixmap.cacheKey(), clampToEdge};
+// TextureCache::Hash::const_iterator it = textureCache.textures.find(key);
+// SubTexture2DPtr texture;
+// if (it != textureCache.textures.end()) {
+// texture = it.value().toStrongRef();
+// if (!texture.isNull())
+// return texture;
+// }
+// QImage image = pixmap.toImage();
+// return textureCache.insert(key, image, clampToEdge, dynamic);
+//}
diff --git a/src/scenegraph/convenience/utilities.h b/src/scenegraph/convenience/utilities.h
index d32a049..4e41556 100644
--- a/src/scenegraph/convenience/utilities.h
+++ b/src/scenegraph/convenience/utilities.h
@@ -63,32 +63,32 @@ class QSize;
class QFontEngine;
class QRectF;
-class SubTexture2D
-{
-public:
- SubTexture2D(TextureAtlasInterface *atlas, const QRect &allocatedRect);
- SubTexture2D(const QGLTexture2DConstPtr &texture);
- ~SubTexture2D();
+//class SubTexture2D
+//{
+//public:
+// SubTexture2D(TextureAtlasInterface *atlas, const QRect &allocatedRect);
+// SubTexture2D(const QGLTexture2DConstPtr &texture);
+// ~SubTexture2D();
- bool hasOwnTexture() const { return m_source.right() == 1; }
- bool isValid() const { return hasOwnTexture() || !m_allocated.isNull(); }
- QRectF sourceRect() const { return m_source; }
- QGLTexture2DConstPtr texture() const { return m_texture; }
-private:
- QRect m_allocated;
- QRectF m_source;
- TextureAtlasInterface *m_atlas;
- QGLTexture2DConstPtr m_texture;
-};
+// bool hasOwnTexture() const { return m_source.right() == 1; }
+// bool isValid() const { return hasOwnTexture() || !m_allocated.isNull(); }
+// QRectF sourceRect() const { return m_source; }
+// QGLTexture2DConstPtr texture() const { return m_texture; }
+//private:
+// QRect m_allocated;
+// QRectF m_source;
+// TextureAtlasInterface *m_atlas;
+// QGLTexture2DConstPtr m_texture;
+//};
-typedef QSharedPointer<const SubTexture2D> SubTexture2DConstPtr;
-typedef QSharedPointer<SubTexture2D> SubTexture2DPtr;
+//typedef QSharedPointer<const SubTexture2D> SubTexture2DConstPtr;
+//typedef QSharedPointer<SubTexture2D> SubTexture2DPtr;
class QT_SCENEGRAPH_EXPORT Utilities
{
public:
- static SubTexture2DPtr getTextureForImage(const QImage &image, bool clampToEdge, bool dynamic = true);
- static SubTexture2DPtr getTextureForPixmap(const QPixmap &pixmap, bool clampToEdge, bool dynamic = true);
+// static SubTexture2DPtr getTextureForImage(const QImage &image, bool clampToEdge, bool dynamic = true);
+// static SubTexture2DPtr getTextureForPixmap(const QPixmap &pixmap, bool clampToEdge, bool dynamic = true);
static void setupRectGeometry(Geometry *geometry, const QRectF &rect, const QSize &textureSize = QSize(), const QRectF &sourceRect = QRectF());
static QVector<QGLAttributeDescription> &getRectGeometryDescription();
diff --git a/src/scenegraph/coreapi/renderer.cpp b/src/scenegraph/coreapi/renderer.cpp
index f57fb11..7147d4c 100644
--- a/src/scenegraph/coreapi/renderer.cpp
+++ b/src/scenegraph/coreapi/renderer.cpp
@@ -43,6 +43,8 @@
#include "node.h"
#include "material.h"
+#include "adaptationlayer.h"
+
#include <qglattributevalue.h>
#include <QGLShaderProgram>
#include <qglframebufferobject.h>
@@ -109,6 +111,10 @@ void Renderer::renderScene(const Bindable &bindable)
if (!m_root_node)
return;
+ static int frameCounter;
+ ++frameCounter;
+ printf("\nFrame #%d\n", frameCounter);
+
initializeGLFunctions();
preprocess();
@@ -142,7 +148,7 @@ void Renderer::setClearColor(const QColor &color)
m_clear_color = color;
}
-void Renderer::setTexture(int unit, const QGLTexture2D *texture)
+void Renderer::setTexture(int unit, const TextureReference *texture)
{
if (unit < 0)
return;
@@ -152,7 +158,7 @@ void Renderer::setTexture(int unit, const QGLTexture2D *texture)
if (!texture) {
glBindTexture(GL_TEXTURE_2D, 0);
} else {
- const_cast<QGLTexture2D *>(texture)->bind();
+ glBindTexture(GL_TEXTURE_2D, texture->textureId());
}
if (unit != 0)
diff --git a/src/scenegraph/coreapi/renderer.h b/src/scenegraph/coreapi/renderer.h
index 80fa771..b62528e 100644
--- a/src/scenegraph/coreapi/renderer.h
+++ b/src/scenegraph/coreapi/renderer.h
@@ -58,6 +58,7 @@
class AbstractEffectProgram;
struct AbstractEffectType;
class QGLFramebufferObject;
+class TextureReference;
class Bindable
{
@@ -122,8 +123,8 @@ public:
void setClearColor(const QColor &color);
- void setTexture(int unit, const QGLTexture2D *texture);
- void setTexture(const QGLTexture2D *texture) { setTexture(0, texture); }
+ void setTexture(int unit, const TextureReference *texture);
+ void setTexture(const TextureReference *texture) { setTexture(0, texture); }
void renderScene();
void renderScene(const Bindable &bindable);
diff --git a/src/scenegraph/scenegraph.pri b/src/scenegraph/scenegraph.pri
index cde79fe..19c156b 100644
--- a/src/scenegraph/scenegraph.pri
+++ b/src/scenegraph/scenegraph.pri
@@ -18,23 +18,17 @@ SOURCES += $$PWD/coreapi/geometry.cpp \
# Convenience API
HEADERS += $$PWD/convenience/areaallocator.h \
- $$PWD/convenience/effectnode.h \
+ $$PWD/convenience/textnode.h \
$$PWD/convenience/flatcolormaterial.h \
- $$PWD/convenience/pixmapnode.h \
- $$PWD/convenience/quadnode.h \
$$PWD/convenience/solidrectnode.h \
- $$PWD/convenience/textnode.h \
$$PWD/convenience/texturematerial.h \
$$PWD/convenience/utilities.h \
$$PWD/convenience/vertexcolormaterial.h \
SOURCES += $$PWD/convenience/areaallocator.cpp \
- $$PWD/convenience/effectnode.cpp \
+ $$PWD/convenience/textnode.cpp \
$$PWD/convenience/flatcolormaterial.cpp \
- $$PWD/convenience/pixmapnode.cpp \
- $$PWD/convenience/quadnode.cpp \
$$PWD/convenience/solidrectnode.cpp \
- $$PWD/convenience/textnode.cpp \
$$PWD/convenience/texturematerial.cpp \
$$PWD/convenience/utilities.cpp \
$$PWD/convenience/vertexcolormaterial.cpp \