Krita Source Code Documentation
Loading...
Searching...
No Matches
KisProjectionLeaf Class Reference

#include <kis_projection_leaf.h>

+ Inheritance diagram for KisProjectionLeaf:

Public Types

enum  NodeDropReason { NodeAvailable , DropPassThroughMask , DropPassThroughClone }
 

Public Member Functions

bool accept (KisNodeVisitor &visitor)
 
bool canHaveChildLayers () const
 
QBitArray channelFlags () const
 
bool checkParentPassThrough ()
 
bool checkThisPassThrough ()
 
bool dependsOnLowerNodes () const
 
NodeDropReason dropReason () const
 
void explicitlyRegeneratePassThroughProjection ()
 
KisNodeSP findRoot () const
 
KisProjectionLeafSP firstChild () const
 
bool hasClones () const
 
bool isDroppedNode () const
 
bool isLayer () const
 
bool isMask () const
 
bool isOverlayProjectionLeaf () const
 
bool isRoot () const
 
bool isStillInGraph () const
 
bool isTemporaryHiddenFromRendering () const
 
bool isTopmostNode () const
 
 KisProjectionLeaf (KisNode *node)
 
KisProjectionLeafSP lastChild () const
 
KisPaintDeviceSP lazyDestinationForSubtreeComposition ()
 
KisProjectionLeafSP nextSibling () const
 
KisNodeSP node () const
 
quint8 opacity () const
 
KisPaintDeviceSP original ()
 
KisProjectionLeafSP overlayProjectionLeaf () const
 
KisProjectionLeafSP parent () const
 
KisProjectionLeafSP prevSibling () const
 
 Private (KisNode *_node)
 
KisPaintDeviceSP projection ()
 
KisAbstractProjectionPlaneSP projectionPlane () const
 
void setTemporaryHiddenFromRendering (bool value)
 
bool shouldBeRendered () const
 
void temporarySetPassThrough (bool value)
 
bool visible () const
 
virtual ~KisProjectionLeaf ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Static Public Member Functions

static bool checkPassThrough (const KisNode *node)
 
static bool isSelectionMask (const KisNode *node)
 
static KisNodeSP skipSelectionMasksBackward (KisNodeSP node)
 
static KisNodeSP skipSelectionMasksForward (KisNodeSP node)
 

Public Attributes

bool isTemporaryHidden = false
 
KisNodeWSP node
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 26 of file kis_projection_leaf.cpp.

Member Enumeration Documentation

◆ NodeDropReason

Enumerator
NodeAvailable 
DropPassThroughMask 
DropPassThroughClone 

Definition at line 59 of file kis_projection_leaf.h.

Constructor & Destructor Documentation

◆ KisProjectionLeaf()

KisProjectionLeaf::KisProjectionLeaf ( KisNode * node)

Definition at line 93 of file kis_projection_leaf.cpp.

94 : m_d(new Private(node))
95{
96}
const QScopedPointer< Private > m_d

◆ ~KisProjectionLeaf()

KisProjectionLeaf::~KisProjectionLeaf ( )
virtual

Definition at line 98 of file kis_projection_leaf.cpp.

99{
100}

Member Function Documentation

◆ accept()

bool KisProjectionLeaf::accept ( KisNodeVisitor & visitor)

Definition at line 233 of file kis_projection_leaf.cpp.

234{
235 return m_d->node->accept(visitor);
236}

References m_d.

◆ canHaveChildLayers()

bool KisProjectionLeaf::canHaveChildLayers ( ) const

Definition at line 271 of file kis_projection_leaf.cpp.

272{
273 return (bool)qobject_cast<const KisGroupLayer*>(m_d->node.data());
274}

References m_d.

◆ channelFlags()

QBitArray KisProjectionLeaf::channelFlags ( ) const

Definition at line 313 of file kis_projection_leaf.cpp.

314{
315 QBitArray channelFlags;
316
317 KisLayer *layer = qobject_cast<KisLayer*>(m_d->node.data());
318 if (!layer) return channelFlags;
319
320 channelFlags = layer->channelFlags();
321
322 if (m_d->checkParentPassThrough()) {
323 QBitArray parentChannelFlags;
324
325 if (*m_d->node->colorSpace() ==
326 *m_d->node->parent()->colorSpace()) {
327
328 KisLayer *parentLayer = qobject_cast<KisLayer*>(m_d->node->parent().data());
329 parentChannelFlags = parentLayer->channelFlags();
330 }
331
333 }
334
335 return channelFlags;
336}
QBitArray mergeChannelFlags(const QBitArray &childFlags, const QBitArray &parentFlags)
QBitArray channelFlags
Definition kis_layer.cc:167
QBitArray channelFlags() const

