This file is indexed.

/usr/share/qt5/doc/qtquick/qtquick-rendercontrol-window-singlethreaded-cpp.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>window_singlethreaded.cpp Example File | Qt Quick 5.5</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
    <div class="main">
    <div class="main-rounded">
        <div class="navigationbar">
        <ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li><a href="qtquick-rendercontrol-example.html">QQuickRenderControl Example</a></li>
<li>window_singlethreaded.cpp Example File</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">window_singlethreaded.cpp Example File</h1>
<span class="subtitle">rendercontrol/window_singlethreaded.cpp</span>
<!-- $$$rendercontrol/window_singlethreaded.cpp-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp"><span class="comment">/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** &quot;Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
**   * Redistributions of source code must retain the above copyright
**     notice, this list of conditions and the following disclaimer.
**   * Redistributions in binary form must reproduce the above copyright
**     notice, this list of conditions and the following disclaimer in
**     the documentation and/or other materials provided with the
**     distribution.
**   * Neither the name of The Qt Company Ltd nor the names of its
**     contributors may be used to endorse or promote products derived
**     from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
**
** $QT_END_LICENSE$
**
****************************************************************************/</span>

<span class="preprocessor">#include &quot;window_singlethreaded.h&quot;</span>
<span class="preprocessor">#include &quot;cuberenderer.h&quot;</span>
<span class="preprocessor">#include &lt;QOpenGLContext&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLFunctions&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLFramebufferObject&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLShaderProgram&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLVertexArrayObject&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLBuffer&gt;</span>
<span class="preprocessor">#include &lt;QOpenGLVertexArrayObject&gt;</span>
<span class="preprocessor">#include &lt;QOffscreenSurface&gt;</span>
<span class="preprocessor">#include &lt;QScreen&gt;</span>
<span class="preprocessor">#include &lt;QQmlEngine&gt;</span>
<span class="preprocessor">#include &lt;QQmlComponent&gt;</span>
<span class="preprocessor">#include &lt;QQuickItem&gt;</span>
<span class="preprocessor">#include &lt;QQuickWindow&gt;</span>
<span class="preprocessor">#include &lt;QQuickRenderControl&gt;</span>
<span class="preprocessor">#include &lt;QCoreApplication&gt;</span>

<span class="keyword">class</span> RenderControl : <span class="keyword">public</span> <span class="type"><a href="qquickrendercontrol.html">QQuickRenderControl</a></span>
{
<span class="keyword">public</span>:
    RenderControl(<span class="type">QWindow</span> <span class="operator">*</span>w) : m_window(w) { }
    <span class="type">QWindow</span> <span class="operator">*</span>renderWindow(<span class="type">QPoint</span> <span class="operator">*</span>offset) Q_DECL_OVERRIDE;

<span class="keyword">private</span>:
    <span class="type">QWindow</span> <span class="operator">*</span>m_window;
};

<span class="type">QWindow</span> <span class="operator">*</span>RenderControl<span class="operator">::</span>renderWindow(<span class="type">QPoint</span> <span class="operator">*</span>offset)
{
    <span class="keyword">if</span> (offset)
        <span class="operator">*</span>offset <span class="operator">=</span> <span class="type">QPoint</span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
    <span class="keyword">return</span> m_window;
}

