summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /src/gui/painting
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbrush.cpp6
-rw-r--r--src/gui/painting/qcolor.cpp6
-rw-r--r--src/gui/painting/qfixed_p.h139
-rw-r--r--src/gui/painting/qpen.cpp6
-rw-r--r--src/gui/painting/qpolygon.cpp12
5 files changed, 70 insertions, 99 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index c8dc370a8b..6850eac59e 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -957,7 +957,6 @@ bool QBrush::operator==(const QBrush &b) const
*/
QDebug operator<<(QDebug dbg, const QBrush &b)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
static const char *BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
@@ -983,11 +982,6 @@ QDebug operator<<(QDebug dbg, const QBrush &b)
dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QBrush to QDebug");
- return dbg;
- Q_UNUSED(b);
-#endif
}
#endif
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 2c95434843..96491918cd 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2399,7 +2399,6 @@ void QColor::invalidate()
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QColor &c)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
if (!c.isValid())
dbg.nospace() << "QColor(Invalid)";
else if (c.spec() == QColor::Rgb)
@@ -2413,11 +2412,6 @@ QDebug operator<<(QDebug dbg, const QColor &c)
dbg.nospace() << "QColor(AHSL " << c.alphaF() << ", " << c.hslHueF() << ", " << c.hslSaturationF() << ", " << c.lightnessF() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QColor to QDebug");
- return dbg;
- Q_UNUSED(c);
-#endif
}
#endif
diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h
index d30328b0fa..44772a4bb5 100644
--- a/src/gui/painting/qfixed_p.h
+++ b/src/gui/painting/qfixed_p.h
@@ -60,48 +60,50 @@
QT_BEGIN_NAMESPACE
struct QFixed {
+private:
+ Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation
public:
- QFixed() : val(0) {}
- QFixed(int i) : val(i<<6) {}
- QFixed(long i) : val(i<<6) {}
+ Q_DECL_CONSTEXPR QFixed() : val(0) {}
+ Q_DECL_CONSTEXPR QFixed(int i) : val(i<<6) {}
+ Q_DECL_CONSTEXPR QFixed(long i) : val(i<<6) {}
QFixed &operator=(int i) { val = (i<<6); return *this; }
QFixed &operator=(long i) { val = (i<<6); return *this; }
- static QFixed fromReal(qreal r) { QFixed f; f.val = (int)(r*qreal(64)); return f; }
- static QFixed fromFixed(int fixed) { QFixed f; f.val = fixed; return f; }
+ Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); }
+ Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor
- inline int value() const { return val; }
+ Q_DECL_CONSTEXPR inline int value() const { return val; }
inline void setValue(int value) { val = value; }
- inline int toInt() const { return (((val)+32) & -64)>>6; }
- inline qreal toReal() const { return ((qreal)val)/(qreal)64; }
+ Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; }
+ Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; }
- inline int truncate() const { return val>>6; }
- inline QFixed round() const { QFixed f; f.val = ((val)+32) & -64; return f; }
- inline QFixed floor() const { QFixed f; f.val = (val) & -64; return f; }
- inline QFixed ceil() const { QFixed f; f.val = (val+63) & -64; return f; }
+ Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; }
+ Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); }
+ Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); }
+ Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); }
- inline QFixed operator+(int i) const { QFixed f; f.val = (val + (i<<6)); return f; }
- inline QFixed operator+(uint i) const { QFixed f; f.val = (val + (i<<6)); return f; }
- inline QFixed operator+(const QFixed &other) const { QFixed f; f.val = (val + other.val); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed((val + (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); }
inline QFixed &operator+=(int i) { val += (i<<6); return *this; }
inline QFixed &operator+=(uint i) { val += (i<<6); return *this; }
inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; }
- inline QFixed operator-(int i) const { QFixed f; f.val = (val - (i<<6)); return f; }
- inline QFixed operator-(uint i) const { QFixed f; f.val = (val - (i<<6)); return f; }
- inline QFixed operator-(const QFixed &other) const { QFixed f; f.val = (val - other.val); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed((val - (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); }
+ Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); }
inline QFixed &operator-=(int i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; }
inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; }
- inline QFixed operator-() const { QFixed f; f.val = -val; return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); }
- inline bool operator==(const QFixed &other) const { return val == other.val; }
- inline bool operator!=(const QFixed &other) const { return val != other.val; }
- inline bool operator<(const QFixed &other) const { return val < other.val; }
- inline bool operator>(const QFixed &other) const { return val > other.val; }
- inline bool operator<=(const QFixed &other) const { return val <= other.val; }
- inline bool operator>=(const QFixed &other) const { return val >= other.val; }
- inline bool operator!() const { return !val; }
+ Q_DECL_CONSTEXPR inline bool operator==(const QFixed &other) const { return val == other.val; }
+ Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &other) const { return val != other.val; }
+ Q_DECL_CONSTEXPR inline bool operator<(const QFixed &other) const { return val < other.val; }
+ Q_DECL_CONSTEXPR inline bool operator>(const QFixed &other) const { return val > other.val; }
+ Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &other) const { return val <= other.val; }
+ Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &other) const { return val >= other.val; }
+ Q_DECL_CONSTEXPR inline bool operator!() const { return !val; }
inline QFixed &operator/=(int x) { val /= x; return *this; }
inline QFixed &operator/=(const QFixed &o) {
@@ -120,7 +122,7 @@ public:
}
return *this;
}
- inline QFixed operator/(int d) const { QFixed f; f.val = val/d; return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator/(int d) const { return fromFixed(val/d); }
inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); }
inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; }
inline QFixed &operator*=(int i) { val *= i; return *this; }
@@ -136,50 +138,50 @@ public:
val = neg ? -res : res;
return *this;
}
- inline QFixed operator*(int i) const { QFixed f = *this; return (f *= i); }
- inline QFixed operator*(uint i) const { QFixed f = *this; return (f *= i); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(int i) const { return fromFixed(val * i); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(uint i) const { return fromFixed(val * i); }
inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); }
private:
- QFixed(qreal i) : val((int)(i*qreal(64))) {}
+ Q_DECL_CONSTEXPR QFixed(qreal i) : val((int)(i*qreal(64))) {}
QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; }
- inline QFixed operator+(qreal i) const { QFixed f; f.val = (val + (int)(i*qreal(64))); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); }
inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; }
- inline QFixed operator-(qreal i) const { QFixed f; f.val = (val - (int)(i*qreal(64))); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); }
inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; }
inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; }
- inline QFixed operator/(qreal d) const { QFixed f; f.val = (int)(val/d); return f; }
+ Q_DECL_CONSTEXPR inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); }
inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; }
- inline QFixed operator*(qreal d) const { QFixed f = *this; return (f *= d); }
+ Q_DECL_CONSTEXPR inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); }
int val;
};
Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE);
#define QFIXED_MAX (INT_MAX/256)
-inline int qRound(const QFixed &f) { return f.toInt(); }
-inline int qFloor(const QFixed &f) { return f.floor().truncate(); }
-
-inline QFixed operator*(int i, const QFixed &d) { return d*i; }
-inline QFixed operator+(int i, const QFixed &d) { return d+i; }
-inline QFixed operator-(int i, const QFixed &d) { return -(d-i); }
-inline QFixed operator*(uint i, const QFixed &d) { return d*i; }
-inline QFixed operator+(uint i, const QFixed &d) { return d+i; }
-inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }
-// inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }
-
-inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }
-inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }
-inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }
-inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }
-inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }
-inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }
-inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }
-inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }
-inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }
-inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }
-inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }
-inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }
+Q_DECL_CONSTEXPR inline int qRound(const QFixed &f) { return f.toInt(); }
+Q_DECL_CONSTEXPR inline int qFloor(const QFixed &f) { return f.floor().truncate(); }
+
+Q_DECL_CONSTEXPR inline QFixed operator*(int i, const QFixed &d) { return d*i; }
+Q_DECL_CONSTEXPR inline QFixed operator+(int i, const QFixed &d) { return d+i; }
+Q_DECL_CONSTEXPR inline QFixed operator-(int i, const QFixed &d) { return -(d-i); }
+Q_DECL_CONSTEXPR inline QFixed operator*(uint i, const QFixed &d) { return d*i; }
+Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i; }
+Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); }
+// Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; }
+
+Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return (i<<6) <= f.value(); }
+Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return (i<<6) >= f.value(); }
+Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return (i<<6) < f.value(); }
+Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > (i<<6); }
+Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return (i<<6) > f.value(); }
#ifndef QT_NO_DEBUG_STREAM
inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
@@ -189,29 +191,28 @@ inline QDebug &operator<<(QDebug &dbg, const QFixed &f)
struct QFixedPoint {
QFixed x;
QFixed y;
- inline QFixedPoint() {}
- inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {}
- QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); }
- static QFixedPoint fromPointF(const QPointF &p) {
+ Q_DECL_CONSTEXPR inline QFixedPoint() {}
+ Q_DECL_CONSTEXPR inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {}
+ Q_DECL_CONSTEXPR QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); }
+ Q_DECL_CONSTEXPR static QFixedPoint fromPointF(const QPointF &p) {
return QFixedPoint(QFixed::fromReal(p.x()), QFixed::fromReal(p.y()));
}
};
Q_DECLARE_TYPEINFO(QFixedPoint, Q_PRIMITIVE_TYPE);
-inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2)
+Q_DECL_CONSTEXPR inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2)
{ return QFixedPoint(p1.x - p2.x, p1.y - p2.y); }
-inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2)
+Q_DECL_CONSTEXPR inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2)
{ return QFixedPoint(p1.x + p2.x, p1.y + p2.y); }
struct QFixedSize {
QFixed width;
QFixed height;
- QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); }
- static QFixedSize fromSizeF(const QSizeF &s) {
- QFixedSize size;
- size.width = QFixed::fromReal(s.width());
- size.height = QFixed::fromReal(s.height());
- return size;
+ Q_DECL_CONSTEXPR QFixedSize() {}
+ Q_DECL_CONSTEXPR QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {}
+ Q_DECL_CONSTEXPR QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); }
+ Q_DECL_CONSTEXPR static QFixedSize fromSizeF(const QSizeF &s) {
+ return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height()));
}
};
Q_DECLARE_TYPEINFO(QFixedSize, Q_PRIMITIVE_TYPE);
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index b6966b12c3..8d05eb56ff 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -985,7 +985,6 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPen &p)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
const char *PEN_STYLES[] = {
"NoPen",
"SolidLine",
@@ -1002,11 +1001,6 @@ QDebug operator<<(QDebug dbg, const QPen &p)
<< ',' << p.dashOffset()
<< ',' << p.miterLimit() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPen to QDebug");
- return dbg;
- Q_UNUSED(p);
-#endif
}
#endif
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index 3a4860a559..ee1f7967cb 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -468,17 +468,11 @@ QRect QPolygon::boundingRect() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPolygon &a)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QPolygon(";
for (int i = 0; i < a.count(); ++i)
dbg.nospace() << a.at(i);
dbg.nospace() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPolygon to QDebug");
- return dbg;
- Q_UNUSED(a);
-#endif
}
#endif
@@ -814,17 +808,11 @@ QDataStream &operator>>(QDataStream &s, QPolygonF &a)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPolygonF &a)
{
-#ifndef Q_BROKEN_DEBUG_STREAM
dbg.nospace() << "QPolygonF(";
for (int i = 0; i < a.count(); ++i)
dbg.nospace() << a.at(i);
dbg.nospace() << ')';
return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QPolygonF to QDebug");
- return dbg;
- Q_UNUSED(a);
-#endif
}
#endif