File indexing completed on 2024-05-12 15:59:37
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KoOptimizedPixelDataScalerU8ToU16Base_H 0008 #define KoOptimizedPixelDataScalerU8ToU16Base_H 0009 0010 #include <QtGlobal> 0011 #include "kritapigment_export.h" 0012 0013 /** 0014 * @brief Converts an RGB-like color space between U8 and U16 formats 0015 * 0016 * In some places we need to extend precision of the color space 0017 * in a very efficient way. It is specifically needed in the 0018 * colorsmudge engine, because it operates at an extremely low 0019 * levels of opacity. The conversion should also happen very 0020 * efficiently, because colorsmudge requests it on the fly right 0021 * when the user is painting on the canvas. 0022 * 0023 * The actual implementation is placed in class 0024 * `KoOptimizedPixelDataScalerU8ToU16`. 0025 * 0026 * To create a scaler, just call a factory. It will create a version 0027 * of the scaler optimized for your CPU architecture. 0028 * 0029 * \code{.cpp} 0030 * QScopedPointer<KoOptimizedPixelDataScalerU8ToU16Base> scaler( 0031 * KoOptimizedPixelDataScalerU8ToU16Factory::createRgbaScaler()); 0032 * 0033 * // ... 0034 * 0035 * // convert the data from U8 to U16 0036 * scaler->convertU8ToU16(src, srcRowStride, 0037 * dst, dstRowStride, 0038 * numRows, numColumns); 0039 * 0040 * // ... 0041 * 0042 * // convert the data back from U16 to U8 0043 * scaler->convertU16ToU8(src, srcRowStride, 0044 * dst, dstRowStride, 0045 * numRows, numColumns); 0046 * 0047 * \endcode 0048 */ 0049 class KRITAPIGMENT_EXPORT KoOptimizedPixelDataScalerU8ToU16Base 0050 { 0051 public: 0052 KoOptimizedPixelDataScalerU8ToU16Base(int channelsPerPixel); 0053 0054 virtual ~KoOptimizedPixelDataScalerU8ToU16Base(); 0055 0056 virtual void convertU8ToU16(const quint8 *src, int srcRowStride, 0057 quint8 *dst, int dstRowStride, 0058 int numRows, int numColumns) const = 0; 0059 0060 virtual void convertU16ToU8(const quint8 *src, int srcRowStride, 0061 quint8 *dst, int dstRowStride, 0062 int numRows, int numColumns) const = 0; 0063 0064 int channelsPerPixel() const; 0065 0066 protected: 0067 int m_channelsPerPixel; 0068 }; 0069 0070 #endif // KoOptimizedPixelDataScalerU8ToU16Base_H