11QSGOpenVGRectangleNode::QSGOpenVGRectangleNode()
14 setMaterial((QSGMaterial*)1);
15 setGeometry((QSGGeometry*)1);
17 m_rectPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
18 VG_PATH_CAPABILITY_APPEND_TO);
19 m_rectPaint = vgCreatePaint();
67 vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
71 vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
76 vgClearPath(m_rectPath, VG_PATH_CAPABILITY_APPEND_TO);
80 static const VGubyte rectCommands[] = {
89 QVector<VGfloat> coordinates(5);
90 coordinates[0] = m_rect.x();
91 coordinates[1] = m_rect.y();
92 coordinates[2] = m_rect.width();
93 coordinates[3] = m_rect.height();
94 coordinates[4] = -m_rect.width();
96 vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData());
100 static const VGubyte rectCommands[] = {
108 QVector<VGfloat> coordinates(8);
109 const QPointF topLeft = transform().map(m_rect.topLeft());
110 const QPointF topRight = transform().map(m_rect.topRight());
111 const QPointF bottomLeft = transform().map(m_rect.bottomLeft());
112 const QPointF bottomRight = transform().map(m_rect.bottomRight());
113 coordinates[0] = bottomLeft.x();
114 coordinates[1] = bottomLeft.y();
115 coordinates[2] = bottomRight.x();
116 coordinates[3] = bottomRight.y();
117 coordinates[4] = topRight.x();
118 coordinates[5] = topRight.y();
119 coordinates[6] = topLeft.x();
120 coordinates[7] = topLeft.y();
122 vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData());
129 vgSetPaint(m_rectPaint, VG_FILL_PATH);
130 vgSetParameteri(m_rectPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
131 vgSetParameterfv(m_rectPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_color).constData());
133 m_paintDirty =
false;
136 vgSetPaint(m_rectPaint, VG_FILL_PATH);
137 vgDrawPath(m_rectPath, VG_FILL_PATH);
250 vgSetPaint(opacityPaint(), VG_FILL_PATH);
251 vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
253 vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
257 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
260 VGImage image =
static_cast<VGImage>(m_texture->comparisonKey());
263 if (m_transformMode != QSGImageNode::NoTransform) {
264 float translateX = 0.0f;
265 float translateY = 0.0f;
269 if (m_transformMode & QSGImageNode::MirrorHorizontally) {
270 translateX = m_rect.width();
274 if (m_transformMode & QSGImageNode::MirrorVertically) {
275 translateY = m_rect.height();
279 vgTranslate(translateX, translateY);
280 vgScale(scaleX, scaleY);
284 if (m_sourceRect == m_rect) {
288 float scaleX = m_rect.width() / m_sourceRect.width();
289 float scaleY = m_rect.height() / m_sourceRect.height();
290 vgScale(scaleX, scaleY);
291 VGImage subImage = vgChildImage(image, m_sourceRect.x(), m_sourceRect.y(), m_sourceRect.width(), m_sourceRect.height());
292 vgDrawImage(subImage);
293 vgDestroyImage(subImage);
356 vgSetPaint(opacityPaint(), VG_FILL_PATH);
357 vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
359 vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
363 vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
366 VGImage image =
static_cast<VGImage>(m_texture->comparisonKey());
369 QSGOpenVGHelpers::qDrawBorderImage(image, m_texture->textureSize(), m_bounds, m_bounds.marginsRemoved(m_margins), QRectF(0, 0, 1, 1));