本文整理汇总了C++中QSGRenderContext类的典型用法代码示例。如果您正苦于以下问题:C++ QSGRenderContext类的具体用法?C++ QSGRenderContext怎么用?C++ QSGRenderContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSGRenderContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
void DesignerSupport::refFromEffectItem(QQuickItem *referencedItem, bool hide)
{
if (referencedItem == 0)
return;
QQuickItemPrivate::get(referencedItem)->refFromEffectItem(hide);
QQuickWindowPrivate::get(referencedItem->window())->updateDirtyNode(referencedItem);
Q_ASSERT(QQuickItemPrivate::get(referencedItem)->rootNode());
if (!m_itemTextureHash.contains(referencedItem)) {
QSGRenderContext *rc = QQuickWindowPrivate::get(referencedItem->window())->context;
QSGLayer *texture = rc->sceneGraphContext()->createLayer(rc);
texture->setLive(true);
texture->setItem(QQuickItemPrivate::get(referencedItem)->rootNode());
texture->setRect(referencedItem->boundingRect());
texture->setSize(referencedItem->boundingRect().size().toSize());
texture->setRecursive(true);
#ifndef QT_OPENGL_ES
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL)
texture->setFormat(GL_RGBA8);
else
texture->setFormat(GL_RGBA);
#else
texture->setFormat(GL_RGBA);
#endif
texture->setHasMipmaps(false);
m_itemTextureHash.insert(referencedItem, texture);
}
}
示例2: setUnicodeText
void setUnicodeText(const QString &text, const QFont &font, const QColor &color)
{
deleteContent();
QRawFont raw_font = QRawFont::fromFont(font, QFontDatabase::Latin);
qreal line_width = raw_font.averageCharWidth() * text.size();
QSGRenderContext *sgr = QQuickItemPrivate::get(m_owner)->sceneGraphRenderContext();
QTextLayout layout(text,font);
layout.beginLayout();
QTextLine line = layout.createLine();
line.setLineWidth(line_width);
//Q_ASSERT(!layout.createLine().isValid());
layout.endLayout();
QList<QGlyphRun> glyphRuns = line.glyphRuns();
qreal xpos = 0;
for (int i = 0; i < glyphRuns.size(); i++) {
QSGGlyphNode *node = sgr->sceneGraphContext()->createGlyphNode(sgr, false);
node->setOwnerElement(m_owner);
node->geometry()->setIndexDataPattern(QSGGeometry::StaticPattern);
node->geometry()->setVertexDataPattern(QSGGeometry::StaticPattern);
node->setGlyphs(QPointF(xpos, raw_font.ascent()), glyphRuns.at(i));
node->setStyle(QQuickText::Normal);
node->setColor(color);
xpos += raw_font.averageCharWidth() * glyphRuns.at(i).positions().size();
node->update();
appendChildNode(node);
}
}
示例3: setCursor
void QQuickTextNode::setCursor(const QRectF &rect, const QColor &color)
{
if (m_cursorNode != 0)
delete m_cursorNode;
QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
m_cursorNode = sg->sceneGraphContext()->createRectangleNode(rect, color);
appendChildNode(m_cursorNode);
}
示例4: addImage
void QQuickTextNode::addImage(const QRectF &rect, const QImage &image)
{
QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
QSGImageNode *node = sg->sceneGraphContext()->createImageNode();
QSGTexture *texture = sg->createTexture(image);
m_textures.append(texture);
node->setTargetRect(rect);
node->setInnerTargetRect(rect);
node->setTexture(texture);
appendChildNode(node);
node->update();
}
示例5: Q_D
void QQuickItemGrabResult::setup()
{
Q_D(QQuickItemGrabResult);
if (!d->item) {
disconnect(d->window.data(), &QQuickWindow::beforeSynchronizing, this, &QQuickItemGrabResult::setup);
disconnect(d->window.data(), &QQuickWindow::afterRendering, this, &QQuickItemGrabResult::render);
QCoreApplication::postEvent(this, new QEvent(Event_Grab_Completed));
return;
}
QSGRenderContext *rc = QQuickWindowPrivate::get(d->window.data())->context;
d->texture = rc->sceneGraphContext()->createLayer(rc);
d->texture->setItem(QQuickItemPrivate::get(d->item)->itemNode());
d->itemSize = QSizeF(d->item->width(), d->item->height());
}
示例6: setLatinText
void setLatinText(const QString &text, const QFont &font, const QColor &color) {
QRawFont raw_font = QRawFont::fromFont(font, QFontDatabase::Latin);
if (raw_font != m_raw_font) {
m_raw_font = raw_font;
m_positions.clear();
}
if (m_positions.size() < text.size()) {
qreal x_pos = 0;
qreal max_char_width = raw_font.averageCharWidth();
qreal ascent = raw_font.ascent();
if (m_positions.size())
x_pos = m_positions.last().x() + max_char_width;
int to_add = text.size() - m_positions.size();
for (int i = 0; i < to_add; i++) {
m_positions << QPointF(x_pos, ascent);
x_pos += max_char_width;
}
}
deleteContent();
QSGRenderContext *sgr = QQuickItemPrivate::get(m_owner)->sceneGraphRenderContext();
QSGGlyphNode *node = sgr->sceneGraphContext()->createGlyphNode(sgr, false);
node->setOwnerElement(m_owner);
node->geometry()->setIndexDataPattern(QSGGeometry::StaticPattern);
node->geometry()->setVertexDataPattern(QSGGeometry::StaticPattern);
node->setStyle(QQuickText::Normal);
node->setColor(color);
QGlyphRun glyphrun;
glyphrun.setRawFont(raw_font);
glyphrun.setGlyphIndexes(raw_font.glyphIndexesForString(text));
glyphrun.setPositions(m_positions);
node->setGlyphs(QPointF(0, raw_font.ascent()), glyphrun);
node->update();
appendChildNode(node);
}
示例7: Q_ASSERT
void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
{
Q_ASSERT(m_font.isValid());
setFlag(Blending, true);
QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
Q_ASSERT(ctx != 0);
// The following piece of code will read/write to the font engine's caches,
// potentially from different threads. However, this is safe because this
// code is only called from QQuickItem::updatePaintNode() which is called
// only when the GUI is blocked, and multiple threads will call it in
// sequence. See also QSGRenderContext::invalidate
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
if (QFontEngine *fontEngine = fontD->fontEngine) {
if (glyphFormat == QFontEngine::Format_None) {
glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
? fontEngine->glyphFormat
: QFontEngine::Format_A32;
}
qreal devicePixelRatio = ctx->surface()->surfaceClass() == QSurface::Window ?
static_cast<QWindow *>(ctx->surface())->devicePixelRatio() : ctx->screen()->devicePixelRatio();
QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
if (!fontEngine->supportsTransformation(glyphCacheTransform))
glyphCacheTransform = QTransform();
m_glyphCache = fontEngine->glyphCache(ctx, glyphFormat, glyphCacheTransform);
if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) {
m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform);
fontEngine->setGlyphCache(ctx, m_glyphCache.data());
QSGRenderContext *sg = QSGRenderContext::from(ctx);
Q_ASSERT(sg);
sg->registerFontengineForCleanup(fontEngine);
}
}
}
示例8: addRectangleNode
void QQuickTextNode::addRectangleNode(const QRectF &rect, const QColor &color)
{
QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
appendChildNode(sg->sceneGraphContext()->createRectangleNode(rect, color));
}