References KisLayer::channelFlags, channelFlags(), m_d, and KritaUtils::mergeChannelFlags().

◆ checkParentPassThrough()

bool KisProjectionLeaf::checkParentPassThrough ( )
inline

Definition at line 56 of file kis_projection_leaf.cpp.

56 {
57 return node->parent() && checkPassThrough(node->parent());
58 }
KisNodeWSP parent
Definition kis_node.cpp:86
static bool checkPassThrough(const KisNode *node)

References KisNode::parent.

◆ checkPassThrough()

static bool KisProjectionLeaf::checkPassThrough ( const KisNode * node)
inlinestatic

Definition at line 33 of file kis_projection_leaf.cpp.

33 {
34 const KisGroupLayer *group = qobject_cast<const KisGroupLayer*>(node);
35 return group && group->passThroughMode();
36 }

References KisGroupLayer::passThroughMode.

◆ checkThisPassThrough()

bool KisProjectionLeaf::checkThisPassThrough ( )
inline

Definition at line 60 of file kis_projection_leaf.cpp.

60 {
61 return checkPassThrough(node);
62 }

◆ dependsOnLowerNodes()

bool KisProjectionLeaf::dependsOnLowerNodes ( ) const

Definition at line 276 of file kis_projection_leaf.cpp.

277{
278 return (bool)qobject_cast<const KisAdjustmentLayer*>(m_d->node.data());
279}

References m_d.

◆ dropReason()

KisProjectionLeaf::NodeDropReason KisProjectionLeaf::dropReason ( ) const

Definition at line 359 of file kis_projection_leaf.cpp.

360{
361 if (qobject_cast<KisMask*>(m_d->node.data()) &&
362 m_d->checkParentPassThrough()) {
363
364 return DropPassThroughMask;
365 }
366
367 KisCloneLayer *cloneLayer = qobject_cast<KisCloneLayer*>(m_d->node.data());
368 if (cloneLayer && cloneLayer->copyFrom()) {
369 KisProjectionLeafSP leaf = cloneLayer->copyFrom()->projectionLeaf();
370
371 if (leaf->m_d->checkThisPassThrough()) {
373 }
374 }
375
376 return NodeAvailable;
377}
KisLayerSP copyFrom
KisProjectionLeafSP projectionLeaf
Definition kis_node.cpp:93

References KisCloneLayer::copyFrom, DropPassThroughClone, DropPassThroughMask, m_d, NodeAvailable, and KisNode::projectionLeaf.

◆ explicitlyRegeneratePassThroughProjection()

void KisProjectionLeaf::explicitlyRegeneratePassThroughProjection ( )

Regenerate projection of the current group layer iff it is pass-through mode.

WARNING: must be called either under the image lock held or in the context of an exclusive stroke job.

This method is rather slow and dangerous. It should be executes in exclusive environment only.

Definition at line 398 of file kis_projection_leaf.cpp.

399{
400 if (!m_d->checkThisPassThrough()) return;
401
402 m_d->temporarySetPassThrough(false);
403
404 const QRect updateRect = projection()->defaultBounds()->bounds();
405
406 KisRefreshSubtreeWalker walker(updateRect);
407 walker.collectRects(m_d->node, updateRect);
408
409 KisAsyncMerger merger;
410 merger.startMerge(walker);
411
412 m_d->temporarySetPassThrough(true);
413}
void startMerge(KisBaseRectsWalker &walker, bool notifyClones=true)
virtual QRect bounds() const =0
KisDefaultBoundsBaseSP defaultBounds() const
KisPaintDeviceSP projection()

References KisDefaultBoundsBase::bounds(), KisBaseRectsWalker::collectRects(), KisPaintDevice::defaultBounds(), m_d, projection(), and KisAsyncMerger::startMerge().

◆ findRoot()

KisNodeSP KisProjectionLeaf::findRoot ( ) const
inline

Definition at line 75 of file kis_projection_leaf.cpp.

75 {
76 KisNodeSP root = node;
77
78 while (root->parent()) {
79 root = root->parent();
80 }
81
82 return root;
83 }

References KisNode::parent.

◆ firstChild()

KisProjectionLeafSP KisProjectionLeaf::firstChild ( ) const

Definition at line 122 of file kis_projection_leaf.cpp.

