Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsharedimage.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2021 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\qmlmodule Qt.labs.sharedimage
6
\title Qt Quick Shared Image Provider
7
\ingroup qmlmodules
8
\brief Adds an image provider which utilizes shared CPU memory.
9
10
\section2 Summary
11
12
This module provides functionality to save memory in use cases where
13
several Qt Quick applications use the same local image files. It does this
14
by placing the decoded QImage data in shared system memory, making it
15
accessible to all the processes (see QSharedMemory).
16
17
This module only shares CPU memory. It does not provide sharing of GPU
18
memory or textures.
19
20
\note Neither the sending nor the receiving process is authenticated.
21
This module should not be used in untrusted environments.
22
23
\section2 Usage
24
25
To use this module, import it like this:
26
\code
27
import Qt.labs.sharedimage
28
\endcode
29
30
The sharing functionality is provided through a QQuickImageProvider. Use
31
the "image:" scheme for the URL source of the image, followed by the
32
identifier \e shared, followed by the image file path. For example:
33
34
\code
35
Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }
36
\endcode
37
38
This will look for the file \e /usr/share/wallpapers/mybackground.jpg.
39
The first process that does this will read the image file
40
using normal Qt image loading. The decoded image data will then be placed
41
in shared memory, using the full file path as key. Later processes
42
requesting the same image will discover that the data is already available
43
in shared memory. They will then use that instead of loading the image file
44
again.
45
46
The shared image data will be kept available until the last process has deleted
47
its last reference to the shared image, at which point it is automatically released.
48
49
If system memory sharing is not available, the shared image provider falls
50
back to normal, unshared image loading.
51
52
The file path must be absolute. To use a relative path, make it absolute
53
using \e Qt.resolvedUrl() and replace the URL scheme. For example:
54
55
\code
56
...
57
property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
58
Image { source: imagePrefix + "myimage.png" }
59
\endcode
60
61
The shared image module does not provide any directly usable QML types.
62
*/
qtdeclarative
src
labs
sharedimage
doc
src
qsharedimage.qdoc
Generated on
for Qt by
1.16.1