[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-droid.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/context.cpp
^
|
@@ -68,6 +68,10 @@
#include "renderer/overlaprenderer.h"
#endif
+#ifdef CUSTOMCONTEXT_SIMPLERENDERER
+#include "renderer/simplerenderer.h"
+#endif
+
#ifdef CUSTOMCONTEXT_MACTEXTURE
#include "mactexture.h"
#endif
@@ -281,22 +285,24 @@
}
-#ifdef CUSTOMCONTEXT_HYBRISTEXTURE
void Context::renderContextInitialized(QSGRenderContext *ctx)
{
+#if defined(CUSTOMCONTEXT_HYBRISTEXTURE)
// This check is delayed until there is an EGL display present.
m_hybrisTexture = qEnvironmentVariableIsEmpty("CUSTOMCONTEXT_NO_HYBRISTEXTURE");
if (m_hybrisTexture && strstr(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), "EGL_HYBRIS_native_buffer") == 0) {
qDebug() << "EGL_HYBRIS_native_buffer is not available...";
m_hybrisTexture = false;
}
+
#if defined(CUSTOMCONTEXT_DEBUG)
qDebug(" - EGL/Hybris based texture: %s", m_hybrisTexture ? "yes" : "no");
#endif
+#endif // CUSTOMCONTEXT_HYBRISTEXTURE
+
QSGContext::renderContextInitialized(ctx);
}
-#endif
@@ -497,6 +503,9 @@
return renderer;
}
#endif
+#ifdef CUSTOMCONTEXT_SIMPLERENDERER
+ return new QSGSimpleRenderer::Renderer(this);
+#endif
return CONTEXT_CLASS_BASE::createRenderer();
}
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/customcontext.pro
^
|
@@ -163,6 +163,14 @@
message("overlaprenderer ..........: no")
}
+simplerenderer:{
+ message("simplerenderer ...........: yes")
+ DEFINES += CUSTOMCONTEXT_SIMPLERENDERER
+ SOURCES += renderer/simplerenderer.cpp
+ HEADERS += renderer/simplerenderer.h renderer/qsgbasicshadermanager_p.h renderer/qsgbasicclipmanager_p.h
+} else {
+ message("simplerenderer ...........: no")
+}
############################################################
|
[-]
[+]
|
Added |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/renderer/qsgbasicclipmanager_p.h
^
|
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Sceneground Playground.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGBASICCLIPMANAGER_P_H
+#define QSGBASICCLIPMANAGER_P_H
+
+#include <private/qsgcontext_p.h>
+#include <private/qsgshadersourcebuilder_p.h>
+
+#include <QOpenGLShaderProgram>
+
+class QSGBasicClipManager : public QObject
+{
+ Q_OBJECT
+public:
+ enum ClipTypeBit
+ {
+ NoClip = 0x00,
+ ScissorClip = 0x01,
+ StencilClip = 0x02
+ };
+ Q_DECLARE_FLAGS(ClipType, ClipTypeBit)
+
+ QSGBasicClipManager(QSGRenderContext *context)
+ : QObject(context)
+ , m_program(0)
+ , m_currentStencilValue(0)
+ , m_clipMatrixId(0)
+ , m_clipType(NoClip)
+ {
+ connect(context, SIGNAL(invalidated()), this, SLOT(invalidate()));
+ }
+
+ static QSGBasicClipManager *from(QSGRenderContext *context)
+ {
+ const QString name = QStringLiteral("qsg_basic_clipmanager");
+ QSGBasicClipManager *cm = context->findChild<QSGBasicClipManager*>(name);
+ if (!cm) {
+ cm = new QSGBasicClipManager(context);
+ cm->setObjectName(name);
+ }
+ return cm;
+ }
+
+ void setDeviceRect(const QRect &deviceRect) { m_deviceRect = deviceRect; }
+ void setProjectionMatrix(const QMatrix4x4 &matrix) { m_projectionMatrix = matrix; }
+
+ template<typename ClipRenderer, typename ShaderStateTracker>
+ void activate(const QSGClipNode *clip, ClipRenderer *clipRenderer, ShaderStateTracker *tracker, QOpenGLFunctions *gl);
+
+ ClipType clipType() const { return m_clipType; }
+ const QSGClipNode *currentClip() const { return m_currentClip; }
+
+public Q_SLOTS:
+ void invalidate() {
+ delete m_program;
+ m_program = 0;
+ }
+
+private:
+ QOpenGLShaderProgram *m_program;
+ QRect m_currentScissorRect;
+ int m_currentStencilValue;
+ int m_clipMatrixId;
+ ClipType m_clipType;
+ const QSGClipNode *m_currentClip;
+
+ QRect m_deviceRect;
+ QMatrix4x4 m_projectionMatrix;
+};
+
+template <typename ClipRenderer, typename ShaderStateTracker>
+void QSGBasicClipManager::activate(const QSGClipNode *clip,
+ ClipRenderer *clipRenderer,
+ ShaderStateTracker *tracker,
+ QOpenGLFunctions *gl)
+{
+ if (m_currentClip == clip)
+ return;
+
+ m_clipType = NoClip;
+ m_currentClip = clip;
+ if (!clip) {
+ gl->glDisable(GL_STENCIL_TEST);
+ gl->glDisable(GL_SCISSOR_TEST);
+ return;
+ }
+
+ gl->glDisable(GL_SCISSOR_TEST);
+
+ m_currentStencilValue = 0;
+ m_currentScissorRect = QRect();
+
+ while (clip) {
+ QMatrix4x4 m = m_projectionMatrix;
+ if (clip->matrix())
+ m *= *clip->matrix();
+
+ bool isRectangleWithNoPerspective = clip->isRectangular()
+ && qFuzzyIsNull(m(3, 0)) && qFuzzyIsNull(m(3, 1));
+ bool noRotate = qFuzzyIsNull(m(0, 1)) && qFuzzyIsNull(m(1, 0));
+ bool isRotate90 = qFuzzyIsNull(m(0, 0)) && qFuzzyIsNull(m(1, 1));
+
+ if (isRectangleWithNoPerspective && (noRotate || isRotate90)) {
+ QRectF bbox = clip->clipRect();
+ qreal invW = 1 / m(3, 3);
+ qreal fx1, fy1, fx2, fy2;
+ if (noRotate) {
+ fx1 = (bbox.left() * m(0, 0) + m(0, 3)) * invW;
+ fy1 = (bbox.bottom() * m(1, 1) + m(1, 3)) * invW;
+ fx2 = (bbox.right() * m(0, 0) + m(0, 3)) * invW;
+ fy2 = (bbox.top() * m(1, 1) + m(1, 3)) * invW;
+ } else {
+ Q_ASSERT(isRotate90);
+ fx1 = (bbox.bottom() * m(0, 1) + m(0, 3)) * invW;
+ fy1 = (bbox.left() * m(1, 0) + m(1, 3)) * invW;
+ fx2 = (bbox.top() * m(0, 1) + m(0, 3)) * invW;
+ fy2 = (bbox.right() * m(1, 0) + m(1, 3)) * invW;
+ }
+
+ if (fx1 > fx2)
+ qSwap(fx1, fx2);
+ if (fy1 > fy2)
+ qSwap(fy1, fy2);
+
+ GLint ix1 = qRound((fx1 + 1) * m_deviceRect.width() * qreal(0.5));
+ GLint iy1 = qRound((fy1 + 1) * m_deviceRect.height() * qreal(0.5));
+ GLint ix2 = qRound((fx2 + 1) * m_deviceRect.width() * qreal(0.5));
+ GLint iy2 = qRound((fy2 + 1) * m_deviceRect.height() * qreal(0.5));
+
+ if (!(m_clipType & ScissorClip)) {
+ m_currentScissorRect = QRect(ix1, iy1, ix2 - ix1, iy2 - iy1);
+ gl->glEnable(GL_SCISSOR_TEST);
+ m_clipType |= ScissorClip;
+ } else {
+ m_currentScissorRect &= QRect(ix1, iy1, ix2 - ix1, iy2 - iy1);
+ }
+ gl->glScissor(m_currentScissorRect.x(), m_currentScissorRect.y(),
+ m_currentScissorRect.width(), m_currentScissorRect.height());
+ } else {
+
+ if (!(m_clipType & StencilClip)) {
+ tracker->deactivate();
+ if (!m_program) {
+ m_program = new QOpenGLShaderProgram();
+ QSGShaderSourceBuilder::initializeProgramFromFiles(
+ m_program,
+ QStringLiteral(":/scenegraph/shaders/stencilclip.vert"),
+ QStringLiteral(":/scenegraph/shaders/stencilclip.frag"));
+ m_program->bindAttributeLocation("vCoord", 0);
+ m_program->link();
+ m_clipMatrixId = m_program->uniformLocation("matrix");
+ }
+
+ gl->glClearStencil(0);
+ gl->glClear(GL_STENCIL_BUFFER_BIT);
+ gl->glEnable(GL_STENCIL_TEST);
+ gl->glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ gl->glDepthMask(GL_FALSE);
+
+ m_program->bind();
+ tracker->setEnabledVertexAttribArrays(1, gl);
+
+ m_clipType |= StencilClip;
+ }
+
+ gl->glStencilFunc(GL_EQUAL, m_currentStencilValue, 0xff); // stencil test, ref, test mask
+ gl->glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // stencil fail, z fail, z pass
+ m_program->setUniformValue(m_clipMatrixId, m);
|
[-]
[+]
|
Added |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/renderer/qsgbasicshadermanager_p.h
^
|
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Sceneground Playground.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGBASICSHADERMANAGER_P_H
+#define QSGBASICSHADERMANAGER_P_H
+
+#include <qsgmaterial.h>
+
+#include <private/qsgcontext_p.h>
+#include <private/qsgrenderer_p.h>
+
+class QSGBasicShaderManager : public QObject
+{
+ Q_OBJECT
+public:
+ QSGBasicShaderManager(QSGRenderContext *context)
+ : QObject(context)
+ , m_context(context)
+ , m_currentShader(0)
+ , m_currentMaterial(0)
+ , m_previousMaterial(0)
+ , m_currentAttributeCount(0)
+ {
+ connect(context, SIGNAL(invalidated()), this, SLOT(invalidate()));
+ }
+
+ static QSGBasicShaderManager *from(QSGRenderContext *context)
+ {
+ const QString name = QStringLiteral("qsg_basic_shadermanager");
+ QSGBasicShaderManager *sm = context->findChild<QSGBasicShaderManager *>(name);
+ if (!sm) {
+ sm = new QSGBasicShaderManager(context);
+ sm->setObjectName(name);
+ }
+ return sm;
+ }
+
+ QSGMaterialShader *prepare(const QSGMaterial *material)
+ {
+ Q_ASSERT(material);
+
+ QSGMaterialType *type = material->type();
+ QSGMaterialShader *shader = m_shaders.value(type);
+ if (shader)
+ return shader;
+
+ shader = static_cast<QSGMaterialShader *>(material->createShader());
+ m_context->compile(shader, const_cast<QSGMaterial *>(material));
+ m_context->initialize(shader);
+
+ m_shaders[type] = shader;
+
+ return shader;
+ }
+
+ static int countAttributes(QSGMaterialShader *shader)
+ {
+ const char * const *names = shader->attributeNames();
+ Q_ASSERT(names);
+ int count = 0;
+ while (names[count])
+ ++count;
+ return count;
+ }
+
+ void activate(const QSGMaterial *m, QSGMaterialShader::RenderState::DirtyStates states, QSGRenderer *renderer, QOpenGLFunctions *gl)
+ {
+ Q_ASSERT(m);
+ QSGMaterialShader *shader = prepare(m);
+ Q_ASSERT(shader);
+
+ m_previousMaterial = m_currentMaterial;
+ m_currentMaterial = m;
+
+ if (shader != m_currentShader) {
+ if (m_currentShader)
+ m_currentShader->deactivate();
+ m_currentShader = shader;
+ m_currentShader->program()->bind();
+ m_currentShader->activate();
+ m_previousMaterial = 0;
+ states |=(QSGMaterialShader::RenderState::DirtyOpacity | QSGMaterialShader::RenderState::DirtyMatrix);
+ setEnabledVertexAttribArrays(countAttributes(m_currentShader), gl);
+ }
+
+ m_currentShader->updateState(renderer->state(states),
+ const_cast<QSGMaterial *>(m_currentMaterial),
+ const_cast<QSGMaterial *>(m_previousMaterial));
+ }
+
+ void setEnabledVertexAttribArrays(int howMany, QOpenGLFunctions *gl) {
+ for (int i=m_currentAttributeCount; i<howMany; ++i)
+ gl->glEnableVertexAttribArray(i);
+ for (int i=m_currentAttributeCount-1; i>=howMany; --i)
+ gl->glDisableVertexAttribArray(i);
+ m_currentAttributeCount = howMany;
+ }
+
+ void deactivate() {
+ if (m_currentShader) {
+ m_currentShader->deactivate();
+ m_currentShader = 0;
+ }
+ m_previousMaterial = 0;
+ m_currentMaterial = 0;
+ }
+
+ QSGMaterialShader *currentShader() const { return m_currentShader; }
+ int currentAttributeCount() const { return m_currentAttributeCount; }
+
+ void endFrame(QOpenGLFunctions *gl) {
+ // Reset shader and potential shader state
+ if (m_currentShader) {
+ m_currentShader->deactivate();
+ m_currentShader = 0;
+ }
+ m_currentMaterial = 0;
+ m_previousMaterial = 0;
+ // Disable all attribute arrays.
+ while (m_currentAttributeCount > 0)
+ gl->glDisableVertexAttribArray(--m_currentAttributeCount);
+ }
+
+public Q_SLOTS:
+ void invalidate() {
+ qDeleteAll(m_shaders.values());
+ m_shaders.clear();
+ }
+
+private:
+ QHash<QSGMaterialType *, QSGMaterialShader *> m_shaders;
+ QSGRenderContext *m_context;
+
+ QSGMaterialShader *m_currentShader;
+ const QSGMaterial *m_currentMaterial;
+ const QSGMaterial *m_previousMaterial;
+ int m_currentAttributeCount;
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/renderer/simplerenderer.cpp
^
|
@@ -0,0 +1,555 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Sceneground Playground.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "simplerenderer.h"
+
+#include <private/qsgnodeupdater_p.h>
+
+#include <QtGui/QOpenGLFunctions_1_0>
+#include <QtGui/QOpenGLFunctions_3_2_Core>
+
+namespace QSGSimpleRenderer {
+
+#define QSGNODE_TRAVERSE(NODE) for (QSGNode *child = NODE->firstChild(); child; child = child->nextSibling())
+
+#define DECLARE_DEBUG_VAR(variable) \
+ static bool debug_ ## variable() \
+ { static bool value = qgetenv("QSG_RENDERER_DEBUG").contains(QT_STRINGIFY(variable)); return value; }
+DECLARE_DEBUG_VAR(build)
+DECLARE_DEBUG_VAR(change)
+DECLARE_DEBUG_VAR(render)
+DECLARE_DEBUG_VAR(nodepthbuffer)
+
+static inline int size_of_type(GLenum type)
+{
+ static int sizes[] = {
+ sizeof(char),
+ sizeof(unsigned char),
+ sizeof(short),
+ sizeof(unsigned short),
+ sizeof(int),
+ sizeof(unsigned int),
+ sizeof(float),
+ 2,
+ 3,
+ 4,
+ sizeof(double)
+ };
+ Q_ASSERT(type >= GL_BYTE && type <= 0x140A); // the value of GL_DOUBLE
+ return sizes[type - GL_BYTE];
+}
+
+
+class DummyUpdater : public QSGNodeUpdater
+{
+public:
+ void updateState(QSGNode *) { };
+};
+
+Renderer::Renderer(QSGRenderContext *ctx)
+ : QSGRenderer(ctx)
+ , m_renderList(16)
+ , m_vboData(1024)
+ , m_iboData(256)
+ , m_vboId(0)
+ , m_iboId(0)
+ , m_vboSize(0)
+ , m_iboSize(0)
+ , m_rebuild(true)
+{
+ m_shaderManager = QSGBasicShaderManager::from(ctx);
+ m_clipManager = QSGBasicClipManager::from(ctx);
+ m_useDepthBuffer = QOpenGLContext::currentContext()->format().depthBufferSize() > 0
+ && !debug_nodepthbuffer();
+
+ setNodeUpdater(new DummyUpdater());
+
+ initializeOpenGLFunctions();
+ glGenBuffers(1, &m_vboId);
+ glGenBuffers(1, &m_iboId);
+}
+
+Renderer::~Renderer()
+{
+ glDeleteBuffers(1, &m_vboId);
+ glDeleteBuffers(1, &m_iboId);
+}
+
+void Renderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state)
+{
+ if (Q_UNLIKELY(debug_change())) {
+ QDebug debug = qDebug();
+ debug << "dirty:";
+ if (state & QSGNode::DirtyGeometry)
+ debug << "Geometry";
+ if (state & QSGNode::DirtyMaterial)
+ debug << "Material";
+ if (state & QSGNode::DirtyMatrix)
+ debug << "Matrix";
+ if (state & QSGNode::DirtyNodeAdded)
+ debug << "Added";
+ if (state & QSGNode::DirtyNodeRemoved)
+ debug << "Removed";
+ if (state & QSGNode::DirtyOpacity)
+ debug << "Opacity";
+ if (state & QSGNode::DirtySubtreeBlocked)
+ debug << "SubtreeBlocked";
+ if (state & QSGNode::DirtyForceUpdate)
+ debug << "ForceUpdate";
+
+ // when removed, some parts of the node could already have been destroyed
+ // so don't debug it out.
+ if (state & QSGNode::DirtyNodeRemoved)
+ debug << (void *) node << node->type();
+ else
+ debug << node;
+ }
+
+ if (state & (QSGNode::DirtyNodeAdded
+ | QSGNode::DirtyNodeRemoved
+ | QSGNode::DirtySubtreeBlocked
+ | QSGNode::DirtyGeometry
+ | QSGNode::DirtyForceUpdate)) {
+ m_rebuild = true;
+ }
+ if (state & QSGNode::DirtyMatrix)
+ m_dirtyTransformNodes << node;
+ if (state & QSGNode::DirtyOpacity)
+ m_dirtyOpacityNodes << node;
+ if (state & QSGNode::DirtyMaterial)
+ m_dirtyOpaqueElements = true;
+
+ QSGRenderer::nodeChanged(node, state);
+}
+
+class BasicGeometryNode_Accessor : public QSGNode
+{
+public:
+ QSGGeometry *m_geometry;
+
+ int m_reserved_start_index;
+ int m_reserved_end_index;
+
+ const QMatrix4x4 *m_matrix;
+ const QSGClipNode *m_clip_list;
+};
+
+
+void Renderer::buildRenderList(QSGNode *node, QSGClipNode *clip)
+{
+ if (node->isSubtreeBlocked())
+ return;
+
+ if (node->type() == QSGNode::GeometryNodeType || node->type() == QSGNode::ClipNodeType) {
+ QSGBasicGeometryNode *gn = static_cast<QSGBasicGeometryNode *>(node);
+ QSGGeometry *g = gn->geometry();
+
+ Element e;
+ e.node = gn;
+
+ if (g->vertexCount() > 0) {
+ e.vboOffset = m_vboSize;
+ int vertexSize = g->sizeOfVertex() * g->vertexCount();
+ m_vboSize += vertexSize;
+ m_vboData.resize(m_vboSize);
+ memcpy(m_vboData.data() + e.vboOffset, g->vertexData(), vertexSize);
+ } else {
+ e.vboOffset = -1;
+ }
+
+ if (g->indexCount() > 0) {
+ e.iboOffset = m_iboSize;
+ int indexSize = g->sizeOfIndex() * g->indexCount();
+ m_iboSize += indexSize;
+ m_iboData.resize(m_iboSize);
+ memcpy(m_iboData.data() + e.iboOffset, g->indexData(), indexSize);
+ } else {
+ e.iboOffset = -1;
+ }
+
|
[-]
[+]
|
Added |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/renderer/simplerenderer.h
^
|
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Sceneground Playground.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** 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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGSIMPLERENDERER_H
+#define QSGSIMPLERENDERER_H
+
+#include <private/qdatabuffer_p.h>
+
+#include <private/qsgrenderer_p.h>
+#include <private/qsgcontext_p.h>
+
+#include <qbitarray.h>
+
+#include "qsgbasicshadermanager_p.h"
+#include "qsgbasicclipmanager_p.h"
+
+namespace QSGSimpleRenderer
+{
+
+struct Element {
+ QSGBasicGeometryNode *node;
+ qint32 vboOffset;
+ qint32 iboOffset;
+};
+
+class Renderer : public QSGRenderer, public QOpenGLFunctions
+{
+public:
+ Renderer(QSGRenderContext *context);
+ ~Renderer();
+
+ virtual void render();
+ virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) Q_DECL_OVERRIDE;
+
+ void buildRenderList(QSGNode *node, QSGClipNode *clip);
+ void updateMatrices(QSGNode *node, QSGTransformNode *xnode);
+ void updateOpacities(QSGNode *node, qreal opacity);
+ void renderElements();
+ void renderElement(int elementIndex);
+
+ QDataBuffer<Element> m_renderList;
+ QBitArray m_opaqueElements;
+ QDataBuffer<char> m_vboData;
+ QDataBuffer<char> m_iboData;
+
+ QSet<QSGNode *> m_dirtyTransformNodes;
+ QSet<QSGNode *> m_dirtyOpacityNodes;
+
+ QSGBasicShaderManager *m_shaderManager;
+ QSGBasicClipManager *m_clipManager;
+
+ GLuint m_vboId;
+ GLuint m_iboId;
+ int m_vboSize;
+ int m_iboSize;
+
+ bool m_rebuild;
+ bool m_useDepthBuffer;
+ bool m_dirtyOpaqueElements;
+};
+
+}
+
+#endif // QSGSIMPLERENDERER_H
|
[-]
[+]
|
Added |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/texture/drawhelper.h
^
|
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRAWHELPER_H
+#define DRAWHELPER_H
+
+// Taken from qdrawhelper_p.h
+static inline uint PREMUL(uint x) {
+ uint a = x >> 24;
+ uint t = (x & 0xff00ff) * a;
+ t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
+ t &= 0xff00ff;
+
+ x = ((x >> 8) & 0xff) * a;
+ x = (x + ((x >> 8) & 0xff) + 0x80);
+ x &= 0xff00;
+ x |= t | (a << 24);
+ return x;
+}
+static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/texture/eglgralloctexture.cpp
^
|
@@ -54,26 +54,13 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include "drawhelper.h"
+
// Taken from libhybris
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
-// Taken from qdrawhelper_p.h
-static inline uint PREMUL(uint x) {
- uint a = x >> 24;
- uint t = (x & 0xff00ff) * a;
- t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
- t &= 0xff00ff;
-
- x = ((x >> 8) & 0xff) * a;
- x = (x + ((x >> 8) & 0xff) + 0x80);
- x &= 0xff00;
- x |= t | (a << 24);
- return x;
-}
-static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
-
#ifndef QSG_NO_RENDER_TIMING
static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/texture/hybristexture.cpp
^
|
@@ -42,8 +42,6 @@
#include <QtCore/qdebug.h>
#include <QtCore/QCoreApplication>
-#include <QtGui/private/qdrawhelper_p.h>
-
#include "hybristexture.h"
#include <QtCore/QElapsedTimer>
@@ -53,6 +51,8 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
+#include "drawhelper.h"
+
#ifndef QSG_NO_RENDER_TIMING
static bool qsg_render_timing = !qgetenv("QSG_RENDER_TIMING").isEmpty();
static QElapsedTimer qsg_renderer_timer;
@@ -67,6 +67,7 @@
#define EGL_NATIVE_BUFFER_HYBRIS 0x3140
+
namespace CustomContext {
extern "C" {
@@ -271,11 +272,10 @@
return buffer;
}
-HybrisTexture::HybrisTexture(NativeBuffer *buffer)
+HybrisTexture::HybrisTexture(QSharedPointer<NativeBuffer> buffer)
: m_id(0)
, m_buffer(buffer)
, m_bound(false)
- , m_ownsBuffer(false)
{
Q_ASSERT(buffer);
#ifdef CUSTOMCONTEXT_DEBUG
@@ -287,8 +287,6 @@
{
if (m_id)
glDeleteTextures(1, &m_id);
- if (m_ownsBuffer)
- delete m_buffer;
}
void HybrisTexture::bind()
@@ -344,8 +342,7 @@
NativeBuffer *buffer = NativeBuffer::create(image);
if (!buffer)
return 0;
- HybrisTexture *texture = new HybrisTexture(buffer);
- texture->m_ownsBuffer = true;
+ HybrisTexture *texture = new HybrisTexture(QSharedPointer<NativeBuffer>(buffer));
return texture;
}
@@ -359,7 +356,6 @@
HybrisTextureFactory::~HybrisTextureFactory()
{
- delete m_buffer;
}
QSGTexture *HybrisTextureFactory::createTexture(QQuickWindow *) const
|
[-]
[+]
|
Changed |
_service:tar_git:qtscenegraph-adaptation-0.6.5.tar.bz2/customcontext/texture/hybristexture.h
^
|
@@ -44,6 +44,7 @@
#include <QtQuick/QSGTexture>
#include <QtQuick/QQuickTextureFactory>
+#include <QSharedPointer>
#include <QtGui/qopengl.h>
@@ -77,7 +78,7 @@
{
Q_OBJECT
public:
- HybrisTexture(NativeBuffer *buffer);
+ HybrisTexture(QSharedPointer<NativeBuffer> buffer);
~HybrisTexture();
virtual int textureId() const;
@@ -90,9 +91,8 @@
private:
mutable GLuint m_id;
- NativeBuffer *m_buffer;
+ QSharedPointer<NativeBuffer> m_buffer;
bool m_bound;
- bool m_ownsBuffer;
};
class HybrisTextureFactory : public QQuickTextureFactory
@@ -110,7 +110,7 @@
static HybrisTextureFactory *create(const QImage &image);
private:
- NativeBuffer *m_buffer;
+ QSharedPointer<NativeBuffer> m_buffer;
};
}
|