summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/adaptationlayers/mactexturemanager.cpp1
-rw-r--r--src/canvas/qxgraphicsview.cpp4
-rw-r--r--src/graphicsitems/nodes/qxninepatchnode.cpp154
-rw-r--r--src/graphicsitems/qxborderimage.cpp2
4 files changed, 80 insertions, 81 deletions
diff --git a/src/adaptationlayers/mactexturemanager.cpp b/src/adaptationlayers/mactexturemanager.cpp
index 5e76a7b..43d019d 100644
--- a/src/adaptationlayers/mactexturemanager.cpp
+++ b/src/adaptationlayers/mactexturemanager.cpp
@@ -59,6 +59,7 @@ const TextureReference *QSGMacTextureManager::requestUploadedTexture(const QImag
texture->setTextureId(id);
texture->setTextureSize(image.size());
texture->setOwnsTexture(true);
+ texture->setAlphaChannel(image.hasAlphaChannel());
if (hints & TextureManager::SynchronousUploadHint) {
texture->setStatus(TextureReference::Uploaded);
diff --git a/src/canvas/qxgraphicsview.cpp b/src/canvas/qxgraphicsview.cpp
index caf7ca3..b3fe658 100644
--- a/src/canvas/qxgraphicsview.cpp
+++ b/src/canvas/qxgraphicsview.cpp
@@ -586,15 +586,13 @@ void QxGraphicsView::setSceneGraphContext(QSGContext *context)
void QxGraphicsView::showEvent(QShowEvent *e)
{
- printf("showEvent\n");
- initializeSceneGraph();
-
#ifdef Q_WS_QPA
QWidget::showEvent(e);
#else
QGLWidget::showEvent(e);
#endif
+ initializeSceneGraph();
}
/*!
diff --git a/src/graphicsitems/nodes/qxninepatchnode.cpp b/src/graphicsitems/nodes/qxninepatchnode.cpp
index 938d34f..7dbc858 100644
--- a/src/graphicsitems/nodes/qxninepatchnode.cpp
+++ b/src/graphicsitems/nodes/qxninepatchnode.cpp
@@ -103,82 +103,82 @@ void QxNinePatchNode::updateGeometry()
{
// ### Gunnar: port properly
-// Geometry *g = geometry();
-// if (g->isNull()) {
-// QVector<QGLAttributeDescription> desc;
-// desc << QGLAttributeDescription(QGL::Position, 2, GL_FLOAT, 5 * sizeof(float));
-// desc << QGLAttributeDescription(QGL::TextureCoord0, 2, GL_FLOAT, 5 * sizeof(float));
-// updateGeometryDescription(desc, GL_UNSIGNED_SHORT);
-// g->setVertexCount(6 * 6); // Grid of 6x6 vertices.
-// g->setIndexCount(5 * 5 * 6); // Grid of 5x5 cells, 2 triangles per cell.
-// g->setDrawingMode(QGL::Triangles);
-
-// ushort *indices = g->ushortIndexData();
-// int count = 0;
-// for (int i = 0; i < 5; ++i) {
-// int i6 = i * 6;
-// for (int j = 0; j < 5; ++j) {
-// indices[count++] = i6 + j + 0;
-// indices[count++] = i6 + j + 6;
-// indices[count++] = i6 + j + 7;
-// indices[count++] = i6 + j + 7;
-// indices[count++] = i6 + j + 1;
-// indices[count++] = i6 + j + 0;
-// }
-// }
-// }
-
-// struct V
-// {
-// V(float x, float y, float u, float v) : x(x), y(y), u(u), v(v) { }
-// float x, y, u, v;
-// };
-
-// 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() -
-// (texRect.width() - (m_innerRect.x() + m_innerRect.width()));
-// x[4] = x[3] - 0.5;
-// x[5] = m_targetRect.x() + m_targetRect.width();
-
-// y[0] = m_targetRect.y();
-// y[1] = m_targetRect.y() + m_innerRect.y();
-// y[2] = y[1] + 0.5;
-// y[3] = m_targetRect.y() + m_targetRect.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 = texRect.width();
-// qreal ph = texRect.height();
-
-// 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();
-// u[3] = src.left() + (m_innerRect.x() + m_innerRect.width()) / pw * src.width();
-// u[4] = u[3] - 0.5 / pw * src.width();
-// u[5] = src.right();
-
-// v[0] = src.top();
-// v[1] = src.top() + m_innerRect.y() / ph * src.height();
-// v[2] = v[1] + 0.5 / ph * src.height();
-// v[3] = src.top() + (m_innerRect.y() + m_innerRect.height()) / ph * src.height();
-// v[4] = v[3] - 0.5 / ph * src.height();
-// v[5] = src.bottom();
-
-// for (int i = 0; i < 6; ++i) {
-// for (int j = 0; j < 6; ++j)
-// vertices[i * 6 + j] = V(x[j], y[i], u[j], v[i]);
-// }
-
-// setBoundingRect(m_targetRect);
-// markDirty(Node::DirtyGeometry);
+ Geometry *g = geometry();
+ if (g->isNull()) {
+ QVector<QGLAttributeDescription> desc;
+ desc << QGLAttributeDescription(QGL::Position, 2, GL_FLOAT, 5 * sizeof(float));
+ desc << QGLAttributeDescription(QGL::TextureCoord0, 2, GL_FLOAT, 5 * sizeof(float));
+ updateGeometryDescription(desc, GL_UNSIGNED_SHORT);
+ g->setVertexCount(6 * 6); // Grid of 6x6 vertices.
+ g->setIndexCount(5 * 5 * 6); // Grid of 5x5 cells, 2 triangles per cell.
+ g->setDrawingMode(QGL::Triangles);
+
+ ushort *indices = g->ushortIndexData();
+ int count = 0;
+ for (int i = 0; i < 5; ++i) {
+ int i6 = i * 6;
+ for (int j = 0; j < 5; ++j) {
+ indices[count++] = i6 + j + 0;
+ indices[count++] = i6 + j + 6;
+ indices[count++] = i6 + j + 7;
+ indices[count++] = i6 + j + 7;
+ indices[count++] = i6 + j + 1;
+ indices[count++] = i6 + j + 0;
+ }
+ }
+ }
+
+ struct V
+ {
+ V(float x, float y, float u, float v) : x(x), y(y), u(u), v(v) { }
+ float x, y, u, v;
+ };
+
+ V *vertices = (V *)g->vertexData();
+
+ qreal x[6], y[6], u[6], v[6];
+ QRectF texRect = m_texture->subRect();
+
+ 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() -
+ (texRect.width() - (m_innerRect.x() + m_innerRect.width()));
+ x[4] = x[3] - 0.5;
+ x[5] = m_targetRect.x() + m_targetRect.width();
+
+ y[0] = m_targetRect.y();
+ y[1] = m_targetRect.y() + m_innerRect.y();
+ y[2] = y[1] + 0.5;
+ y[3] = m_targetRect.y() + m_targetRect.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 = texRect.width();
+ qreal ph = texRect.height();
+
+ 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();
+ u[3] = src.left() + (m_innerRect.x() + m_innerRect.width()) / pw * src.width();
+ u[4] = u[3] - 0.5 / pw * src.width();
+ u[5] = src.right();
+
+ v[0] = src.top();
+ v[1] = src.top() + m_innerRect.y() / ph * src.height();
+ v[2] = v[1] + 0.5 / ph * src.height();
+ v[3] = src.top() + (m_innerRect.y() + m_innerRect.height()) / ph * src.height();
+ v[4] = v[3] - 0.5 / ph * src.height();
+ v[5] = src.bottom();
+
+ for (int i = 0; i < 6; ++i) {
+ for (int j = 0; j < 6; ++j)
+ vertices[i * 6 + j] = V(x[j], y[i], u[j], v[i]);
+ }
+
+ setBoundingRect(m_targetRect);
+ markDirty(Node::DirtyGeometry);
}
diff --git a/src/graphicsitems/qxborderimage.cpp b/src/graphicsitems/qxborderimage.cpp
index c2af4e5..44e9411 100644
--- a/src/graphicsitems/qxborderimage.cpp
+++ b/src/graphicsitems/qxborderimage.cpp
@@ -340,7 +340,7 @@ void QxBorderImagePrivate::updatePixmap()
pix.height() - border->bottom() - border->top());
if (!texture) {
- texture = view->sceneGraphContext()->textureManager()->requestUploadedTexture(pix.pixmap().toImage(),
+ texture = QSGContext::current->textureManager()->requestUploadedTexture(pix.pixmap().toImage(),
TextureManager::SynchronousUploadHint);
} // ### gunnar: does not support changing images...