| 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 | |
| 4 | #ifndef QSGSOFTWARECONTEXT_H |
| 5 | #define QSGSOFTWARECONTEXT_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <private/qsgcontext_p.h> |
| 19 | #include <private/qsgadaptationlayer_p.h> |
| 20 | #include "qsgrendererinterface.h" |
| 21 | |
| 22 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_RENDERLOOP) |
| 23 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_COMPILATION) |
| 24 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_TEXTURE) |
| 25 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_GLYPH) |
| 26 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_TIME_RENDERER) |
| 27 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_INFO) |
| 28 | Q_DECLARE_LOGGING_CATEGORY(QSG_RASTER_LOG_RENDERLOOP) |
| 29 | |
| 30 | QT_BEGIN_NAMESPACE |
| 31 | |
| 32 | class QSGSoftwareRenderContext : public QSGRenderContext |
| 33 | { |
| 34 | Q_OBJECT |
| 35 | public: |
| 36 | QSGSoftwareRenderContext(QSGContext *ctx); |
| 37 | void initializeIfNeeded(); |
| 38 | void invalidate() override; |
| 39 | void renderNextFrame(QSGRenderer *renderer) override; |
| 40 | QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const override; |
| 41 | QSGRenderer *createRenderer(QSGRendererInterface::RenderMode) override; |
| 42 | int maxTextureSize() const override; |
| 43 | |
| 44 | bool m_initialized; |
| 45 | QPainter *m_activePainter; |
| 46 | }; |
| 47 | |
| 48 | class QSGSoftwareContext : public QSGContext, public QSGRendererInterface |
| 49 | { |
| 50 | Q_OBJECT |
| 51 | public: |
| 52 | explicit QSGSoftwareContext(QObject *parent = nullptr); |
| 53 | |
| 54 | QSGRenderContext *createRenderContext() override { return new QSGSoftwareRenderContext(this); } |
| 55 | QSGInternalRectangleNode *createInternalRectangleNode() override; |
| 56 | QSGInternalImageNode *createInternalImageNode(QSGRenderContext *renderContext) override; |
| 57 | QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override; |
| 58 | QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality) override; |
| 59 | QSGLayer *createLayer(QSGRenderContext *renderContext) override; |
| 60 | QSurfaceFormat defaultSurfaceFormat() const override; |
| 61 | QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override; |
| 62 | QSGRectangleNode *createRectangleNode() override; |
| 63 | QSGImageNode *createImageNode() override; |
| 64 | QSGNinePatchNode *createNinePatchNode() override; |
| 65 | #if QT_CONFIG(quick_sprite) |
| 66 | QSGSpriteNode *createSpriteNode() override; |
| 67 | #endif |
| 68 | |
| 69 | GraphicsApi graphicsApi() const override; |
| 70 | ShaderType shaderType() const override; |
| 71 | ShaderCompilationTypes shaderCompilationType() const override; |
| 72 | ShaderSourceTypes shaderSourceType() const override; |
| 73 | void *getResource(QQuickWindow *window, Resource resource) const override; |
| 74 | }; |
| 75 | |
| 76 | QT_END_NAMESPACE |
| 77 | |
| 78 | #endif // QSGSOFTWARECONTEXT_H |
| 79 |
