File indexing completed on 2024-06-16 04:17:26

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2012 Boudewijn Rempt <boud@valdyas.org>
0003  * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #ifndef KIS_TEXTURE_OPTION_H
0009 #define KIS_TEXTURE_OPTION_H
0010 
0011 #include <kritapaintop_export.h>
0012 
0013 #include <kis_paint_device.h>
0014 #include <kis_cached_paint_device.h>
0015 #include <kis_types.h>
0016 #include <resources/KoAbstractGradient.h>
0017 #include <resources/KoCachedGradient.h>
0018 
0019 #include "KisTextureMaskInfo.h"
0020 
0021 #include <QRect>
0022 
0023 class KoPattern;
0024 class KoResource;
0025 class KisPropertiesConfiguration;
0026 class KisResourcesInterface;
0027 
0028 #include <KisStandardOptions.h>
0029 #include <KisTextureOptionData.h>
0030 
0031 
0032 class PAINTOP_EXPORT KisTextureOption
0033 {
0034 public:
0035     KisTextureOption(const KisPropertiesConfiguration *setting, KisResourcesInterfaceSP resourcesInterface,
0036                      KoCanvasResourcesInterfaceSP canvasResourcesInterface,
0037                      int levelOfDetail,
0038                      KisBrushTextureFlags flags = None);
0039 
0040     bool m_enabled {false};
0041 
0042     /**
0043      * @brief apply combine the texture map with the dab
0044      * @param dab the colored, final representation of the dab, after mirroring and everything.
0045      * @param offset the position of the dab on the image. used to calculate the position of the mask pattern
0046      * @param info the paint information
0047      */
0048     void apply(KisFixedPaintDeviceSP dab, const QPoint& offset, const KisPaintInformation & info);
0049     static QList<KoResourceLoadResult> prepareLinkedResources(const KisPropertiesConfigurationSP setting, KisResourcesInterfaceSP resourcesInterface);
0050     static QList<KoResourceLoadResult> prepareEmbeddedResources(const KisPropertiesConfigurationSP setting, KisResourcesInterfaceSP resourcesInterface);
0051     bool applyingGradient() const;
0052 
0053     static bool applyingGradient(const KisPropertiesConfiguration *settings);
0054 
0055 private:
0056     void applyLightness(KisFixedPaintDeviceSP dab, const QPoint& offset, const KisPaintInformation& info);
0057     void applyGradient(KisFixedPaintDeviceSP dab, const QPoint& offset, const KisPaintInformation& info);
0058     void fillProperties(const KisPropertiesConfiguration *setting, KisResourcesInterfaceSP resourcesInterface, KoCanvasResourcesInterfaceSP canvasResourcesInterface);
0059 private:
0060 
0061     int m_offsetX {0};
0062     int m_offsetY {0};
0063     KisTextureOptionData::TexturingMode m_texturingMode {KisTextureOptionData::MULTIPLY};
0064     KoAbstractGradientSP m_gradient;
0065     KoCachedGradient m_cachedGradient;
0066 
0067     int m_levelOfDetail {0};
0068 
0069 private:
0070     KisStrengthOption m_strengthOption;
0071     KisTextureMaskInfoSP m_maskInfo;
0072     KisBrushTextureFlags m_flags;
0073     KisCachedPaintDevice m_cachedPaintDevice;
0074 };
0075 
0076 #endif // KIS_TEXTURE_OPTION_H