File indexing completed on 2025-02-23 04:09:01
0001 /* 0002 * SPDX-FileCopyrightText: 2009 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_PROJECTION_BACKEND 0008 #define KIS_PROJECTION_BACKEND 0009 0010 #include "kis_update_info.h" 0011 0012 class KoColorProfile; 0013 class KisImagePatch; 0014 class KisDisplayFilter; 0015 0016 #include <KoColorConversionTransformation.h> 0017 0018 /** 0019 * KisProjectionBackend is an abstract class representing 0020 * an object that can store a cache of KisImage projection. 0021 * More than that this object can perform some scaling operations 0022 * that are based on "patches" paradigm 0023 */ 0024 class KisProjectionBackend 0025 { 0026 public: 0027 virtual ~KisProjectionBackend(); 0028 0029 /** 0030 * Those methods are related to KisPrescaledProjection's 0031 * equivalents 0032 */ 0033 virtual void setImage(KisImageWSP image) = 0; 0034 virtual void setImageSize(qint32 w, qint32 h) = 0; 0035 virtual void setMonitorProfile(const KoColorProfile* monitorProfile, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) = 0; 0036 virtual void setChannelFlags(const QBitArray &channelFlags) = 0; 0037 virtual void setDisplayFilter(QSharedPointer<KisDisplayFilter> displayFilter) = 0; 0038 0039 /** 0040 * Updates the cache of the backend by reading from 0041 * an associated image. All data transfers with 0042 * KisImage should happen here 0043 */ 0044 virtual void updateCache(const QRect &dirtyImageRect) = 0; 0045 0046 /** 0047 * Prescales the cache of the backend. It is intended to be 0048 * called from a separate thread where you can easily 0049 * do the calculations. No data transfers with KisImage 0050 * should happen during this phase 0051 */ 0052 virtual void recalculateCache(KisPPUpdateInfoSP info) = 0; 0053 0054 /** 0055 * Some backends cannot work with arbitrary areas due to 0056 * scaling stuff. That's why KisPrescaledProjection asks 0057 * a backend to align an image rect before any operations. 0058 */ 0059 virtual void alignSourceRect(QRect& rect, qreal scale); 0060 0061 /** 0062 * Gets a patch from a backend that can draw a info.imageRect on some 0063 * QPainter in future. info.scaleX and info.scaleY are the scales 0064 * of planned drawing, btw, it doesn't mean that an QImage inside 0065 * the patch will have these scales - it'll have the nearest suitable 0066 * scale or even original scale (e.g. KisProjectionCache) 0067 * 0068 * If info.borderWidth is non-zero, info.requestedRect will 0069 * be expended by info.borderWidth pixels to all directions and 0070 * image of this rect will actually be written to the patch's QImage. 0071 * That is done to eliminate border effects in smooth scaling. 0072 */ 0073 virtual KisImagePatch getNearestPatch(KisPPUpdateInfoSP info) = 0; 0074 0075 /** 0076 * Draws a piece of original image onto @p gc 's canvas 0077 * @p info.imageRect - area in KisImage pixels where to read from 0078 * @p info.viewportRect - area in canvas pixels where to write to 0079 * If info.imageRect and info.viewportRect don't agree, the image 0080 * will be scaled 0081 * @p info.borderWidth has the same meaning as in getNearestPatch 0082 * @p info.renderHints - hints, transmitted to QPainter during drawing 0083 */ 0084 virtual void drawFromOriginalImage(QPainter& gc, 0085 KisPPUpdateInfoSP info) = 0; 0086 }; 0087 0088 #endif /* KIS_PROJECTION_BACKEND */