File indexing completed on 2024-05-12 15:58:07
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_ABSTRACT_PROJECTION_PLANE_H 0008 #define __KIS_ABSTRACT_PROJECTION_PLANE_H 0009 0010 #include "kis_types.h" 0011 #include "kis_layer.h" 0012 0013 class QRect; 0014 class KisPainter; 0015 0016 0017 /** 0018 * An interface of the node to the compositioning 0019 * system. Compositioning system KisAsyncMerger knows nothing about 0020 * the internals of the layer, it just knows that the layer can: 0021 * 0022 * 1) recalculate() its internal representation if it is filthy 0023 * 0024 * 2) apply() itself onto a global projection using, writing all its data 0025 * to the projection. 0026 * 0027 * 3) report parameters of these operations using needRect(), 0028 * changeRect() and accessRect() methods, which mean the same as 0029 * the corresponding methods of KisNode, but include more 0030 * transformations for the layer, e.g. Layer Styles and 0031 * Pass-through mode. 0032 */ 0033 class KRITAIMAGE_EXPORT KisAbstractProjectionPlane 0034 { 0035 public: 0036 KisAbstractProjectionPlane(); 0037 virtual ~KisAbstractProjectionPlane(); 0038 0039 /** 0040 * Is called by the async merger when the node is filthy and 0041 * should recalculate its internal representation. For usual 0042 * layers it means just calling updateProjection(). 0043 */ 0044 virtual QRect recalculate(const QRect& rect, KisNodeSP filthyNode) = 0; 0045 0046 /** 0047 * Writes the data of the projection plane onto a global 0048 * projection using \p painter object. 0049 */ 0050 virtual void apply(KisPainter *painter, const QRect &rect) = 0; 0051 0052 /** 0053 * Works like KisNode::needRect(), but includes more 0054 * transformations of the layer 0055 */ 0056 virtual QRect needRect(const QRect &rect, KisLayer::PositionToFilthy pos = KisLayer::N_FILTHY) const = 0; 0057 0058 /** 0059 * Works like KisNode::changeRect(), but includes more 0060 * transformations of the layer 0061 */ 0062 virtual QRect changeRect(const QRect &rect, KisLayer::PositionToFilthy pos = KisLayer::N_FILTHY) const = 0; 0063 0064 /** 0065 * Works like KisNode::needRect(), but includes more 0066 * transformations of the layer 0067 */ 0068 virtual QRect accessRect(const QRect &rect, KisLayer::PositionToFilthy pos = KisLayer::N_FILTHY) const = 0; 0069 0070 /** 0071 * Works like KisLayer::needRectForOriginal(), but includes needed 0072 * rects of layer styles 0073 */ 0074 virtual QRect needRectForOriginal(const QRect &rect) const = 0; 0075 0076 /** 0077 * Return a tight rectangle, where the contents of the plane 0078 * is placed from user's point of view. It includes everything 0079 * belonging to the plane (e.g. layer styles). 0080 */ 0081 virtual QRect tightUserVisibleBounds() const = 0; 0082 0083 /** 0084 * Returns a list of devices which should synchronize the lod cache on update 0085 */ 0086 virtual KisPaintDeviceList getLodCapableDevices() const = 0; 0087 }; 0088 0089 /** 0090 * A simple implementation of KisAbstractProjectionPlane interface 0091 * that does nothing. 0092 */ 0093 class KisDumbProjectionPlane : public KisAbstractProjectionPlane 0094 { 0095 public: 0096 QRect recalculate(const QRect& rect, KisNodeSP filthyNode) override; 0097 void apply(KisPainter *painter, const QRect &rect) override; 0098 0099 QRect needRect(const QRect &rect, KisLayer::PositionToFilthy pos) const override; 0100 QRect changeRect(const QRect &rect, KisLayer::PositionToFilthy pos) const override; 0101 QRect accessRect(const QRect &rect, KisLayer::PositionToFilthy pos) const override; 0102 QRect needRectForOriginal(const QRect &rect) const override; 0103 QRect tightUserVisibleBounds() const override; 0104 0105 KisPaintDeviceList getLodCapableDevices() const override; 0106 }; 0107 0108 #endif /* __KIS_ABSTRACT_PROJECTION_PLANE_H */