summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qdrawhelper.cpp
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-08-15 13:09:55 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-08-15 16:53:19 +0200
commitc7ec7cd2a1ae9bec31113fae1f1e549b2bf98e0b (patch)
treefc81fba4e7815ea061da277cf3bcf3102866932f /src/gui/painting/qdrawhelper.cpp
parent7947032e2d1d68b2c0f79874db7adcf560851f29 (diff)
parent6132260da394a9627947f0fe6a279c20863b6ad2 (diff)
Merge branch 'wip/qt6' into wip/cmake
Diffstat (limited to 'src/gui/painting/qdrawhelper.cpp')
-rw-r--r--src/gui/painting/qdrawhelper.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 006befea22..674f52678d 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -2053,6 +2053,23 @@ inline void fetchTransformed_pixelBounds(int max, int l1, int l2, int &v)
}
}
+static inline bool canUseFastMatrixPath(const qreal cx, const qreal cy, const qsizetype length, const QSpanData *data)
+{
+ if (Q_UNLIKELY(!data->fast_matrix))
+ return false;
+
+ qreal fx = (data->m21 * cy + data->m11 * cx + data->dx) * fixed_scale;
+ qreal fy = (data->m22 * cy + data->m12 * cx + data->dy) * fixed_scale;
+ qreal minc = std::min(fx, fy);
+ qreal maxc = std::max(fx, fy);
+ fx += std::trunc(data->m11 * fixed_scale) * length;
+ fy += std::trunc(data->m12 * fixed_scale) * length;
+ minc = std::min(minc, std::min(fx, fy));
+ maxc = std::max(maxc, std::max(fx, fy));
+
+ return minc >= std::numeric_limits<int>::min() && maxc <= std::numeric_limits<int>::max();
+}
+
template<TextureBlendType blendType, QPixelLayout::BPP bpp, typename T>
static void QT_FASTCALL fetchTransformed_fetcher(T *buffer, const QSpanData *data,
int y, int x, int length)
@@ -2070,7 +2087,7 @@ static void QT_FASTCALL fetchTransformed_fetcher(T *buffer, const QSpanData *dat
// When templated 'fetch' should be inlined at compile time:
const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : FetchPixelFunc(fetchPixel<bpp>);
- if (data->fast_matrix) {
+ if (canUseFastMatrixPath(cx, cy, length, data)) {
// The increment pr x in the scanline
int fdx = (int)(data->m11 * fixed_scale);
int fdy = (int)(data->m12 * fixed_scale);
@@ -3026,7 +3043,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
uint *end = buffer + length;
uint *b = buffer;
- if (data->fast_matrix) {
+ if (canUseFastMatrixPath(cx, cy, length, data)) {
// The increment pr x in the scanline
int fdx = (int)(data->m11 * fixed_scale);
int fdy = (int)(data->m12 * fixed_scale);
@@ -3383,7 +3400,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
const qreal cx = x + qreal(0.5);
const qreal cy = y + qreal(0.5);
- if (data->fast_matrix) {
+ if (canUseFastMatrixPath(cx, cy, length, data)) {
// The increment pr x in the scanline
int fdx = (int)(data->m11 * fixed_scale);
int fdy = (int)(data->m12 * fixed_scale);
@@ -3570,7 +3587,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf
QRgba64 *end = buffer + length;
QRgba64 *b = buffer;
- if (data->fast_matrix) {
+ if (canUseFastMatrixPath(cx, cy, length, data)) {
// The increment pr x in the scanline
const int fdx = (int)(data->m11 * fixed_scale);
const int fdy = (int)(data->m12 * fixed_scale);
@@ -3728,7 +3745,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint64(QRgba64 *buf
QRgba64 *end = buffer + length;
QRgba64 *b = buffer;
- if (data->fast_matrix) {
+ if (canUseFastMatrixPath(cx, cy, length, data)) {
// The increment pr x in the scanline
const int fdx = (int)(data->m11 * fixed_scale);
const int fdy = (int)(data->m12 * fixed_scale);