|
Krita Source Code Documentation
|
#include <KisOverlayPaintDeviceWrapper.h>
Classes | |
| struct | Private |
Public Types | |
| enum | OverlayMode { NormalMode = 0 , PreciseMode , LazyPreciseMode } |
Public Member Functions | |
| void | beginTransaction (KUndo2Command *parent=0) |
| KisPaintDeviceSP | createPreciseCompositionSourceDevice () |
| KUndo2Command * | endTransaction () |
| KisPaintDeviceSP | externalDestination () const |
| KisOverlayPaintDeviceWrapper (KisPaintDeviceSP source, int numOverlays=1, OverlayMode mode=NormalMode, const KoColorSpace *forcedOverlayColorSpace=nullptr) | |
| KisPaintDeviceSP | overlay (int index=0) const |
| const KoColorSpace * | overlayColorSpace () const |
| void | readRect (const QRect &rc) |
| void | readRects (const QVector< QRect > &rects) |
| void | setExternalDestination (KisPaintDeviceSP device) |
| KisPaintDeviceSP | source () const |
| void | writeRect (const QRect &rc, int index=0) |
| void | writeRects (const QVector< QRect > &rects, int index=0) |
| ~KisOverlayPaintDeviceWrapper () | |
Private Attributes | |
| const QScopedPointer< Private > | m_d |
Friends | |
| struct | KisChangeOverlayWrapperCommand |
A special wrapper class for a paint device that allows working with parts of the source paint device using an overlay, that is without modifying the device itself. The overlay may have higher bit depth if PreciseMode or LazyPreciseMode is used.
For example, you have an RGBA8 paint device, but you want all the blending happen in higher bit depth. You wrap your paint device (source paint device) into KisOverlayPaintDeviceWrapper, and the wrapper creates a temporary device (precise overlay paint device) in RGBA16 colorspace. Then you work with this precise paint device as usual, uploading and downloading pixel data to/from the source paint device using readRect() and writeRect()
In LazyPreciseMode, if the source device is already "precise", that is having the bit depth higher than 8 bit per channel, no temporary device is created. All the operations are forwarded directly to the source device.
In some cases (e.g. when trying to maintain a separate heightmap channel), you may want to have multiple overlays.
When doing conversions between U8 and U16 color spaces, the overlay will try to use AVX2-optimized algorithms.
Example:
Definition at line 67 of file KisOverlayPaintDeviceWrapper.h.
| Enumerator | |
|---|---|
| NormalMode | |
| PreciseMode | |
| LazyPreciseMode | |
Definition at line 70 of file KisOverlayPaintDeviceWrapper.h.
| KisOverlayPaintDeviceWrapper::KisOverlayPaintDeviceWrapper | ( | KisPaintDeviceSP | source, |
| int | numOverlays = 1, | ||
| KisOverlayPaintDeviceWrapper::OverlayMode | mode = NormalMode, | ||
| const KoColorSpace * | forcedOverlayColorSpace = nullptr ) |
Create an overlay wrapper and attach it to device.
If mode is NormalMode, then numOverlays are created. All overlays will have the same (possible "imprecise") colorspace as source.
If mode is PreciseMode, then numOverlays are created. If source has "imprecise" color space (U8), then overlays will be upgraded to a "precise" color space (U16).
If mode is LazyPreciseMode and numOverlays is 1, then the overlay will be created only in case when precise color space is needed. Otherwise, the mode behaves like PreciseMode
| device | source device |
| numOverlays | the number of overlays to create |
| mode | mode to use |
| forcedOverlayColorSpace | forced color space to use for overlay. Passing non- null as forcedOverlayColorSpace will override precise color space decision process. This argument is useful for cases when two overlay devices need to have exactly the same color space (e.g. in colorsmudge overlay mode). |
Definition at line 66 of file KisOverlayPaintDeviceWrapper.cpp.
References CMYKAColorModelID, KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KisPaintDevice::colorSpace(), KoColorSpaceRegistry::colorSpace(), KisPaintDevice::compositionSourceColorSpace(), KoColor::convertedTo(), KoOptimizedPixelDataScalerU8ToU16Factory::createCmykaScaler(), KoOptimizedPixelDataScalerU8ToU16Factory::createRgbaScaler(), KisPaintDevice::defaultBounds(), KisPaintDevice::defaultPixel(), KoID::id(), KoColorSpaceRegistry::instance(), Integer16BitsColorDepthID, Integer8BitsColorDepthID, LazyPreciseMode, m_d, KisPaintDevice::moveTo(), KisPaintDevice::offset(), overlay(), overlayColorSpace(), PreciseMode, KoColorSpace::profile(), RGBAColorModelID, KisPaintDevice::setDefaultBounds(), KisPaintDevice::setDefaultPixel(), KisPaintDevice::setSupportsWraparoundMode(), source(), KisPaintDevice::supportsWraproundMode(), and YCbCrAColorModelID.
| KisOverlayPaintDeviceWrapper::~KisOverlayPaintDeviceWrapper | ( | ) |
Definition at line 132 of file KisOverlayPaintDeviceWrapper.cpp.
| void KisOverlayPaintDeviceWrapper::beginTransaction | ( | KUndo2Command * | parent = 0 | ) |
Definition at line 306 of file KisOverlayPaintDeviceWrapper.cpp.
References KIS_SAFE_ASSERT_RECOVER, KisChangeOverlayWrapperCommand, m_d, and void().
| KisPaintDeviceSP KisOverlayPaintDeviceWrapper::createPreciseCompositionSourceDevice | ( | ) |
Create a composite source device for being used over overlay().
Please note that one cannot use overlay()->createCompositeSourceDevice() for this purpose because overlay() is just a copy of sourceDevice() and doesn't have overloaded methods for this color space.
TODO: make KisPaintDevice::compositeSourceColorSpace() not a virtual method, but let is be assigned during the lifetime of the paint device. It'll let us remove this extra function.
TODO: this function has rather vague meaning when forcedOverlayColorSpace feature is used
Definition at line 277 of file KisOverlayPaintDeviceWrapper.cpp.
References KoColorSpace::colorModelId(), KoColorSpaceRegistry::colorSpace(), KisPaintDevice::createCompositionSourceDevice(), KoID::id(), KoColorSpaceRegistry::instance(), Integer16BitsColorDepthID, m_d, KoColorSpace::profile(), KisPaintDevice::setDefaultBounds(), and source().
| KUndo2Command * KisOverlayPaintDeviceWrapper::endTransaction | ( | ) |
Definition at line 327 of file KisOverlayPaintDeviceWrapper.cpp.
References KIS_SAFE_ASSERT_RECOVER, m_d, and void().
| KisPaintDeviceSP KisOverlayPaintDeviceWrapper::externalDestination | ( | ) | const |
Definition at line 141 of file KisOverlayPaintDeviceWrapper.cpp.
References m_d.
| KisPaintDeviceSP KisOverlayPaintDeviceWrapper::overlay | ( | int | index = 0 | ) | const |
| const KoColorSpace * KisOverlayPaintDeviceWrapper::overlayColorSpace | ( | ) | const |
| void KisOverlayPaintDeviceWrapper::readRect | ( | const QRect & | rc | ) |
Definition at line 156 of file KisOverlayPaintDeviceWrapper.cpp.
References readRects().
Definition at line 166 of file KisOverlayPaintDeviceWrapper.cpp.
References KisPainter::copyAreaOptimized(), KisPaintDevice::createRandomAccessorNG(), KisPaintDevice::extent(), m_d, KisRegion::makeGridLikeRectsUnique(), overlay(), and KritaUtils::processTwoDevicesWithStrides().
| void KisOverlayPaintDeviceWrapper::setExternalDestination | ( | KisPaintDeviceSP | device | ) |
Definition at line 136 of file KisOverlayPaintDeviceWrapper.cpp.
References m_d.
| KisPaintDeviceSP KisOverlayPaintDeviceWrapper::source | ( | ) | const |
Definition at line 146 of file KisOverlayPaintDeviceWrapper.cpp.
References m_d.
| void KisOverlayPaintDeviceWrapper::writeRect | ( | const QRect & | rc, |
| int | index = 0 ) |
Definition at line 161 of file KisOverlayPaintDeviceWrapper.cpp.
References writeRects().
Definition at line 234 of file KisOverlayPaintDeviceWrapper.cpp.
References KisPaintDevice::colorSpace(), KisPainter::copyAreaOptimized(), KisPaintDevice::createRandomAccessorNG(), KisPaintDevice::createRandomConstAccessorNG(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, overlay(), and KritaUtils::processTwoDevicesWithStrides().
|
friend |
Definition at line 136 of file KisOverlayPaintDeviceWrapper.h.
|
private |
Definition at line 138 of file KisOverlayPaintDeviceWrapper.h.