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
\section2 Usage
21
22
To use this module, import it like this:
23
\code
24
import Qt.labs.sharedimage
25
\endcode
26
27
The sharing functionality is provided through a QQuickImageProvider. Use
28
the "image:" scheme for the URL source of the image, followed by the
29
identifier \e shared, followed by the image file path. For example:
30
31
\code
32
Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }
33
\endcode
34
35
This will look for the file \e /usr/share/wallpapers/mybackground.jpg.
36
The first process that does this will read the image file
37
using normal Qt image loading. The decoded image data will then be placed
38
in shared memory, using the full file path as key. Later processes
39
requesting the same image will discover that the data is already available
40
in shared memory. They will then use that instead of loading the image file
41
again.
42
43
The shared image data will be kept available until the last process has deleted
44
its last reference to the shared image, at which point it is automatically released.
45
46
If system memory sharing is not available, the shared image provider falls
47
back to normal, unshared image loading.
48
49
The file path must be absolute. To use a relative path, make it absolute
50
using \e Qt.resolvedUrl() and replace the URL scheme. For example:
51
52
\code
53
...
54
property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
55
Image { source: imagePrefix + "myimage.png" }
56
\endcode
57
58
The shared image module does not provide any directly usable QML types.
59
*/
qtdeclarative
src
labs
sharedimage
doc
src
qsharedimage.qdoc
Generated on
for Qt by
1.14.0