Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsgopenvgcontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
7#include "qsgopenvgtexture.h"
8#include "qsgopenvglayer.h"
12#if QT_CONFIG(quick_sprite)
13#include "qsgopenvgspritenode.h"
14#endif
15
16#include "qopenvgcontext_p.h"
17
18#include <private/qsgrenderer_p.h>
21
22// polish, animations, sync, render and swap in the render loop
23Q_LOGGING_CATEGORY(QSG_OPENVG_LOG_TIME_RENDERLOOP, "qt.scenegraph.time.renderloop")
24
26
29 , m_vgContext(nullptr)
30 , m_glyphCacheManager(nullptr)
31{
32
33}
34
36{
37 const InitParams *vgparams = static_cast<const InitParams *>(params);
38 if (vgparams->sType != INIT_PARAMS_MAGIC)
39 qFatal("Invalid OpenVG render context parameters");
40
41 m_vgContext = vgparams->context;
44}
45
47{
48 m_vgContext = nullptr;
49 delete m_glyphCacheManager;
50 m_glyphCacheManager = nullptr;
53}
54
59
61{
62 QImage tmp = image;
63
64 // Make sure image is not larger than maxTextureSize
65 int maxSize = maxTextureSize();
66 if (tmp.width() > maxSize || tmp.height() > maxSize) {
67 tmp = tmp.scaled(qMin(maxSize, tmp.width()), qMin(maxSize, tmp.height()), Qt::IgnoreAspectRatio, Qt::FastTransformation);
68 }
69
70 return new QSGOpenVGTexture(tmp, flags);
71}
72
77
82
87
92
97
103
104QSGGlyphNode *QSGOpenVGContext::createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode, int renderTypeQuality)
105{
106 Q_UNUSED(preferNativeGlyphNode);
107 Q_UNUSED(renderTypeQuality);
108 return new QSGOpenVGGlyphNode(rc);
109}
110
115
117{
118 return new QSGOpenVGLayer(renderContext);
119}
120
128
133
138
140{
141 VGint width = vgGeti(VG_MAX_IMAGE_WIDTH);
142 VGint height = vgGeti(VG_MAX_IMAGE_HEIGHT);
143
144 return qMin(width, height);
145}
146
147#if QT_CONFIG(quick_sprite)
148QSGSpriteNode *QSGOpenVGContext::createSpriteNode()
149{
150 return new QSGOpenVGSpriteNode();
151}
152#endif
153
155{
156 return static_cast<QSGOpenVGRenderContext *>(renderContext);
157}
158
163
168
169QSGRendererInterface::ShaderCompilationTypes QSGOpenVGRenderContext::shaderCompilationType() const
170{
171 return 0;
172}
173
174QSGRendererInterface::ShaderSourceTypes QSGOpenVGRenderContext::shaderSourceType() const
175{
176 return 0;
177}
178
180{
181 if (!m_glyphCacheManager)
182 m_glyphCacheManager = new QSGOpenVGFontGlyphCacheManager;
183
184 QSGOpenVGFontGlyphCache *cache = m_glyphCacheManager->cache(rawFont);
185 if (!cache) {
186 cache = new QSGOpenVGFontGlyphCache(m_glyphCacheManager, rawFont);
187 m_glyphCacheManager->insertCache(rawFont, cache);
188 }
189
190 return cache;
191}
192
\inmodule QtGui
Definition qimage.h:37
QImage scaled(int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qimage.h:209
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
The QSGContext holds the scene graph entry points for one QML engine.
The QSGImageNode class is provided for convenience to easily draw textured content using the QML scen...
\inmodule QtQuick
QSurfaceFormat defaultSurfaceFormat() const override
QSGNinePatchNode * createNinePatchNode() override
QSGRenderContext * createRenderContext() override
QSGGlyphNode * createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode, int renderTypeQuality) override
QSGOpenVGContext(QObject *parent=nullptr)
QSGLayer * createLayer(QSGRenderContext *renderContext) override
QSGInternalImageNode * createInternalImageNode(QSGRenderContext *renderContext) override
QSGImageNode * createImageNode() override
QSGInternalRectangleNode * createInternalRectangleNode() override
QSGRectangleNode * createRectangleNode() override
QSGPainterNode * createPainterNode(QQuickPaintedItem *item) override
QSGRendererInterface * rendererInterface(QSGRenderContext *renderContext) override
Returns a pointer to the (presumably) global renderer interface.
QSGOpenVGFontGlyphCache * cache(const QRawFont &font)
void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache)
ShaderSourceTypes shaderSourceType() const override
void renderNextFrame(QSGRenderer *renderer) override
int maxTextureSize() const override
static const int INIT_PARAMS_MAGIC
ShaderType shaderType() const override
GraphicsApi graphicsApi() const override
Returns the graphics API that is in use by the Qt Quick scenegraph.
void initialize(const QSGRenderContext::InitParams *params) override
ShaderCompilationTypes shaderCompilationType() const override
QSGRenderer * createRenderer(QSGRendererInterface::RenderMode renderMode=QSGRendererInterface::RenderMode2D) override
QSGTexture * createTexture(const QImage &image, uint flags) const override
QSGOpenVGFontGlyphCache * glyphCache(const QRawFont &rawFont)
The QSGRectangleNode class is a convenience class for drawing solid filled rectangles using scenegrap...
virtual void initialize(const InitParams *params)
virtual void invalidate()
An interface providing access to some of the graphics API specific internals of the scenegraph.
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
GraphicsApi
\value Unknown An unknown graphics API is in use \value Software The Qt Quick 2D Renderer is in use \...
ShaderType
\value UnknownShadingLanguage Not yet known due to no window and scenegraph associated \value GLSL GL...
The renderer class is the abstract baseclass used for rendering the QML scene graph.
\inmodule QtQuick
Definition qsgtexture.h:20
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static QSurfaceFormat defaultFormat()
Returns the global default surface format.
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
@ FastTransformation
@ IgnoreAspectRatio
Definition image.cpp:4
static void * context
#define qFatal
Definition qlogging.h:168
#define Q_LOGGING_CATEGORY(name,...)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLint GLsizei GLsizei height
GLint GLsizei width
GLbitfield flags
GLint GLsizei GLsizei GLenum format
void ** params
#define emit
#define Q_UNUSED(x)
unsigned int uint
Definition qtypes.h:34
QGraphicsItem * item
QSvgRenderer * renderer
[0]