Loading...
Searching...
No Matches
TextureSource.hpp
1#pragma once
2#if defined(SCORE_HAS_GPU_JS)
3#include <Gfx/GfxContext.hpp>
4#include <Gfx/TexturePort.hpp>
5
6#include <QPointer>
7#include <QQuickRhiItem>
8#include <QSGSimpleTextureNode>
9#include <QSGTexture>
10#include <QTimer>
11
12#include <private/qrhi_p.h>
13
14#include <memory>
15#include <verdigris>
16
17namespace Gfx
18{
19class DocumentPlugin;
20}
21
22namespace score::gfx
23{
24class Node;
25class PreviewNode;
26}
27
28namespace JS
29{
30
31class TextureSource : public QQuickRhiItem
32{
33 W_OBJECT(TextureSource)
34 QML_ELEMENT
35
36public:
37 explicit TextureSource(QQuickItem* parent = nullptr);
38 ~TextureSource();
39
40 // QML Properties
41 INLINE_PROPERTY_CREF(QString, process, = "", process, setProcess, processChanged)
42 INLINE_PROPERTY_CREF(QVariant, port, = "", port, setPort, portChanged)
43
44 QQuickRhiItemRenderer* createRenderer() override;
45
46protected:
47 void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
48 void componentComplete() override;
49 void releaseResources() override;
50
51 void handleWindowChanged(QQuickWindow* window);
52 void onRenderFrame();
53
54private:
55 friend class TextureSourceRenderer;
56 void rebuild();
57 bool connectToOutlet();
58 void disconnectFromOutlet();
59 QRhiTexture* extractTextureFromNode();
60
61 QPointer<Gfx::TextureOutlet> m_outlet{};
62 QPointer<Gfx::DocumentPlugin> m_gfxPlugin{};
63
64 // For texture extraction from the graph
65 bool m_isConnected = false;
66 int m_nodeId{};
67};
68
69}
70#endif
TreeNode< DeviceExplorerNode > Node
Definition DeviceNode.hpp:74
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:24
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12