WindowSingleThreaded<span class="operator">::</span>WindowSingleThreaded()
    : m_rootItem(<span class="number">0</span>)<span class="operator">,</span>
      m_fbo(<span class="number">0</span>)<span class="operator">,</span>
      m_quickInitialized(<span class="keyword">false</span>)<span class="operator">,</span>
      m_quickReady(<span class="keyword">false</span>)<span class="operator">,</span>
      m_dpr(<span class="number">0</span>)
{
    setSurfaceType(<span class="type">QSurface</span><span class="operator">::</span>OpenGLSurface);

    <span class="type">QSurfaceFormat</span> format;
    <span class="comment">// Qt Quick may need a depth and stencil buffer. Always make sure these are available.</span>
    format<span class="operator">.</span>setDepthBufferSize(<span class="number">16</span>);
    format<span class="operator">.</span>setStencilBufferSize(<span class="number">8</span>);
    setFormat(format);

    m_context <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QOpenGLContext</span>;
    m_context<span class="operator">-</span><span class="operator">&gt;</span>setFormat(format);
    m_context<span class="operator">-</span><span class="operator">&gt;</span>create();

    m_offscreenSurface <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QOffscreenSurface</span>;
    <span class="comment">// Pass m_context-&gt;format(), not format. Format does not specify and color buffer</span>
    <span class="comment">// sizes, while the context, that has just been created, reports a format that has</span>
    <span class="comment">// these values filled in. Pass this to the offscreen surface to make sure it will be</span>
    <span class="comment">// compatible with the context's configuration.</span>
    m_offscreenSurface<span class="operator">-</span><span class="operator">&gt;</span>setFormat(m_context<span class="operator">-</span><span class="operator">&gt;</span>format());
    m_offscreenSurface<span class="operator">-</span><span class="operator">&gt;</span>create();

    m_cubeRenderer <span class="operator">=</span> <span class="keyword">new</span> CubeRenderer(m_offscreenSurface);

    m_renderControl <span class="operator">=</span> <span class="keyword">new</span> RenderControl(<span class="keyword">this</span>);

    <span class="comment">// Create a QQuickWindow that is associated with out render control. Note that this</span>
    <span class="comment">// window never gets created or shown, meaning that it will never get an underlying</span>
    <span class="comment">// native (platform) window.</span>
    m_quickWindow <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qquickwindow.html">QQuickWindow</a></span>(m_renderControl);

    <span class="comment">// Create a QML engine.</span>
    m_qmlEngine <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QQmlEngine</span>;
    <span class="keyword">if</span> (<span class="operator">!</span>m_qmlEngine<span class="operator">-</span><span class="operator">&gt;</span>incubationController())
        m_qmlEngine<span class="operator">-</span><span class="operator">&gt;</span>setIncubationController(m_quickWindow<span class="operator">-</span><span class="operator">&gt;</span>incubationController());

    <span class="comment">// When Quick says there is a need to render, we will not render immediately. Instead,</span>
    <span class="comment">// a timer with a small interval is used to get better performance.</span>
    m_updateTimer<span class="operator">.</span>setSingleShot(<span class="keyword">true</span>);
    m_updateTimer<span class="operator">.</span>setInterval(<span class="number">5</span>);
    connect(<span class="operator">&amp;</span>m_updateTimer<span class="operator">,</span> <span class="operator">&amp;</span><span class="type">QTimer</span><span class="operator">::</span>timeout<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>render);

    <span class="comment">// Now hook up the signals. For simplicy we don't differentiate between</span>
    <span class="comment">// renderRequested (only render is needed, no sync) and sceneChanged (polish and sync</span>
    <span class="comment">// is needed too).</span>
    connect(m_quickWindow<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qquickwindow.html">QQuickWindow</a></span><span class="operator">::</span>sceneGraphInitialized<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>createFbo);
    connect(m_quickWindow<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qquickwindow.html">QQuickWindow</a></span><span class="operator">::</span>sceneGraphInvalidated<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>destroyFbo);
    connect(m_renderControl<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qquickrendercontrol.html">QQuickRenderControl</a></span><span class="operator">::</span>renderRequested<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>requestUpdate);
    connect(m_renderControl<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="qquickrendercontrol.html">QQuickRenderControl</a></span><span class="operator">::</span>sceneChanged<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>requestUpdate);

    <span class="comment">// Just recreating the FBO on resize is not sufficient, when moving between screens</span>
    <span class="comment">// with different devicePixelRatio the QWindow size may remain the same but the FBO</span>
    <span class="comment">// dimension is to change regardless.</span>
    connect(<span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span><span class="type">QWindow</span><span class="operator">::</span>screenChanged<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>handleScreenChange);
}

WindowSingleThreaded<span class="operator">::</span><span class="operator">~</span>WindowSingleThreaded()
{
    <span class="comment">// Make sure the context is current while doing cleanup. Note that we use the</span>
    <span class="comment">// offscreen surface here because passing 'this' at this point is not safe: the</span>
    <span class="comment">// underlying platform window may already be destroyed. To avoid all the trouble, use</span>
    <span class="comment">// another surface that is valid for sure.</span>
    m_context<span class="operator">-</span><span class="operator">&gt;</span>makeCurrent(m_offscreenSurface);

    <span class="comment">// Delete the render control first since it will free the scenegraph resources.</span>
    <span class="comment">// Destroy the QQuickWindow only afterwards.</span>
    <span class="keyword">delete</span> m_renderControl;

    <span class="keyword">delete</span> m_qmlComponent;
    <span class="keyword">delete</span> m_quickWindow;
    <span class="keyword">delete</span> m_qmlEngine;
    <span class="keyword">delete</span> m_fbo;

    m_context<span class="operator">-</span><span class="operator">&gt;</span>doneCurrent();

    <span class="keyword">delete</span> m_cubeRenderer;

    <span class="keyword">delete</span> m_offscreenSurface;
    <span class="keyword">delete</span> m_context;
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>createFbo()
{
    <span class="comment">// The scene graph has been initialized. It is now time to create an FBO and associate</span>
    <span class="comment">// it with the QQuickWindow.</span>
    m_dpr <span class="operator">=</span> devicePixelRatio();
    m_fbo <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QOpenGLFramebufferObject</span>(size() <span class="operator">*</span> m_dpr<span class="operator">,</span> <span class="type">QOpenGLFramebufferObject</span><span class="operator">::</span>CombinedDepthStencil);
    m_quickWindow<span class="operator">-</span><span class="operator">&gt;</span>setRenderTarget(m_fbo);
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>destroyFbo()
{
    <span class="keyword">delete</span> m_fbo;
    m_fbo <span class="operator">=</span> <span class="number">0</span>;
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>render()
{
    <span class="keyword">if</span> (<span class="operator">!</span>m_context<span class="operator">-</span><span class="operator">&gt;</span>makeCurrent(m_offscreenSurface))
        <span class="keyword">return</span>;

    <span class="comment">// Polish, synchronize and render the next frame (into our fbo).  In this example</span>
    <span class="comment">// everything happens on the same thread and therefore all three steps are performed</span>
    <span class="comment">// in succession from here. In a threaded setup the render() call would happen on a</span>
    <span class="comment">// separate thread.</span>
    m_renderControl<span class="operator">-</span><span class="operator">&gt;</span>polishItems();
    m_renderControl<span class="operator">-</span><span class="operator">&gt;</span>sync();
    m_renderControl<span class="operator">-</span><span class="operator">&gt;</span>render();

    m_quickWindow<span class="operator">-</span><span class="operator">&gt;</span>resetOpenGLState();
    <span class="type">QOpenGLFramebufferObject</span><span class="operator">::</span>bindDefault();

    m_context<span class="operator">-</span><span class="operator">&gt;</span>functions()<span class="operator">-</span><span class="operator">&gt;</span>glFlush();

    m_quickReady <span class="operator">=</span> <span class="keyword">true</span>;

    <span class="comment">// Get something onto the screen.</span>
    m_cubeRenderer<span class="operator">-</span><span class="operator">&gt;</span>render(<span class="keyword">this</span><span class="operator">,</span> m_context<span class="operator">,</span> m_quickReady <span class="operator">?</span> m_fbo<span class="operator">-</span><span class="operator">&gt;</span>texture() : <span class="number">0</span>);
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>requestUpdate()
{
    <span class="keyword">if</span> (<span class="operator">!</span>m_updateTimer<span class="operator">.</span>isActive())
        m_updateTimer<span class="operator">.</span>start();
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>run()
{
    disconnect(m_qmlComponent<span class="operator">,</span> SIGNAL(statusChanged(<span class="type">QQmlComponent</span><span class="operator">::</span>Status))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(run()));

    <span class="keyword">if</span> (m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>isError()) {
        <span class="type">QList</span><span class="operator">&lt;</span><span class="type">QQmlError</span><span class="operator">&gt;</span> errorList <span class="operator">=</span> m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>errors();
        foreach (<span class="keyword">const</span> <span class="type">QQmlError</span> <span class="operator">&amp;</span>error<span class="operator">,</span> errorList)
            qWarning() <span class="operator">&lt;</span><span class="operator">&lt;</span> error<span class="operator">.</span>url() <span class="operator">&lt;</span><span class="operator">&lt;</span> error<span class="operator">.</span>line() <span class="operator">&lt;</span><span class="operator">&lt;</span> error;
        <span class="keyword">return</span>;
    }

    <span class="type">QObject</span> <span class="operator">*</span>rootObject <span class="operator">=</span> m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>create();
    <span class="keyword">if</span> (m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>isError()) {
        <span class="type">QList</span><span class="operator">&lt;</span><span class="type">QQmlError</span><span class="operator">&gt;</span> errorList <span class="operator">=</span> m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>errors();
        foreach (<span class="keyword">const</span> <span class="type">QQmlError</span> <span class="operator">&amp;</span>error<span class="operator">,</span> errorList)
            qWarning() <span class="operator">&lt;</span><span class="operator">&lt;</span> error<span class="operator">.</span>url() <span class="operator">&lt;</span><span class="operator">&lt;</span> error<span class="operator">.</span>line() <span class="operator">&lt;</span><span class="operator">&lt;</span> error;
        <span class="keyword">return</span>;
    }

    m_rootItem <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type"><a href="qquickitem.html">QQuickItem</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(rootObject);
    <span class="keyword">if</span> (<span class="operator">!</span>m_rootItem) {
        qWarning(<span class="string">&quot;run: Not a QQuickItem&quot;</span>);
        <span class="keyword">delete</span> rootObject;
        <span class="keyword">return</span>;
    }

    <span class="comment">// The root item is ready. Associate it with the window.</span>
    m_rootItem<span class="operator">-</span><span class="operator">&gt;</span>setParentItem(m_quickWindow<span class="operator">-</span><span class="operator">&gt;</span>contentItem());

    <span class="comment">// Update item and rendering related geometries.</span>
    updateSizes();

    <span class="comment">// Initialize the render control and our OpenGL resources.</span>
    m_context<span class="operator">-</span><span class="operator">&gt;</span>makeCurrent(m_offscreenSurface);
    m_renderControl<span class="operator">-</span><span class="operator">&gt;</span>initialize(m_context);
    m_quickInitialized <span class="operator">=</span> <span class="keyword">true</span>;
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>updateSizes()
{
    <span class="comment">// Behave like SizeRootObjectToView.</span>
    m_rootItem<span class="operator">-</span><span class="operator">&gt;</span>setWidth(width());
    m_rootItem<span class="operator">-</span><span class="operator">&gt;</span>setHeight(height());

    m_quickWindow<span class="operator">-</span><span class="operator">&gt;</span>setGeometry(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> width()<span class="operator">,</span> height());

    m_cubeRenderer<span class="operator">-</span><span class="operator">&gt;</span>resize(width()<span class="operator">,</span> height());
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>startQuick(<span class="keyword">const</span> <span class="type">QString</span> <span class="operator">&amp;</span>filename)
{
    m_qmlComponent <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QQmlComponent</span>(m_qmlEngine<span class="operator">,</span> <span class="type">QUrl</span>(filename));
    <span class="keyword">if</span> (m_qmlComponent<span class="operator">-</span><span class="operator">&gt;</span>isLoading())
        connect(m_qmlComponent<span class="operator">,</span> <span class="operator">&amp;</span><span class="type">QQmlComponent</span><span class="operator">::</span>statusChanged<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">&amp;</span>WindowSingleThreaded<span class="operator">::</span>run);
    <span class="keyword">else</span>
        run();
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>exposeEvent(<span class="type">QExposeEvent</span> <span class="operator">*</span>)
{
    <span class="keyword">if</span> (isExposed()) {
        m_cubeRenderer<span class="operator">-</span><span class="operator">&gt;</span>render(<span class="keyword">this</span><span class="operator">,</span> m_context<span class="operator">,</span> m_quickReady <span class="operator">?</span> m_fbo<span class="operator">-</span><span class="operator">&gt;</span>texture() : <span class="number">0</span>);
        <span class="keyword">if</span> (<span class="operator">!</span>m_quickInitialized)
            startQuick(<span class="type">QStringLiteral</span>(<span class="string">&quot;qrc:/rendercontrol/demo.qml&quot;</span>));
    }
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>resizeFbo()
{
    <span class="keyword">if</span> (m_rootItem <span class="operator">&amp;</span><span class="operator">&amp;</span> m_context<span class="operator">-</span><span class="operator">&gt;</span>makeCurrent(m_offscreenSurface)) {
        <span class="keyword">delete</span> m_fbo;
        createFbo();
        m_context<span class="operator">-</span><span class="operator">&gt;</span>doneCurrent();
        updateSizes();
        render();
    }
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>resizeEvent(<span class="type">QResizeEvent</span> <span class="operator">*</span>)
{
    <span class="comment">// If this is a resize after the scene is up and running, recreate the fbo and the</span>
    <span class="comment">// Quick item and scene.</span>
    <span class="keyword">if</span> (m_fbo <span class="operator">&amp;</span><span class="operator">&amp;</span> m_fbo<span class="operator">-</span><span class="operator">&gt;</span>size() <span class="operator">!</span><span class="operator">=</span> size() <span class="operator">*</span> devicePixelRatio())
        resizeFbo();
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>handleScreenChange()
{
    <span class="keyword">if</span> (m_dpr <span class="operator">!</span><span class="operator">=</span> devicePixelRatio())
        resizeFbo();
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>mousePressEvent(<span class="type">QMouseEvent</span> <span class="operator">*</span>e)
{
    <span class="comment">// Use the constructor taking localPos and screenPos. That puts localPos into the</span>
    <span class="comment">// event's localPos and windowPos, and screenPos into the event's screenPos. This way</span>
    <span class="comment">// the windowPos in e is ignored and is replaced by localPos. This is necessary</span>
    <span class="comment">// because QQuickWindow thinks of itself as a top-level window always.</span>
    <span class="type">QMouseEvent</span> mappedEvent(e<span class="operator">-</span><span class="operator">&gt;</span>type()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>localPos()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>screenPos()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>button()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>buttons()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>modifiers());
    <span class="type">QCoreApplication</span><span class="operator">::</span>sendEvent(m_quickWindow<span class="operator">,</span> <span class="operator">&amp;</span>mappedEvent);
}

<span class="type">void</span> WindowSingleThreaded<span class="operator">::</span>mouseReleaseEvent(<span class="type">QMouseEvent</span> <span class="operator">*</span>e)
{
    <span class="type">QMouseEvent</span> mappedEvent(e<span class="operator">-</span><span class="operator">&gt;</span>type()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>localPos()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>screenPos()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>button()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>buttons()<span class="operator">,</span> e<span class="operator">-</span><span class="operator">&gt;</span>modifiers());
    <span class="type">QCoreApplication</span><span class="operator">::</span>sendEvent(m_quickWindow<span class="operator">,</span> <span class="operator">&amp;</span>mappedEvent);
}</pre>
</div>
<!-- @@@rendercontrol/window_singlethreaded.cpp -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>