krita/image

KisLayer Class Reference

Abstract class that represents the concept of a Layer in Krita. More...

#include <kis_layer.h>

Inheritance diagram for KisLayer:

List of all members.

Public Member Functions

 KisLayer (const KisLayer &rhs)
 KisLayer (KisImageWSP image, const QString &name, quint8 opacity)
virtual ~KisLayer ()
QRect changeRect (const QRect &rect) const
QBitArraychannelFlags () const
const KoColorSpacecolorSpace () const
const KoCompositeOp * compositeOp () const
virtual void copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const
QImage createThumbnail (qint32 w, qint32 h)
QList< KisEffectMaskSPeffectMasks () const
QRect exactBounds () const
QRect extent () const
bool hasEffectMasks () const
KisImageWSP image () const
KisMetaData::Store * metaData ()
virtual bool needProjection () const
virtual KisPaintDeviceSP original () const =0
KisLayerSP KDE_DEPRECATED parentLayer () const
KisEffectMaskSP previewMask () const
virtual KisPaintDeviceSP projection () const
void removePreviewMask ()
virtual
KoDocumentSectionModel::PropertyList 
sectionModelProperties () const
virtual KisSelectionSP selection () const
virtual KisSelectionMaskSP selectionMask () const
void setChannelFlags (const QBitArray &channelFlags)
void setDirty (const QRect &rect)
void setImage (KisImageWSP image)
void setPreviewMask (KisEffectMaskSP mask)
virtual void setSectionModelProperties (const KoDocumentSectionModel::PropertyList &properties)
void setTemporary (bool t)
void setX (qint32 x)
void setY (qint32 y)
bool temporary () const
virtual QRect updateProjection (const QRect &rect)
qint32 x () const
qint32 y () const

Protected Member Functions