123{
125
126 if (!m_d->checkThisPassThrough()) {
127 node = m_d->node->firstChild();
128 node = Private::skipSelectionMasksForward(node);
129 }
130
131 if (!node && isRoot()) {
132 KisProjectionLeafSP overlayLeaf = m_d->overlayProjectionLeaf();
133 if (overlayLeaf) {
134 return overlayLeaf;
135 }
136 }
137
139}
QSharedPointer< KisProjectionLeaf > KisProjectionLeafSP
Definition kis_types.h:292
KisNodeSP firstChild() const
Definition kis_node.cpp:361

References KisNode::firstChild(), isRoot(), m_d, node, and KisNode::projectionLeaf.

◆ hasClones()

bool KisProjectionLeaf::hasClones ( ) const

Definition at line 343 of file kis_projection_leaf.cpp.

344{
345 KisLayer *layer = qobject_cast<KisLayer*>(m_d->node.data());
346 return layer ? layer->hasClones() : false;
347}
bool hasClones() const
Definition kis_layer.cc:483

References KisLayer::hasClones(), and m_d.

◆ isDroppedNode()

bool KisProjectionLeaf::isDroppedNode ( ) const

Definition at line 349 of file kis_projection_leaf.cpp.

350{
351 return dropReason() != NodeAvailable;
352}
NodeDropReason dropReason() const

References dropReason(), and NodeAvailable.

◆ isLayer()

bool KisProjectionLeaf::isLayer ( ) const

Definition at line 259 of file kis_projection_leaf.cpp.

260{
261 return (bool)qobject_cast<const KisLayer*>(m_d->node.data()) &&
262 !m_d->node->isFakeNode();
263}

References m_d.

◆ isMask()

bool KisProjectionLeaf::isMask ( ) const

Definition at line 265 of file kis_projection_leaf.cpp.

266{
267 return (bool)qobject_cast<const KisMask*>(m_d->node.data()) &&
268 !m_d->node->isFakeNode();
269}

References m_d.

◆ isOverlayProjectionLeaf()

bool KisProjectionLeaf::isOverlayProjectionLeaf ( ) const

Definition at line 379 of file kis_projection_leaf.cpp.

380{
381 return this == m_d->overlayProjectionLeaf();
382}

References m_d.

◆ isRoot()

bool KisProjectionLeaf::isRoot ( ) const

Definition at line 254 of file kis_projection_leaf.cpp.

255{
256 return (bool)!m_d->node->parent();
257}

References m_d.

◆ isSelectionMask()

static bool KisProjectionLeaf::isSelectionMask ( const KisNode * node)
inlinestatic

Definition at line 38 of file kis_projection_leaf.cpp.

38 {
39 return qobject_cast<const KisSelectionMask*>(node);
40 }

◆ isStillInGraph()

bool KisProjectionLeaf::isStillInGraph ( ) const

Definition at line 338 of file kis_projection_leaf.cpp.

339{
340 return (bool)m_d->node->graphListener();
341}

References m_d.

◆ isTemporaryHiddenFromRendering()

bool KisProjectionLeaf::isTemporaryHiddenFromRendering ( ) const
See also
setTemporaryHiddenFromRendering

Definition at line 389 of file kis_projection_leaf.cpp.

390{
391 return m_d->isTemporaryHidden;
392}

References m_d.

◆ isTopmostNode()

bool KisProjectionLeaf::isTopmostNode ( ) const
inline

Definition at line 69 of file kis_projection_leaf.cpp.

69 {
71 node->parent() &&
72 !node->parent()->parent();
73 }
KisNodeSP nextSibling() const
Definition kis_node.cpp:408
static KisNodeSP skipSelectionMasksForward(KisNodeSP node)

References KisNode::nextSibling(), and KisNode::parent.

◆ lastChild()

KisProjectionLeafSP KisProjectionLeaf::lastChild ( ) const

Definition at line 141 of file kis_projection_leaf.cpp.

142{
144
145 if (isRoot()) {
146 KisProjectionLeafSP overlayLeaf = m_d->overlayProjectionLeaf();
147 if (overlayLeaf) {
148 return overlayLeaf;
149 }
150 }
151
152 if (!m_d->checkThisPassThrough()) {
153 node = m_d->node->lastChild();
154 node = Private::skipSelectionMasksBackward(node);
155 }
156
158}
KisNodeSP lastChild() const
Definition kis_node.cpp:367

References isRoot(), KisNode::lastChild(), m_d, node, and KisNode::projectionLeaf.

◆ lazyDestinationForSubtreeComposition()

KisPaintDeviceSP KisProjectionLeaf::lazyDestinationForSubtreeComposition ( )

Definition at line 248 of file kis_projection_leaf.cpp.

