aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi/qsggeometry.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsggeometry.h')
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h125
1 files changed, 67 insertions, 58 deletions
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index ae7b2f494c..00acb51c8a 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -51,30 +51,68 @@ class QSGGeometryData;
class Q_QUICK_EXPORT QSGGeometry
{
public:
+ enum AttributeType {
+ UnknownAttribute,
+ PositionAttribute,
+ ColorAttribute,
+ TexCoordAttribute,
+ TexCoord1Attribute,
+ TexCoord2Attribute
+ };
+
+ enum DataPattern {
+ AlwaysUploadPattern = 0,
+ StreamPattern = 1,
+ DynamicPattern = 2,
+ StaticPattern = 3
+ };
+
+ // Equivalents to GL_* drawing modes.
+ // Keep in sync with GL headers.
+ enum DrawingMode {
+ DrawPoints = 0x0000,
+ DrawLines = 0x0001,
+ DrawLineLoop = 0x0002,
+ DrawLineStrip = 0x0003,
+ DrawTriangles = 0x0004,
+ DrawTriangleStrip = 0x0005,
+ DrawTriangleFan = 0x0006
+ };
+
+ // Equivalents to GL_BYTE and similar type constants.
+ // Keep in sync with GL headers.
+ enum Type {
+ ByteType = 0x1400,
+ UnsignedByteType = 0x1401,
+ ShortType = 0x1402,
+ UnsignedShortType = 0x1403,
+ IntType = 0x1404,
+ UnsignedIntType = 0x1405,
+ FloatType = 0x1406,
+
+ TypeByte = ByteType,
+ TypeUnsignedByte = UnsignedByteType,
+ TypeShort = ShortType,
+ TypeUnsignedShort = UnsignedShortType,
+ TypeInt = IntType,
+ TypeUnsignedInt = UnsignedIntType,
+ TypeFloat = FloatType
+ };
struct Q_QUICK_EXPORT Attribute
{
- enum Semantic {
- UNKNOWN,
- POSITION,
- COLOR,
- TEXCOORD,
- TEXCOORD1,
- TEXCOORD2
- };
-
int position;
int tupleSize;
int type;
uint isVertexCoordinate : 1;
- Semantic semantic : 4;
+ AttributeType attributeType : 4;
uint reserved : 27;
static Attribute create(int pos, int tupleSize, int primitiveType, bool isPosition = false);
- static Attribute createWithSemantic(int pos, int tupleSize, int type, Semantic semantic);
+ static Attribute createWithAttributeType(int pos, int tupleSize, int primitiveType, AttributeType attributeType);
};
struct AttributeSet {
@@ -109,39 +147,10 @@ public:
static const AttributeSet &defaultAttributes_TexturedPoint2D();
static const AttributeSet &defaultAttributes_ColoredPoint2D();
- enum DataPattern {
- AlwaysUploadPattern = 0,
- StreamPattern = 1,
- DynamicPattern = 2,
- StaticPattern = 3
- };
-
- // Equivalents to GL_* drawing modes.
- enum DrawingMode {
- DrawPoints = 0x0000,
- DrawLines = 0x0001,
- DrawLineLoop = 0x0002,
- DrawLineStrip = 0x0003,
- DrawTriangles = 0x0004,
- DrawTriangleStrip = 0x0005,
- DrawTriangleFan = 0x0006
- };
-
- // Equivalents to GL_BYTE and similar type constants.
- enum Type {
- TypeByte = 0x1400,
- TypeUnsignedByte = 0x1401,
- TypeShort = 0x1402,
- TypeUnsignedShort = 0x1403,
- TypeInt = 0x1404,
- TypeUnsignedInt = 0x1405,
- TypeFloat = 0x1406
- };
-
QSGGeometry(const QSGGeometry::AttributeSet &attribs,
int vertexCount,
int indexCount = 0,
- int indexType = TypeUnsignedShort);
+ int indexType = UnsignedShortType);
virtual ~QSGGeometry();
// must use unsigned int to be compatible with the old GLenum to keep BC
@@ -223,25 +232,25 @@ private:
inline uint *QSGGeometry::indexDataAsUInt()
{
- Q_ASSERT(m_index_type == TypeUnsignedInt);
+ Q_ASSERT(m_index_type == UnsignedIntType);
return static_cast<uint *>(indexData());
}
inline quint16 *QSGGeometry::indexDataAsUShort()
{
- Q_ASSERT(m_index_type == TypeUnsignedShort);
+ Q_ASSERT(m_index_type == UnsignedShortType);
return static_cast<quint16 *>(indexData());
}
inline const uint *QSGGeometry::indexDataAsUInt() const
{
- Q_ASSERT(m_index_type == TypeUnsignedInt);
+ Q_ASSERT(m_index_type == UnsignedIntType);
return static_cast<const uint *>(indexData());
}
inline const quint16 *QSGGeometry::indexDataAsUShort() const
{
- Q_ASSERT(m_index_type == TypeUnsignedShort);
+ Q_ASSERT(m_index_type == UnsignedShortType);
return static_cast<const quint16 *>(indexData());
}
@@ -250,7 +259,7 @@ inline QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D()
Q_ASSERT(m_attributes.count == 1);
Q_ASSERT(m_attributes.stride == 2 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[0].position == 0);
return static_cast<Point2D *>(m_data);
}
@@ -261,10 +270,10 @@ inline QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D()
Q_ASSERT(m_attributes.stride == 4 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[1].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[1].type == FloatType);
return static_cast<TexturedPoint2D *>(m_data);
}
@@ -274,10 +283,10 @@ inline QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D()
Q_ASSERT(m_attributes.stride == 2 * sizeof(float) + 4 * sizeof(char));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 4);
- Q_ASSERT(m_attributes.attributes[1].type == TypeUnsignedByte);
+ Q_ASSERT(m_attributes.attributes[1].type == UnsignedByteType);
return static_cast<ColoredPoint2D *>(m_data);
}
@@ -286,7 +295,7 @@ inline const QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() const
Q_ASSERT(m_attributes.count == 1);
Q_ASSERT(m_attributes.stride == 2 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[0].position == 0);
return static_cast<const Point2D *>(m_data);
}
@@ -297,10 +306,10 @@ inline const QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoin
Q_ASSERT(m_attributes.stride == 4 * sizeof(float));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[1].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[1].type == FloatType);
return static_cast<const TexturedPoint2D *>(m_data);
}
@@ -310,18 +319,18 @@ inline const QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2
Q_ASSERT(m_attributes.stride == 2 * sizeof(float) + 4 * sizeof(char));
Q_ASSERT(m_attributes.attributes[0].position == 0);
Q_ASSERT(m_attributes.attributes[0].tupleSize == 2);
- Q_ASSERT(m_attributes.attributes[0].type == TypeFloat);
+ Q_ASSERT(m_attributes.attributes[0].type == FloatType);
Q_ASSERT(m_attributes.attributes[1].position == 1);
Q_ASSERT(m_attributes.attributes[1].tupleSize == 4);
- Q_ASSERT(m_attributes.attributes[1].type == TypeUnsignedByte);
+ Q_ASSERT(m_attributes.attributes[1].type == UnsignedByteType);
return static_cast<const ColoredPoint2D *>(m_data);
}
int QSGGeometry::sizeOfIndex() const
{
- if (m_index_type == TypeUnsignedShort) return 2;
- else if (m_index_type == TypeUnsignedByte) return 1;
- else if (m_index_type == TypeUnsignedInt) return 4;
+ if (m_index_type == UnsignedShortType) return 2;
+ else if (m_index_type == UnsignedByteType) return 1;
+ else if (m_index_type == UnsignedIntType) return 4;
return 0;
}