QRect applyMasks (const KisPaintDeviceSP source, const KisPaintDeviceSP destination, const QRect &requestedRect) const
QRect masksChangeRect (const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
QRect masksNeedRect (const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const

Detailed Description

Abstract class that represents the concept of a Layer in Krita.

This is not related to the paint devices: this is merely an abstraction of how layers can be stacked and rendered differently. Regarding the previous-, first-, next- and lastChild() calls, first means that it the layer is at the top of the group in the layerlist, using next will iterate to the bottom to last, whereas previous will go up to first again.

TODO: Add a layer mode whereby the projection of the layer is used as a clipping path?

Definition at line 61 of file kis_layer.h.


Constructor & Destructor Documentation

KisLayer::KisLayer ( KisImageWSP  image,
const QString name,
quint8  opacity 
)

Definition at line 60 of file kis_layer.cc.

KisLayer::KisLayer ( const KisLayer rhs  ) 

Definition at line 70 of file kis_layer.cc.

KisLayer::~KisLayer (  )  [virtual]

Definition at line 80 of file kis_layer.cc.


Member Function Documentation

QRect KisLayer::applyMasks ( const KisPaintDeviceSP  source,
const KisPaintDeviceSP  destination,
const QRect requestedRect 
) const [protected]

A bit of optimization: All filters will read/write exactly from/to the requested rect so we needn't create temporary paint device, just apply it onto destination

We can't eliminate additional copy-op as filters' behaviour may be quite insane here, so let them work on their own paintDevice =)

Definition at line 272 of file kis_layer.cc.

QRect KisLayer::changeRect ( const QRect rect  )  const [virtual]

Some filters will cause a change of pixels those are outside a requested rect.

E.g. we change a rect of 2x2, then we want to apply a convolution filter with kernel 4x4 (changeRect is (2+2*3)x(2+2*3)=8x8) to that area. The rect that should be updated on the layer will be exaclty 8x8. More than that the needRect for that update will be 14x14. See needeRect.

Reimplemented from KisNode.

Reimplemented in KisAdjustmentLayer, and KisSelectionBasedLayer.

Definition at line 398 of file kis_layer.cc.

QBitArray & KisLayer::channelFlags (  )  const

Return a bit array where each bit indicates whether a particular channel is active or not.

If the channelflags bit array is empty, all channels are active.

Definition at line 130 of file kis_layer.cc.

const KoColorSpace * KisLayer::colorSpace (  )  const [virtual]

Implements KisBaseNode.

Reimplemented in KisGroupLayer, and KisPaintLayer.

Definition at line 86 of file kis_layer.cc.

const KoCompositeOp * KisLayer::compositeOp (  )  const [virtual]

Return the composite op associated with this layer.

FIXME: This function duplicates the same function from KisMask. We can't move it to KisBaseNode as it doesn't know anything about parent() method of KisNode Please think it over...

Implements KisBaseNode.

Definition at line 93 of file kis_layer.cc.

void KisLayer::copyOriginalToProjection ( const KisPaintDeviceSP  original,
KisPaintDeviceSP  projection,
const QRect rect 
) const [virtual]

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 383 of file kis_layer.cc.

QImage KisLayer::createThumbnail ( qint32  w,
qint32  h 
) [virtual]
Returns:
a thumbnail in requested size. The thumbnail is a rgba QImage and may have transparent parts. Returns a fully transparent QImage of the requested size if the current node type cannot generate a thumbnail. If the requested size is too big, return a null QImage.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionBasedLayer.

Definition at line 408 of file kis_layer.cc.

QList< KisEffectMaskSP > KisLayer::effectMasks (  )  const
Returns:
the list of effect masks

Definition at line 196 of file kis_layer.cc.

QRect KisLayer::exactBounds (  )  const [virtual]

Returns the exact bounds of where the actual data of this layer resides.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 445 of file kis_layer.cc.

QRect KisLayer::extent (  )  const [virtual]

Returns an approximation of where the bounds of actual data of this layer are.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 439 of file kis_layer.cc.

bool KisLayer::hasEffectMasks (  )  const

Returns true if there are any effect masks present.

Definition at line 214 of file kis_layer.cc.

KisImageWSP KisLayer::image (  )  const

Definition at line 145 of file kis_layer.cc.

QRect KisLayer::masksChangeRect ( const QList< KisEffectMaskSP > &  masks,
const QRect requestedRect,
bool &  rectVariesFlag 
) const [protected]
Parameters:
rectVariesFlag (out param) a flag, showing whether a rect varies from mask to mask
Returns:
an area that should be updated because of the change of of the layer

Definition at line 227 of file kis_layer.cc.

QRect KisLayer::masksNeedRect ( const QList< KisEffectMaskSP > &  masks,
const QRect changeRect,
QStack< QRect > &  applyRects,
bool &  rectVariesFlag 
) const [protected]

Get needRects for all masks.

Parameters:
changeRect requested rect to be updated on final projection. Should be a return value of masksChangedRect()
applyRects (out param) a stack of the rects where filters should be applied
rectVariesFlag (out param) a flag, showing whether a rect varies from mask to mask
Returns:
a needRect that should be prepared on the layer's paintDevice for all masks to succeed

Definition at line 248 of file kis_layer.cc.

KisMetaData::Store * KisLayer::metaData (  ) 
Returns:
the metadata object associated with this object.

Definition at line 473 of file kis_layer.cc.

bool KisLayer::needProjection (  )  const [virtual]

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 378 of file kis_layer.cc.

virtual KisPaintDeviceSP KisLayer::original (  )  const [pure virtual]

Return the layer data before the effect masks have had their go at it.

Reimplemented from KisBaseNode.

Implemented in KisCloneLayer, KisGroupLayer, KisPaintLayer, and KisSelectionBasedLayer.

KisLayerSP KisLayer::parentLayer (  )  const

XXX.

Definition at line 468 of file kis_layer.cc.

KisEffectMaskSP KisLayer::previewMask (  )  const

Retrieve the current preview effect mask.

Definition at line 458 of file kis_layer.cc.

KisPaintDeviceSP KisLayer::projection (  )  const [virtual]

Return the fully rendered representation of this layer: its data and its effect masks.

Reimplemented from KisBaseNode.

Definition at line 393 of file kis_layer.cc.

void KisLayer::removePreviewMask (  ) 

Remove the temporary effect mask.

Definition at line 463 of file kis_layer.cc.

KoDocumentSectionModel::PropertyList KisLayer::sectionModelProperties (  )  const [virtual]

Return a the properties of this base node (locked, visible etc, with the right icons for their representation and their state.

Subclasses can extend this list with new properties, like opacity for layers or visualized for masks.

The order of properties is, unfortunately, for now, important, so take care which properties superclasses of your class define.

KisBaseNode defines visible = 0, locked = 1 KisLayer defines opacity = 2, compositeOp = 3 KisMask defines active = 2 (KisMask does not inherit kislayer)

Reimplemented from KisBaseNode.

Reimplemented in KisGeneratorLayer, KisAdjustmentLayer, KisCloneLayer, and KisPaintLayer.

Definition at line 110 of file kis_layer.cc.

KisSelectionSP KisLayer::selection (  )  const [virtual]
Returns:
the selection contained in the first KisSelectionMask associated with this layer or the image, if either exists, otherwise, return 0.

Reimplemented in KisSelectionBasedLayer.

Definition at line 181 of file kis_layer.cc.

KisSelectionMaskSP KisLayer::selectionMask (  )  const [virtual]
Returns:
the selection associated with this layer, if there is one. Otherwise, return 0;

Definition at line 166 of file kis_layer.cc.

void KisLayer::setChannelFlags ( const QBitArray channelFlags  ) 

set the channelflags for this layer to the specified bit array.

The bit array must have exactly the same number of channels as the colorspace this layer is in, or be empty, in which case all channels are active.

Definition at line 124 of file kis_layer.cc.

void KisLayer::setDirty ( const QRect rect  )  [virtual]

Add the given rect to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node.

Reimplemented from KisNode.

Definition at line 161 of file kis_layer.cc.

void KisLayer::setImage ( KisImageWSP  image  ) 

Set the image this layer belongs to.

Reimplemented in KisGroupLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 150 of file kis_layer.cc.

void KisLayer::setPreviewMask ( KisEffectMaskSP  mask  ) 

Set a temporary effect mask on this layer for filter previews.

Definition at line 452 of file kis_layer.cc.

void KisLayer::setSectionModelProperties ( const KoDocumentSectionModel::PropertyList &  properties  )  [virtual]

Change the section model properties.

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer.

Definition at line 119 of file kis_layer.cc.

void KisLayer::setTemporary ( bool  t  ) 

Set to true if this layer should not appear in the layerbox, even though it is temporarily in the layer stack and taken into account on recomposition.

Definition at line 140 of file kis_layer.cc.

void KisLayer::setX ( qint32   )  [virtual]

Set the x offset of this layer in the image place.

Re-implement this where it makes sense, by default it does nothing.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisGroupLayer, and KisSelectionBasedLayer.

Definition at line 426 of file kis_layer.cc.

void KisLayer::setY ( qint32   )  [virtual]

Set the y offset of this layer in the image place.

Re-implement this where it makes sense, by default it does nothing.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisGroupLayer, and KisSelectionBasedLayer.

Definition at line 432 of file kis_layer.cc.

bool KisLayer::temporary (  )  const

Returns true if this layer is temporary: i.e., it should not appear in the layerbox, even though it is temporarily in the layer stack and taken into account on recomposition.

Definition at line 135 of file kis_layer.cc.

QRect KisLayer::updateProjection ( const QRect rect  )  [virtual]

Ask the layer to assemble its data & apply all the effect masks to it.

If it's needed to create a new projection paint device let's do it now! (content will be shared)

FIXME: else { m_d->projection = 0;}

Definition at line 340 of file kis_layer.cc.

qint32 KisLayer::x (  )  const [virtual]
Returns:
the x-offset of this layer in the image plane.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisGroupLayer, and KisSelectionBasedLayer.

Definition at line 416 of file kis_layer.cc.

qint32 KisLayer::y (  )  const [virtual]
Returns:
the y-offset of this layer in the image plane.

Reimplemented from KisBaseNode.

Reimplemented in KisCloneLayer, KisGroupLayer, and KisSelectionBasedLayer.

Definition at line 421 of file kis_layer.cc.


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