249{
250 const KisGroupLayer *group = qobject_cast<const KisGroupLayer*>(m_d->node.data());
251 return group ? group->lazyDestinationForSubtreeComposition() : nullptr;
252}
KisPaintDeviceSP lazyDestinationForSubtreeComposition() const

References KisGroupLayer::lazyDestinationForSubtreeComposition(), and m_d.

◆ nextSibling()

KisProjectionLeafSP KisProjectionLeaf::nextSibling ( ) const

Definition at line 196 of file kis_projection_leaf.cpp.

197{
198 if (Private::isSelectionMask(m_d->node)) {
199 return KisProjectionLeafSP();
200 }
201
202 KisProjectionLeafSP overlayLeaf = m_d->overlayProjectionLeaf();
203 if (overlayLeaf && m_d->isTopmostNode()) {
204 return overlayLeaf;
205 }
206
207 KisNodeSP node = m_d->node->nextSibling();
208 node = Private::skipSelectionMasksForward(node);
209
210 while (node && Private::checkPassThrough(node) && node->firstChild()) {
211 node = node->firstChild();
212 node = Private::skipSelectionMasksForward(node);
213 }
214
215 if (!node && m_d->checkParentPassThrough()) {
216 node = m_d->node->parent();
217 node = Private::skipSelectionMasksForward(node);
218 }
219
221}

References KisNode::firstChild(), m_d, KisNode::nextSibling(), node, KisNode::parent, and KisNode::projectionLeaf.

◆ node()

KisNodeSP KisProjectionLeaf::node ( ) const

◆ opacity()

quint8 KisProjectionLeaf::opacity ( ) const

Definition at line 300 of file kis_projection_leaf.cpp.

301{
302 quint8 resultOpacity = m_d->node->opacity();
303
304 if (m_d->checkParentPassThrough()) {
305 quint8 parentOpacity = m_d->node->parent()->projectionLeaf()->opacity();
306
307 resultOpacity = KritaUtils::mergeOpacityU8(resultOpacity, parentOpacity);
308 }
309
310 return resultOpacity;
311}
quint8 mergeOpacityU8(quint8 opacity, quint8 parentOpacity)

References m_d, KritaUtils::mergeOpacityU8(), and KisBaseNode::opacity().

◆ original()

KisPaintDeviceSP KisProjectionLeaf::original ( )

Definition at line 238 of file kis_projection_leaf.cpp.

239{
240 return m_d->node->original();
241}

References m_d.

◆ overlayProjectionLeaf()

KisProjectionLeafSP KisProjectionLeaf::overlayProjectionLeaf ( ) const
inline

Definition at line 64 of file kis_projection_leaf.cpp.

64 {
67 }
virtual KisNode * graphOverlayNode() const
KisNodeGraphListener * graphListener
Definition kis_node.cpp:87

References KisNode::graphListener, KisNodeGraphListener::graphOverlayNode(), and KisNode::projectionLeaf.

◆ parent()

KisProjectionLeafSP KisProjectionLeaf::parent ( ) const

Definition at line 102 of file kis_projection_leaf.cpp.

103{
105
106 if (Private::isSelectionMask(m_d->node)) {
107 if (m_d->overlayProjectionLeaf() == this) {
108 node = m_d->findRoot();
109 }
110 } else {
111 node = m_d->node->parent();
112 }
113
114 while (node && Private::checkPassThrough(node)) {
115 node = node->parent();
116 }
117
119}

References m_d, node, KisNode::parent, and KisNode::projectionLeaf.

◆ prevSibling()

KisProjectionLeafSP KisProjectionLeaf::prevSibling ( ) const

Definition at line 160 of file kis_projection_leaf.cpp.

161{
162 if (Private::isSelectionMask(m_d->node)) {
164
165 if (m_d->overlayProjectionLeaf() == this) {
166 KisNodeSP node = m_d->findRoot()->lastChild();
167 node = Private::skipSelectionMasksBackward(node);
168 leaf = node->projectionLeaf();
169 }
170
171 return leaf;
172 }
173
175
176 if (m_d->checkThisPassThrough()) {
177 node = m_d->node->lastChild();
178 node = Private::skipSelectionMasksBackward(node);
179 }
180
181 if (!node) {
182 node = m_d->node->prevSibling();
183 node = Private::skipSelectionMasksBackward(node);
184 }
185
186 const KisProjectionLeaf *leaf = this;
187 while (!node && leaf->m_d->checkParentPassThrough()) {
188 leaf = leaf->node()->parent()->projectionLeaf().data();
189 node = leaf->node()->prevSibling();
190 node = Private::skipSelectionMasksBackward(node);
191 }
192
194}
KisNodeSP prevSibling() const
Definition kis_node.cpp:402

