Detach for colortransforms of indexed formats
We were triggering detach during the transform, but the short-cut for indexed formats wasn't triggering that. Instead make the detach explicit and avoid it during the loop. Pick-to: 6.3 6.2 5.15 Change-Id: I0f12b7f93841342a0770ce3d3c78f26ad19d8dac Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
08733dff58
commit
dbae10487e
@ -4994,7 +4994,8 @@ void QImage::convertToColorSpace(const QColorSpace &colorSpace)
|
|||||||
qWarning() << "QImage::convertToColorSpace: Output colorspace is not valid";
|
qWarning() << "QImage::convertToColorSpace: Output colorspace is not valid";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
detach();
|
if (d->colorSpace == colorSpace)
|
||||||
|
return;
|
||||||
applyColorTransform(d->colorSpace.transformationToColorSpace(colorSpace));
|
applyColorTransform(d->colorSpace.transformationToColorSpace(colorSpace));
|
||||||
d->colorSpace = colorSpace;
|
d->colorSpace = colorSpace;
|
||||||
}
|
}
|
||||||
@ -5036,6 +5037,7 @@ QColorSpace QImage::colorSpace() const
|
|||||||
*/
|
*/
|
||||||
void QImage::applyColorTransform(const QColorTransform &transform)
|
void QImage::applyColorTransform(const QColorTransform &transform)
|
||||||
{
|
{
|
||||||
|
detach();
|
||||||
if (!d)
|
if (!d)
|
||||||
return;
|
return;
|
||||||
if (pixelFormat().colorModel() == QPixelFormat::Indexed) {
|
if (pixelFormat().colorModel() == QPixelFormat::Indexed) {
|
||||||
@ -5078,14 +5080,14 @@ void QImage::applyColorTransform(const QColorTransform &transform)
|
|||||||
if (depth() > 32) {
|
if (depth() > 32) {
|
||||||
transformSegment = [&](int yStart, int yEnd) {
|
transformSegment = [&](int yStart, int yEnd) {
|
||||||
for (int y = yStart; y < yEnd; ++y) {
|
for (int y = yStart; y < yEnd; ++y) {
|
||||||
QRgba64 *scanline = reinterpret_cast<QRgba64 *>(scanLine(y));
|
QRgba64 *scanline = reinterpret_cast<QRgba64 *>(d->data + y * d->bytes_per_line);
|
||||||
transform.d->apply(scanline, scanline, width(), flags);
|
transform.d->apply(scanline, scanline, width(), flags);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
transformSegment = [&](int yStart, int yEnd) {
|
transformSegment = [&](int yStart, int yEnd) {
|
||||||
for (int y = yStart; y < yEnd; ++y) {
|
for (int y = yStart; y < yEnd; ++y) {
|
||||||
QRgb *scanline = reinterpret_cast<QRgb *>(scanLine(y));
|
QRgb *scanline = reinterpret_cast<QRgb *>(d->data + y * d->bytes_per_line);
|
||||||
transform.d->apply(scanline, scanline, width(), flags);
|
transform.d->apply(scanline, scanline, width(), flags);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user