File indexing completed on 2024-05-12 15:58:09

0001 /* SPDX-FileCopyrightText: 2009 Dmitry Kazakov <dimula73@gmail.com>
0002  *
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #ifndef __KIS_ASYNC_MERGER_H
0007 #define __KIS_ASYNC_MERGER_H
0008 
0009 #include "kritaimage_export.h"
0010 #include "kis_types.h"
0011 
0012 class QRect;
0013 class KisBaseRectsWalker;
0014 
0015 class KRITAIMAGE_EXPORT KisAsyncMerger
0016 {
0017 public:
0018     void startMerge(KisBaseRectsWalker &walker, bool notifyClones = true);
0019 
0020 private:
0021     inline void resetProjection();
0022     inline void setupProjection(KisProjectionLeafSP currentLeaf, const QRect& rect, bool useTempProjection);
0023     inline void writeProjection(KisProjectionLeafSP topmostLeaf, bool useTempProjection, const QRect &rect);
0024     inline bool compositeWithProjection(KisProjectionLeafSP leaf, const QRect &rect);
0025     inline void doNotifyClones(KisBaseRectsWalker &walker);
0026 
0027 private:
0028     /**
0029      * The place where intermediate results of layer's merge
0030      * are going. It may be equal to m_finalProjection. In
0031      * this case the projection will be written directly to
0032      * the original of the parent layer
0033      */
0034     KisPaintDeviceSP m_currentProjection;
0035 
0036     /**
0037      * The final destination of every projection of all
0038      * the layers. It is equal to the original of a parental
0039      * node.
0040      * NOTE: This pointer is cached here to avoid
0041      *       race conditions
0042      */
0043     KisPaintDeviceSP m_finalProjection;
0044 
0045     /**
0046      * Creation of the paint device is quite expensive, so we'll just
0047      * save the pointer to our temporary device here and will get it when
0048      * needed. This variable must not be used anywhere out of
0049      * setupProjection()
0050      */
0051     KisPaintDeviceSP m_cachedPaintDevice;
0052 };
0053 
0054 
0055 #endif /* __KIS_ASYNC_MERGER_H */
0056