diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-27 12:40:36 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-28 19:06:44 +0000 |
commit | 77164e4cc05373de1147128058754d6511145afb (patch) | |
tree | 872ea60536608b0f67184d8b35d5aef455907ee1 /src/gui/painting/qpainter.cpp | |
parent | 12705f70c9a380a5a4e8ba4027a835259aebb78f (diff) |
QRegion: make iterable
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>
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
0 files changed, 0 insertions, 0 deletions