aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickitemrhiintegration/rhiitem_p.h
blob: 5fe2de8de01ede05ca27314ebb63dc22a32b340f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef RHIITEM_P_H
#define RHIITEM_P_H

#include "rhiitem.h"
#include <QSGSimpleTextureNode>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qsgplaintexture_p.h>

class RhiItemNode : public QSGTextureProvider, public QSGSimpleTextureNode
{
    Q_OBJECT

public:
    RhiItemNode(RhiItem *item);
    ~RhiItemNode();

    QSGTexture *texture() const override;

    void sync();
    bool isValid() const { return m_rhi && m_texture && m_sgWrapperTexture; }
    void scheduleUpdate();
    bool hasRenderer() const { return m_renderer; }
    void setRenderer(RhiItemRenderer *r) { m_renderer = r; }
    void setMirrorVertically(bool b);

private slots:
    void render();

private:
    void createNativeTexture();
    void releaseNativeTexture();

    RhiItem *m_item;
    QQuickWindow *m_window;
    QSize m_pixelSize;
    qreal m_dpr = 0.0f;
    QRhi *m_rhi = nullptr;
    QRhiTexture *m_texture = nullptr;
    QSGPlainTexture *m_sgWrapperTexture = nullptr;
    bool m_renderPending = true;
    RhiItemRenderer *m_renderer = nullptr;
};

class RhiItemPrivate : public QQuickItemPrivate
{
    Q_DECLARE_PUBLIC(RhiItem)
public:
    static RhiItemPrivate *get(RhiItem *item) { return item->d_func(); }
    mutable RhiItemNode *node = nullptr;
    int explicitTextureWidth = 0;
    int explicitTextureHeight = 0;
    bool blend = true;
    bool mirrorVertically = false;
    QSize effectiveTextureSize;
};

#endif