File indexing completed on 2024-05-12 15:59:31

0001 /*
0002  * SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef _KO_COLOR_CONVERSION_CACHE_HPP_
0008 #define _KO_COLOR_CONVERSION_CACHE_HPP_
0009 
0010 class KoCachedColorConversionTransformation;
0011 class KoColorSpace;
0012 
0013 #include "KoColorConversionTransformation.h"
0014 
0015 /**
0016  * This class holds a cache of KoColorConversionTransformations.
0017  *
0018  * This class is not part of public API, and can be changed without notice.
0019  */
0020 class KoColorConversionCache
0021 {
0022 public:
0023     struct CachedTransformation;
0024 public:
0025     KoColorConversionCache();
0026     ~KoColorConversionCache();
0027 
0028     /**
0029      * This function returns a cached color transformation if available
0030      * or create one.
0031      * @param src source color space
0032      * @param dst destination color space
0033      * @param _renderingIntent rendering intent
0034      * @param conversionFlags conversion flags
0035      */
0036     KoCachedColorConversionTransformation cachedConverter(const KoColorSpace* src,
0037                                                           const KoColorSpace* dst,
0038                                                           KoColorConversionTransformation::Intent _renderingIntent,
0039                                                           KoColorConversionTransformation::ConversionFlags conversionFlags);
0040 
0041     /**
0042      * This function is called by the destructor of the color space to
0043      * warn the cache that any pointers to this color space is going to
0044      * be invalid and that the cache needs to stop using those pointers.
0045      * @param src source color space
0046      */
0047     void colorSpaceIsDestroyed(const KoColorSpace* src);
0048 private:
0049     struct Private;
0050     Private* const d;
0051 };
0052 
0053 /**
0054  * This class hold a cached color conversion. It can only be created
0055  * by the cache and when it's deleted it return the transformation to
0056  * the pool of available color conversion transformation.
0057  *
0058  * This class is not part of public API, and can be changed without notice.
0059  */
0060 class KoCachedColorConversionTransformation
0061 {
0062     friend class KoColorConversionCache;
0063 private:
0064     KoCachedColorConversionTransformation(KoColorConversionCache::CachedTransformation* transfo);
0065 public:
0066     KoCachedColorConversionTransformation(const KoCachedColorConversionTransformation&);
0067     ~KoCachedColorConversionTransformation();
0068 public:
0069     const KoColorConversionTransformation* transformation() const;
0070 private:
0071     KoColorConversionCache::CachedTransformation* m_transfo;
0072 };
0073 
0074 
0075 #endif