Search
SailfishOS Open Build Service
>
Projects
>
home:sbinner
:
qt481
>
qt
> qt-4.8.0-Description-rewrite-INV_PREMUL-to-fix-a-glass-jaw-on.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File qt-4.8.0-Description-rewrite-INV_PREMUL-to-fix-a-glass-jaw-on.patch of Package qt
From b70fabfc9c480d5c9d7831b48d61fbaec80aef4f Mon Sep 17 00:00:00 2001 From: Robin Burchell <robin.burchell@collabora.com> Date: Sun, 13 Nov 2011 12:31:18 +0100 Subject: [PATCH] Description: rewrite INV_PREMUL to fix a glass jaw on Atom Author: Arjan van de Ven <arjan@linux.intel.com> --- src/gui/image/qimage.cpp | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index f527bcf..9b46a51 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2574,6 +2574,22 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl } } + +static inline QRgb inv_premul(QRgb p) +{ + unsigned char alpha, red, green, blue; + + alpha = qAlpha(p); + if (alpha == 0) + return 0; + if (alpha == 255) + return p; + red = 255 * qRed(p) / alpha; + green = 255 * qGreen(p) / alpha; + blue = 255 * qBlue(p) / alpha; + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied); @@ -2589,7 +2605,7 @@ static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt: for (int i = 0; i < src->height; ++i) { const QRgb *end = src_data + src->width; while (src_data < end) { - *dest_data = INV_PREMUL(*src_data); + *dest_data = inv_premul(*src_data); ++src_data; ++dest_data; } -- 1.7.7.4