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

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_PROJECTION_LEAF_H
0008 #define __KIS_PROJECTION_LEAF_H
0009 
0010 #include <QScopedPointer>
0011 
0012 #include "kis_types.h"
0013 #include "kritaimage_export.h"
0014 
0015 class KisNodeVisitor;
0016 
0017 
0018 class KRITAIMAGE_EXPORT KisProjectionLeaf
0019 {
0020 public:
0021     KisProjectionLeaf(KisNode *node);
0022     virtual ~KisProjectionLeaf();
0023 
0024     KisProjectionLeafSP parent() const;
0025 
0026     KisProjectionLeafSP firstChild() const;
0027     KisProjectionLeafSP lastChild() const;
0028 
0029     KisProjectionLeafSP prevSibling() const;
0030     KisProjectionLeafSP nextSibling() const;
0031 
0032     KisNodeSP node() const;
0033     KisAbstractProjectionPlaneSP projectionPlane() const;
0034     bool accept(KisNodeVisitor &visitor);
0035 
0036     KisPaintDeviceSP original();
0037     KisPaintDeviceSP projection();
0038     KisPaintDeviceSP lazyDestinationForSubtreeComposition();
0039 
0040     bool isRoot() const;
0041     bool isLayer() const;
0042     bool isMask() const;
0043     bool canHaveChildLayers() const;
0044     bool dependsOnLowerNodes() const;
0045     bool visible() const;
0046     quint8 opacity() const;
0047     QBitArray channelFlags() const;
0048     bool isStillInGraph() const;
0049     bool hasClones() const;
0050 
0051     bool isDroppedNode() const;
0052 
0053     /**
0054      * A leaf can be renderable even when it is invisible, e.g. when it has
0055      * clones (it should update data for clones)
0056      */
0057     bool shouldBeRendered() const;
0058 
0059     enum NodeDropReason {
0060         NodeAvailable,
0061         DropPassThroughMask,
0062         DropPassThroughClone
0063     };
0064     NodeDropReason dropReason() const;
0065 
0066     bool isOverlayProjectionLeaf() const;
0067 
0068     /**
0069      * Temporarily exclude the projection leaf from rendering by making
0070      * it invisible (KisProjectionLeaf::visible() == false).
0071      *
0072      * This method is used by the tools that want to hide the
0073      * original layer's content temporarily.
0074      *
0075      * NOTE: the method is not thread-safe! The caller must guarantee
0076      * exclusive access to the projection leaf himself.
0077      */
0078     void setTemporaryHiddenFromRendering(bool value);
0079 
0080     /**
0081      * \see setTemporaryHiddenFromRendering
0082      */
0083     bool isTemporaryHiddenFromRendering() const;
0084 
0085     /**
0086      * Regenerate projection of the current group layer iff it is
0087      * pass-through mode.
0088      *
0089      * WARNING: must be called either under the image lock held
0090      *          or in the context of an exclusive stroke job.
0091      */
0092     void explicitlyRegeneratePassThroughProjection();
0093 
0094 private:
0095     struct Private;
0096     const QScopedPointer<Private> m_d;
0097 };
0098 
0099 #endif /* __KIS_PROJECTION_LEAF_H */