28 QSGMaterial *newMaterial,
29 QSGMaterial *oldMaterial)
31 Q_ASSERT(!oldMaterial || newMaterial->type() == oldMaterial->type());
32 QSGFlatColorMaterial *oldMat =
static_cast<QSGFlatColorMaterial *>(oldMaterial);
33 QSGFlatColorMaterial *mat =
static_cast<QSGFlatColorMaterial *>(newMaterial);
35 QByteArray *buf = state.uniformData();
36 const int shaderMatrixCount = newMaterial->viewCount();
37 const int matrixCount = qMin(state.projectionMatrixCount(), shaderMatrixCount);
39 for (
int viewIndex = 0; viewIndex < matrixCount; ++viewIndex) {
40 if (state.isMatrixDirty()) {
41 const QMatrix4x4 m = state.combinedMatrix(viewIndex);
42 memcpy(buf->data() + 64 * viewIndex, m.constData(), 64);
47 const QColor &c = mat->color();
48 if (!oldMat || c != oldMat->color() || state.isOpacityDirty()) {
50 c.getRgbF(&r, &g, &b, &a);
51 const float opacity = state.opacity() * a;
52 QVector4D v(r * opacity, g * opacity, b * opacity, opacity);
53 Q_ASSERT(
sizeof(v) == 16);
54 memcpy(buf->data() + 64 * shaderMatrixCount, &v, 16);