1// Copyright (C) 2021 The Qt Company Ltd.
 
    2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
 
    5    \qmlmodule Qt.labs.sharedimage
 
    6    \title Qt Quick Shared Image Provider
 
    8    \brief Adds an image provider which utilizes shared CPU memory
 
   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).
 
   17    This module only shares CPU memory. It does not provide sharing of GPU
 
   22    To use this module, import it like this:
 
   24    import Qt.labs.sharedimage
 
   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:
 
   32    Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }
 
   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
 
   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.
 
   46    If system memory sharing is not available, the shared image provider falls
 
   47    back to normal, unshared image loading.
 
   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:
 
   54    property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
 
   55    Image { source: imagePrefix + "myimage.png" }
 
   58    The shared image module does not provide any directly usable QML types.