References KisNode::lastChild(), m_d, node, KisNode::parent, KisNode::prevSibling(), and KisNode::projectionLeaf.

◆ Private()

KisProjectionLeaf::Private ( KisNode * _node)
inline

Definition at line 28 of file kis_projection_leaf.cpp.

28: node(_node) {}

◆ projection()

KisPaintDeviceSP KisProjectionLeaf::projection ( )

Definition at line 243 of file kis_projection_leaf.cpp.

244{
245 return m_d->node->projection();
246}

References m_d.

◆ projectionPlane()

KisAbstractProjectionPlaneSP KisProjectionLeaf::projectionPlane ( ) const

Definition at line 228 of file kis_projection_leaf.cpp.

229{
230 return m_d->node->projectionPlane();
231}

References m_d.

◆ setTemporaryHiddenFromRendering()

void KisProjectionLeaf::setTemporaryHiddenFromRendering ( bool value)

Temporarily exclude the projection leaf from rendering by making it invisible (KisProjectionLeaf::visible() == false).

This method is used by the tools that want to hide the original layer's content temporarily.

NOTE: the method is not thread-safe! The caller must guarantee exclusive access to the projection leaf himself.

Definition at line 384 of file kis_projection_leaf.cpp.

385{
386 m_d->isTemporaryHidden = value;
387}
float value(const T *src, size_t ch)

References m_d, and value().

◆ shouldBeRendered()

bool KisProjectionLeaf::shouldBeRendered ( ) const

A leaf can be renderable even when it is invisible, e.g. when it has clones (it should update data for clones)

Definition at line 354 of file kis_projection_leaf.cpp.

355{
356 return visible() || hasClones();
357}

References hasClones(), and visible().

◆ skipSelectionMasksBackward()

static KisNodeSP KisProjectionLeaf::skipSelectionMasksBackward ( KisNodeSP node)
inlinestatic

Definition at line 49 of file kis_projection_leaf.cpp.

49 {
50 while (node && isSelectionMask(node)) {
52 }
53 return node;
54 }
static bool isSelectionMask(const KisNode *node)

References isSelectionMask(), and KisNode::prevSibling().

◆ skipSelectionMasksForward()

static KisNodeSP KisProjectionLeaf::skipSelectionMasksForward ( KisNodeSP node)
inlinestatic

Definition at line 42 of file kis_projection_leaf.cpp.

42 {
43 while (node && isSelectionMask(node)) {
45 }
46 return node;
47 }

References isSelectionMask(), and KisNode::nextSibling().

◆ temporarySetPassThrough()

void KisProjectionLeaf::temporarySetPassThrough ( bool value)
inline

Definition at line 85 of file kis_projection_leaf.cpp.

85 {
86 KisGroupLayer *group = qobject_cast<KisGroupLayer*>(node.data());
87 if (!group) return;
88
90 }
void setPassThroughMode(bool value)

References KisWeakSharedPtr< T >::data(), KisGroupLayer::setPassThroughMode(), and value().

◆ visible()

bool KisProjectionLeaf::visible ( ) const

Definition at line 281 of file kis_projection_leaf.cpp.

282{
283 if (m_d->isTemporaryHidden || isDroppedNode()) return false;
284
285 // TODO: check opacity as well!
286
287 bool hiddenByParentPassThrough = false;
288
289 KisNodeSP node = m_d->node->parent();
290 while (node && node->projectionLeaf()->m_d->checkThisPassThrough()) {
291 hiddenByParentPassThrough |= !node->visible();
292 node = node->parent();
293 }
294
295 return (m_d->node->visible(false) || m_d->node->isIsolatedRoot()) &&
296 !m_d->checkThisPassThrough() &&
297 !hiddenByParentPassThrough;
298}
virtual bool visible(bool recursive=false) const

References isDroppedNode(), m_d, node, KisNode::parent, KisNode::projectionLeaf, and KisBaseNode::visible().

Member Data Documentation

◆ isTemporaryHidden

bool KisProjectionLeaf::isTemporaryHidden = false

Definition at line 31 of file kis_projection_leaf.cpp.

◆ m_d

const QScopedPointer<Private> KisProjectionLeaf::m_d
private

Definition at line 96 of file kis_projection_leaf.h.

◆ node

KisNodeSP KisProjectionLeaf::node

Definition at line 30 of file kis_projection_leaf.cpp.


The documentation for this class was generated from the following files: