10 #include <QtCore/QObject>
11 #include <QtCore/QThread>
12 #include <QtCore/QWaitCondition>
13 #include <QtCore/QMutex>
14 #include <QtCore/QSize>
16 #include "TextureCache.h"
26 namespace hifi {
namespace qml {
28 class OffscreenSurface;
33 class RenderEventHandler;
35 class SharedObject :
public QObject {
38 friend class RenderEventHandler;
41 static void setSharedContext(QOpenGLContext* context);
42 static QOpenGLContext* getSharedContext();
43 static TextureCache& getTextureCache();
46 virtual ~SharedObject();
48 void create(OffscreenSurface* surface);
49 void setRootItem(QQuickItem* rootItem);
53 QSize getSize()
const;
54 void setSize(
const QSize& size);
55 void setMaxFps(uint8_t maxFps);
57 QQuickWindow* getWindow() {
return _quickWindow; }
58 QQuickItem* getRootItem() {
return _rootItem; }
59 QQmlContext* getContext() {
return _qmlContext; }
60 void setProxyWindow(QWindow* window);
64 bool isPaused()
const;
65 bool fetchTexture(TextureAndFence& textureAndFence);
66 void addToDeletionList(QObject*
object);
69 bool event(QEvent* e)
override;
71 bool preRender(
bool sceneGraphSync);
72 void shutdownRendering(
const QSize& size);
74 void initializeRenderControl(QOpenGLContext* context);
75 void releaseTextureAndFence();
76 void setRenderTarget(uint32_t fbo,
const QSize& size);
78 QQmlEngine* acquireEngine(OffscreenSurface* surface);
79 void releaseEngine(QQmlEngine* engine);
82 void requestRenderSync();
89 void updateTextureAndFence(
const TextureAndFence& newTextureAndFence);
91 QList<QPointer<QObject>> _deletionList;
94 TextureAndFence _latestTextureAndFence { 0, 0 };
95 QQuickItem* _rootItem {
nullptr };
96 QQuickWindow* _quickWindow {
nullptr };
97 QQmlContext* _qmlContext {
nullptr };
98 mutable QMutex _mutex;
102 QWindow* _proxyWindow {
nullptr };
103 RenderControl* _renderControl {
nullptr };
104 RenderEventHandler* _renderObject {
nullptr };
106 QTimer* _renderTimer {
nullptr };
107 QThread* _renderThread {
nullptr };
110 uint64_t _lastRenderTime { 0 };
111 QSize _size { 100, 100 };
112 uint8_t _maxFps { 60 };
114 bool _renderRequested {
false };
115 bool _syncRequested {
false };
116 bool _quit {
false };
117 bool _paused {
false };