The vast majority is actually switched to QRandomGenerator::bounded(),
which gives a mostly uniform distribution over the [0, bound)
range. There are very few floating point cases left, as many of those
that did use floating point did not need to, after all. (I did leave
some that were too ugly for me to understand)
This commit also found a couple of calls to rand() instead of qrand().
This commit does not include changes to SSL code that continues to use
qrand() (job for someone else):
src/network/ssl/qsslkey_qt.cpp
src/network/ssl/qsslsocket_mac.cpp
tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Fix a number of issues that caused polygons to not always be drawn
fully connected.
Ensures the original lastPixel is set when drawing closed polygons,
ensure we don't round away from the original starting point, and add
handling of edges that need to be rounded half a pixel sideways to line
up with endpoints.
Task-number: QTBUG-27053
Change-Id: Ib51ee5623a629996af51a0967096383f04e91e2f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Especially in examples, where we should show off our convenience
functions, prefer calling these functions over doing arithmetic with
M_PI (or approximations thereto) and 180 (give or take simple
factors). This incidentally documents what's going on, just by the
name of the function used (and reveals at least one place where
variables were misnamed; the return from atan is in radians, *not*
degrees).
Task-number: QTBUG-58083
Change-Id: I6e5d66721cafab423378f970af525400423e971e
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Use M_PI (and friends), where possible, in favor of hand-coded
approximations of various (in)accuracies. Where that's not available
(e.g. fragment shaders), use the same value that qmath.h uses for
M_PI, for consistency. Replaced math.h with qmath.h in places that
defined a fall-back in case math.h omits it (it's not in the C++
standard, although M_PI is in POSIX); or removed this entirely where
it wasn't used.
Reworked some code to reduce the amount of arithmetic needed, in the
process; e.g. pulling common factors out of loops. Revised an
example's doc to not waste time talking about using a six-sig-fig
value for pi (which we no longer do) - it really wasn't relevant, or
anything to be proud of; nor did the doc mention its later use.
Task-number: QTBUG-58083
Change-Id: I5a31e3a2b6a823b97a43209bed61a37b9aa6c05f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
We have to use a temporary data path for winrt, as the applications
are sandboxed and cannot just put data anywhere.
Change-Id: I8f95de132e5b5ac77441cbbf26af873b8018c7cb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Corresponds to the similar function QPainterPath::intersects() and is
faster than calculating the intersection and then checking if it is
empty.
Change-Id: I694bb2206ed330a456a41d4118a952a68177b7a2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
QPainterPath could in certain cases where sub-path points were on the
border of a rect fail to calculate intersects() correctly.
The patch adds handling of such cases by looking if end points cross in
or out of the rect. Other cases are already caught.
Task-number: QTBUG-31551
Change-Id: I6284da8ff8646d4636702923a76362302dde5767
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
The intersection algorithm for intersection with rects, might return
one edge of the rect even if that edge does not intersect with the path.
To deal with that we collapse paths with empty bounding rects to the empty path.
Task-number: QTBUG-60024
Change-Id: I3e305983c66548e772d7d7ce3de99d715edbdd1b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
... for calculated test data names.
In tst_qimage.cpp, use QLatin1String instead of QString for image
format pretty-printing, to avoid needless memory allocation and, more
importantly in the context of this patch, to make the result usable
with addRow(), which does not support %ls.
Change-Id: Ib1953aee2da235ae912917a450491ac8be69ca3a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
If we do not the fontDef of the multifont will be the default 0.
Task-number: QTBUG-59443
Change-Id: Ib223517975b2a57b2371e309d12cd8f918d30825
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
... leveraging the existing support for QLatin1String, which is the
char equivalent of QStringView.
The only noteworthy changes here are the port of the low-level
functions to size_t and that the internal template function,
setColorFromString(), can now take its argument by value, since only
views are ever passed to it anymore.
In the test, used new QTest::addRow() to format test names, and
introduced temporaries to avoid re-calculating the same input values
for every check.
Change-Id: Ia3c59e5c435ff753f34993a8d85c0c0b4e8e2b22
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
The cumbersome complex calls to QMatrix were surely easy to write
thanks to copy-and-paste; but this left the reader to either
laboriously check or guess that all the copies were the same (and
notice that there were two, in fact). DRY.
Since QMatrix wants qreal data, change the float deg angle to a qreal
and work in qreal throughout. Passing the angle to a function instead
of repeating it obviates the need for a local variable in the calling
code, to hold its value.
Change-Id: I6bb4adf438a893083ca19f27942502c1e5c518aa
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
The ARGB32PM code-path doesn't have enough precision to accurately
render ARGB32 images, but the RGB64 code-path does. Since this is
already a slow configuration and the most costly part is the conversion
we can switch to the more accurate code-path for little cost.
Task-number: QTBUG-55720
Change-Id: Ifa0afba8d8cc0c2f699bb91f51726f4ee5228f3e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
The function was incorrectly handling green and blue color channels
causing them to be dropped. This affects drawing non 32-bit images onto
10-bit per color channels formats such as RGB30.
Change-Id: I9211e253b1a9da0dada5c418d592a8f531265989
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
The alpha channel of an RGB32 image was not properly ignored when doing
blending with partial opacity.
Now the alpha value is properly ignored, which is both more correct
and faster. This also makes SSE2 and AVX2 implementations match NEON
which was already doing the right thing (though had dead code for
doing it wrong).
Change-Id: I4613b8d70ed8c2e36ced10baaa7a4a55bd36a940
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Turns the two set of tables in QDrawHelperGammaTables into two
QColorProfile classes that use similar structures and can be reused for
other gamma correction.
At the same time clean-up and improve the comma-correct blending code
to use the new profiles and QRgba64 precision.
Change-Id: I302bd87a5c836e1010fff6d633eeb56fd4ae2ff0
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Commit c5db8fc74 changed all instances of Q_WS_FOO to have the prefix
Q_DEAD_CODE_FROM_QT4 instead, to make it clearer when reading the code
that the code in question was a left-over from Qt4, when we used
Q_WS_ defines instead of Q_OS_ defines.
This worked well for cases of #ifdef Q_DEAD_CODE_FROM_QT4, but less so
for cases of #ifndef Q_DEAD_CODE_FROM_QT4, where the code was actually
unconditionally included.
To make this even clearer, the defines have been replaced by checks for
1 or 0, with a comment describing how the code used to look in Qt4. The
use of constants in the check also makes it easier for editors to parse
the condition and show visually that the code is defined out.
Change-Id: I152070d87334df7259b417cd5e17d7b7950379b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Also bump minimum required Qt version for Android: Ministro updates.
Conflicts:
src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java
src/android/java/src/org/qtproject/qt5/android/bindings/QtLoader.java
src/plugins/platforms/android/androidjnimain.cpp
Change-Id: I966f249bebf92da37bfdeb995ad21b027eb03301
Clip the transformed and rounded sourceClip to the source rectangle,
so we don't try to rotate pixels outside the source.
Task-number: QTBUG-56252
Change-Id: Ib9cb80f9856724118867aea37ead0b02a6c71495
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
The inefficiency of QColor(const char*) came to light by
a recent refactoring which showed that the existing char*
overload of qt_get_hex_rgb() was never called.
So, provide a QLatin1String interface for named colors
that allows user code to reach that internal function
without converting to QString first.
Change-Id: I74df7b570ef28c00e35ca4adf46c4b7c7e9994b3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <a.kudryavtsev@netris.ru>
Use the new qtConfig macro in all pro/pri files.
This required adding some feature entries, and adding
{private,public}Feature to every referenced already existing entry.
Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
- port uses of dynamic containers with static content to constexpr
C arrays
Fixes errors pointed out by my tree's static checks.
Change-Id: I5e1cafa6e428500afae0d653ce48a7fb465c19ed
Reviewed-by: David Faure <david.faure@kdab.com>
Before: HexRgb: 0.00230 ms per iteration, HexArgb: 0.00290 ms per iteration
After: HexRgb: 0.00051 ms per iteration, HexArgb: 0.00061 ms per iteration
This showed up as a relevant optimization when profiling KIconLoader
which uses QColor::name() as part of the key -- thanks to Mark Gaiser for
the investigation and first suggestion of a solution. I have also seen
customer code writing a replacement for QColor::name() because it was
too slow to be used as a hash key.
Change-Id: I009ccdd712ea0d869d466e2c9894e0cea58f0e68
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Nothing fancy, just a safety-net for a following refactoring.
Change-Id: I5be87c86cd61e24bf96881d2485dd7560ea6184a
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Fix a mistake introduced recently and revealed by lancelot. Adds an
auto-test for rotations to catch similar errors faster in the future.
Change-Id: I028a160107d98899e723481b6201ef776f20c721
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Remove #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library,
and tests.
Task-number: QTBUG-51673
Change-Id: I55f61845c3b54027c467a5c59c122e7d16955358
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Cleaning out the workarounds for the discontinued "Embedded Android"
platform of Boot2Qt.
Change-Id: I0ff9d770e82a43457fb7e5da0428f4597ead4038
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Math functions are linked in by default on INTEGRITY.
Change-Id: I737ae87c02b2321caca3975f69525731e839d1a7
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Virtually all code in Qt that inspects a QRegion does
so by calling rects(), which returns a QVector<QRect>.
But rects() has a problem: A QRegion that contains just
one rectangle internally is not represented by a QVector,
and the mere act of calling rects() makes QRegion create
one.
So, expose the fact that QRegion is a container of QRects
to users by providing iterators and begin()/end(), which
can be nothrow, since for the one-rectangle case, instead
of vectorize()ing the region, we just return pointers to
(and one past) the 'extent' rectangle.
As a consequence, the iterator type is just const QRect*,
but I think that whatever containers QRegion may use under
the hood in the future, it will be certainly one that is
layout-compatible with a C array.
No mutable iterators are provided, since QRegion maintains
a running bounding-rect, so a mutable iterator would have
to call into QRegion for every change, which doesn't make
sense.
[ChangeLog][QtGui][QRegion] Is now iterable as a container
of QRects: added {c,}{r,}{begin,end}().
Change-Id: I2fa565fac0c1d26e2c0937604b23763cd4e23604
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
After this change, this was the distribution of calls in
QtGui and QtWidgets when the patch was developed for 5.4:
QtGui QtWidgets
move 23 63
copy 23 36
Change-Id: If3f536e52fc242c585e7fa0662049c0657efcc9c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
To calculate the real count we need to use the actual fixed point
increment and can not use the floating point value increment wass based
on since it might round differently.
Includes auto-test by Gabriel de Dietrich.
Task-number: QTBUG-50153
Change-Id: Ia973088f361c90370fa20bac14a4b8f373b5d234
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Move some code (like registrations of meta types) from init() to
initTestCase() in the process.
Change-Id: I57db5156647cfadab554fbed853b2e68b2815f3b
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>