summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-07-21 14:42:46 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-07-21 14:42:46 +0200
commit7b3b6b5afaaf1db1bfbfa9b56fa7b955a61344bd (patch)
tree8be0d601853d021434e03cef9a9cfd64b3708e92 /src/gui/painting
parent070fc2f694beaa56fc191f1a3f6a1b9812f4ed35 (diff)
parent56defa4725508608a85e2813b85af3a7fcefefa0 (diff)
Merge remote branch 'gerrit/master' into refactor
Conflicts: examples/opengl/cube/main.cpp examples/widgets/applicationicon/main.cpp examples/widgets/orientation/main.cpp src/gui/image/qicon.cpp src/gui/image/qimage.h src/gui/image/qpixmap.h src/gui/image/qpixmap_mac.cpp src/gui/kernel/qapplication.cpp src/gui/kernel/qpalette.cpp src/gui/kernel/qwidget.cpp src/gui/styles/qmacstyle_mac.mm src/gui/widgets/qmenubar.cpp src/gui/widgets/qslider.cpp src/opengl/qwindowsurface_gl.cpp tests/auto/qvariant/qvariant.pro tests/benchmarks/corelib/kernel/qobject/qobject.pro tests/benchmarks/gui/animation/qanimation/qanimation.pro tests/benchmarks/gui/graphicsview/qgraphicsanchorlayout/qgraphicsanchorlayout.pro tests/benchmarks/gui/graphicsview/qgraphicsitem/qgraphicsitem.pro tests/benchmarks/gui/graphicsview/qgraphicsscene/qgraphicsscene.pro tests/benchmarks/gui/graphicsview/qgraphicsview/qgraphicsview.pro tests/benchmarks/gui/graphicsview/qgraphicswidget/qgraphicswidget.pro tests/benchmarks/gui/image/qimagereader/qimagereader.pro tests/benchmarks/gui/itemviews/qtableview/qtableview.pro tests/benchmarks/gui/kernel/qapplication/qapplication.pro tests/benchmarks/gui/kernel/qwidget/qwidget.pro tests/benchmarks/gui/painting/qpainter/qpainter.pro tests/benchmarks/gui/painting/qtbench/qtbench.pro tests/benchmarks/gui/painting/qtracebench/qtracebench.pro tests/benchmarks/gui/text/qtext/qtext.pro Change-Id: I4b911c795ecb29d73b6a7fd18819711b49478a30
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbrush.cpp46
-rw-r--r--src/gui/painting/qpainter.cpp9
-rw-r--r--src/gui/painting/qpen.cpp31
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp2
4 files changed, 43 insertions, 45 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index d644bbace1..429ed0b25b 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -112,6 +112,7 @@ QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
return pm;
}
+static void qt_cleanup_brush_pattern_image_cache();
class QBrushPatternImageCache
{
public:
@@ -123,6 +124,7 @@ public:
void init()
{
+ qAddPostRoutine(qt_cleanup_brush_pattern_image_cache);
for (int style = Qt::Dense1Pattern; style <= Qt::DiagCrossPattern; ++style) {
int i = style - Qt::Dense1Pattern;
m_images[i][0] = QImage(qt_patternForBrush(style, 0), 8, 8, 1, QImage::Format_MonoLSB);
@@ -153,11 +155,7 @@ private:
bool m_initialized;
};
-static void qt_cleanup_brush_pattern_image_cache();
-Q_GLOBAL_STATIC_WITH_INITIALIZER(QBrushPatternImageCache, qt_brushPatternImageCache,
- {
- qAddPostRoutine(qt_cleanup_brush_pattern_image_cache);
- })
+Q_GLOBAL_STATIC(QBrushPatternImageCache, qt_brushPatternImageCache)
static void qt_cleanup_brush_pattern_image_cache()
{
@@ -339,33 +337,29 @@ struct QBrushDataPointerDeleter
\sa Qt::BrushStyle, QPainter, QColor
*/
-#ifndef QT_NO_THREAD
-// Special deleter that only deletes if the ref-count goes to zero
-template <>
-class QGlobalStaticDeleter<QBrushData>
+class QNullBrushData
{
public:
- QGlobalStatic<QBrushData> &globalStatic;
- QGlobalStaticDeleter(QGlobalStatic<QBrushData> &_globalStatic)
- : globalStatic(_globalStatic)
- { }
-
- inline ~QGlobalStaticDeleter()
+ QBrushData *brush;
+ QNullBrushData() : brush(new QBrushData)
+ {
+ brush->ref = 1;
+ brush->style = Qt::BrushStyle(0);
+ brush->color = Qt::black;
+ }
+ ~QNullBrushData()
{
- if (!globalStatic.pointer->ref.deref())
- delete globalStatic.pointer;
- globalStatic.pointer = 0;
- globalStatic.destroyed = true;
+ if (!brush->ref.deref())
+ delete brush;
+ brush = 0;
}
};
-#endif
-Q_GLOBAL_STATIC_WITH_INITIALIZER(QBrushData, nullBrushInstance,
- {
- x->ref = 1;
- x->style = Qt::BrushStyle(0);
- x->color = Qt::black;
- })
+Q_GLOBAL_STATIC(QNullBrushData, nullBrushInstance_holder)
+static QBrushData *nullBrushInstance()
+{
+ return nullBrushInstance_holder()->brush;
+}
static bool qbrush_check_type(Qt::BrushStyle style) {
switch (style) {
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index d5b9f97378..e45d773169 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2799,6 +2799,9 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op)
return;
}
+ if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
+ op = Qt::ReplaceClip;
+
d->state->clipRegion = rect;
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
@@ -2854,6 +2857,9 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
return;
}
+ if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
+ op = Qt::ReplaceClip;
+
d->state->clipRegion = r;
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
@@ -3259,6 +3265,9 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
return;
}
+ if (d->state->clipOperation == Qt::NoClip && op == Qt::IntersectClip)
+ op = Qt::ReplaceClip;
+
d->state->clipPath = path;
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index 7185f0d346..a79e3a0cd2 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -244,30 +244,25 @@ inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle
static const Qt::PenCapStyle qpen_default_cap = Qt::SquareCap;
static const Qt::PenJoinStyle qpen_default_join = Qt::BevelJoin;
-#ifndef QT_NO_THREAD
-// Special deleter that only deletes if the ref-count goes to zero
-template <>
-class QGlobalStaticDeleter<QPenPrivate>
+class QPenDataHolder
{
public:
- QGlobalStatic<QPenPrivate> &globalStatic;
- QGlobalStaticDeleter(QGlobalStatic<QPenPrivate> &_globalStatic)
- : globalStatic(_globalStatic)
+ QPenData *pen;
+ QPenDataHolder(const QBrush &brush, qreal width, Qt::PenStyle penStyle,
+ Qt::PenCapStyle penCapStyle, Qt::PenJoinStyle _joinStyle)
+ : pen(new QPenData(brush, width, penStyle, penCapStyle, _joinStyle))
{ }
-
- inline ~QGlobalStaticDeleter()
+ ~QPenDataHolder()
{
- if (!globalStatic.pointer->ref.deref())
- delete globalStatic.pointer;
- globalStatic.pointer = 0;
- globalStatic.destroyed = true;
+ if (!pen->ref.deref())
+ delete pen;
+ pen = 0;
}
};
-#endif
-Q_GLOBAL_STATIC_WITH_ARGS(QPenData, defaultPenInstance,
+Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, defaultPenInstance,
(Qt::black, 0, Qt::SolidLine, qpen_default_cap, qpen_default_join))
-Q_GLOBAL_STATIC_WITH_ARGS(QPenData, nullPenInstance,
+Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, nullPenInstance,
(Qt::black, 0, Qt::NoPen, qpen_default_cap, qpen_default_join))
/*!
@@ -276,7 +271,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QPenData, nullPenInstance,
QPen::QPen()
{
- d = defaultPenInstance();
+ d = defaultPenInstance()->pen;
d->ref.ref();
}
@@ -289,7 +284,7 @@ QPen::QPen()
QPen::QPen(Qt::PenStyle style)
{
if (style == Qt::NoPen) {
- d = nullPenInstance();
+ d = nullPenInstance()->pen;
d->ref.ref();
} else {
d = new QPenData(Qt::black, 0, style, qpen_default_cap, qpen_default_join);
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 53fefa4fae..665efe07f2 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -198,7 +198,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
Coord c = { 0, 0, // will be filled in later
glyph_width,
glyph_height, // texture coords
- metrics.x.round().truncate(),
+ metrics.x.truncate(),
-metrics.y.truncate() }; // baseline for horizontal scripts
listItemCoordinates.insert(key, c);