summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qcolor.cpp11
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h4
-rw-r--r--src/gui/painting/qpaintengineex.cpp16
-rw-r--r--src/gui/painting/qpainter.cpp58
-rw-r--r--src/gui/painting/qprintengine_pdf.cpp26
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp8
6 files changed, 84 insertions, 39 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index f51dc36..d6d288e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -934,8 +934,7 @@ void QColor::setRgb(int r, int g, int b, int a)
/*!
\fn QRgb QColor::rgba() const
- Returns the RGB value of the color. Unlike rgb(), the alpha is not
- stripped.
+ Returns the RGB value of the color, including its alpha.
For an invalid color, the alpha value of the returned color is unspecified.
@@ -950,8 +949,7 @@ QRgb QColor::rgba() const
}
/*!
- Sets the RGBA value to \a rgba. Unlike setRgb(QRgb rgb), this function does
- not ignore the alpha.
+ Sets the RGB value to \a rgba, including its alpha.
\sa rgba(), rgb()
*/
@@ -968,8 +966,7 @@ void QColor::setRgba(QRgb rgba)
/*!
\fn QRgb QColor::rgb() const
- Returns the RGB value of the color. The alpha is stripped for
- compatibility.
+ Returns the RGB value of the color. The alpha value is opaque.
\sa getRgb(), rgba()
*/
@@ -983,7 +980,7 @@ QRgb QColor::rgb() const
/*!
\overload
- Sets the RGB value to \a rgb, ignoring the alpha.
+ Sets the RGB value to \a rgb. The alpha value is set to opaque.
*/
void QColor::setRgb(QRgb rgb)
{
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index b937f66..a1c73cc 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -264,13 +264,13 @@ private:
#endif // Q_OS_SYMBIAN && QT_NO_FREETYPE
inline void ensureBrush(const QBrush &brush) {
- if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags)
+ if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags))
updateBrush(brush);
}
inline void ensureBrush() { ensureBrush(state()->brush); }
inline void ensurePen(const QPen &pen) {
- if (!qpen_fast_equals(state()->lastPen, pen) || state()->strokeFlags)
+ if (!qpen_fast_equals(state()->lastPen, pen) || (pen.style() != Qt::NoPen && state()->strokeFlags))
updatePen(pen);
}
inline void ensurePen() { ensurePen(state()->pen); }
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 058f226..4f2fffa 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -417,13 +417,6 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
} else if (style == Qt::NoPen) {
d->activeStroker = 0;
} else {
- // ### re-enable...
- if (pen.isCosmetic()) {
- d->dasher.setClipRect(d->exDeviceRect);
- } else {
- QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
- d->dasher.setClipRect(clipRect);
- }
d->dasher.setDashPattern(pen.dashPattern());
d->dasher.setDashOffset(pen.dashOffset());
d->activeStroker = &d->dasher;
@@ -434,6 +427,15 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
return;
}
+ if (pen.style() > Qt::SolidLine) {
+ if (pen.isCosmetic()) {
+ d->activeStroker->setClipRect(d->exDeviceRect);
+ } else {
+ QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
+ d->activeStroker->setClipRect(clipRect);
+ }
+ }
+
const QPainterPath::ElementType *types = path.elements();
const qreal *points = path.points();
int pointCount = path.elementCount();
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index a98ac10..cde6a2d 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1374,9 +1374,6 @@ void QPainterPrivate::updateState(QPainterState *newState)
opacity with non-smooth transformation mode
(\c QPainter::SmoothPixmapTransform not enabled as a render hint).
- \o Text drawing with regular font sizes with simple
- transformations with solid colors using no or 8-bit antialiasing.
-
\o Rectangle fills with solid color, two-color linear gradients
and simple transforms.
@@ -1984,9 +1981,14 @@ QPaintEngine *QPainter::paintEngine() const
/*!
\since 4.6
- Flushes the painting pipeline and prepares for the user issuing
- commands directly to the underlying graphics context. Must be
- followed by a call to endNativePainting().
+ Flushes the painting pipeline and prepares for the user issuing commands
+ directly to the underlying graphics context. Must be followed by a call to
+ endNativePainting().
+
+ Note that only the states the underlying paint engine changes will be reset
+ to their respective default states. If, for example, the OpenGL polygon
+ mode is changed by the user inside a beginNativePaint()/endNativePainting()
+ block, it will not be reset to the default state by endNativePainting().
Here is an example that shows intermixing of painter commands
and raw OpenGL commands:
@@ -2010,9 +2012,9 @@ void QPainter::beginNativePainting()
/*!
\since 4.6
- Restores the painter after manually issuing native painting commands.
- Lets the painter restore any native state that it relies on before
- calling any other painter commands.
+ Restores the painter after manually issuing native painting commands. Lets
+ the painter restore any native state that it relies on before calling any
+ other painter commands.
\sa beginNativePainting()
*/
@@ -7380,10 +7382,15 @@ struct QPaintDeviceRedirection
typedef QList<QPaintDeviceRedirection> QPaintDeviceRedirectionList;
Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections)
Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex)
+Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic)
/*!
\threadsafe
+ \obsolete
+
+ Please use QWidget::render() instead.
+
Redirects all paint commands for the given paint \a device, to the
\a replacement device. The optional point \a offset defines an
offset within the source device.
@@ -7393,9 +7400,10 @@ Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex)
device's painter (if any) before redirecting. Call
restoreRedirected() to restore the previous redirection.
- In general, you'll probably find that calling
- QPixmap::grabWidget() or QPixmap::grabWindow() is an easier
- solution.
+ \warning Making use of redirections in the QPainter API implies
+ that QPainter::begin() and QPaintDevice destructors need to hold
+ a mutex for a short period. This can impact performance. Use of
+ QWidget::render is strongly encouraged.
\sa redirected(), restoreRedirected()
*/
@@ -7427,14 +7435,24 @@ void QPainter::setRedirected(const QPaintDevice *device,
Q_ASSERT(redirections != 0);
*redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset,
hadInternalWidgetRedirection ? redirections->size() - 1 : -1);
+ globalRedirectionAtomic()->ref();
}
/*!
\threadsafe
+ \obsolete
+
+ Using QWidget::render() obsoletes the use of this function.
+
Restores the previous redirection for the given \a device after a
call to setRedirected().
+ \warning Making use of redirections in the QPainter API implies
+ that QPainter::begin() and QPaintDevice destructors need to hold
+ a mutex for a short period. This can impact performance. Use of
+ QWidget::render is strongly encouraged.
+
\sa redirected()
*/
void QPainter::restoreRedirected(const QPaintDevice *device)
@@ -7445,6 +7463,7 @@ void QPainter::restoreRedirected(const QPaintDevice *device)
Q_ASSERT(redirections != 0);
for (int i = redirections->size()-1; i >= 0; --i) {
if (redirections->at(i) == device) {
+ globalRedirectionAtomic()->deref();
const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex;
redirections->removeAt(i);
// Restore the internal widget redirection, i.e. remove it from the global
@@ -7466,9 +7485,18 @@ void QPainter::restoreRedirected(const QPaintDevice *device)
/*!
\threadsafe
+ \obsolete
+
+ Using QWidget::render() obsoletes the use of this function.
+
Returns the replacement for given \a device. The optional out
parameter \a offset returns the offset within the replaced device.
+ \warning Making use of redirections in the QPainter API implies
+ that QPainter::begin() and QPaintDevice destructors need to hold
+ a mutex for a short period. This can impact performance. Use of
+ QWidget::render is strongly encouraged.
+
\sa setRedirected(), restoreRedirected()
*/
QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
@@ -7481,6 +7509,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
return widgetPrivate->redirected(offset);
}
+ if (*globalRedirectionAtomic() == 0)
+ return 0;
+
QMutexLocker locker(globalRedirectionsMutex());
QPaintDeviceRedirectionList *redirections = globalRedirections();
Q_ASSERT(redirections != 0);
@@ -7498,6 +7529,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
void qt_painter_removePaintDevice(QPaintDevice *dev)
{
+ if (*globalRedirectionAtomic() == 0)
+ return;
+
QMutex *mutex = 0;
QT_TRY {
mutex = globalRedirectionsMutex();
diff --git a/src/gui/painting/qprintengine_pdf.cpp b/src/gui/painting/qprintengine_pdf.cpp
index e3a2461..b8bf15e 100644
--- a/src/gui/painting/qprintengine_pdf.cpp
+++ b/src/gui/painting/qprintengine_pdf.cpp
@@ -931,14 +931,24 @@ void QPdfEnginePrivate::writeHeader()
void QPdfEnginePrivate::writeInfo()
{
info = addXrefEntry(-1);
- xprintf("<<\n"
- "/Title (%s)\n"
-// "/Author (%s)\n"
- "/Creator (%s)\n"
- "/Producer (Qt " QT_VERSION_STR " (C) 2009 Nokia Corporation and/or its subsidiary(-ies))\n",
- title.toUtf8().constData(),
-// author.toUtf8().constData(),
- creator.toUtf8().constData());
+
+ // The 'text string' type in PDF is encoded either as PDFDocEncoding, or
+ // Unicode UTF-16 with a Unicode byte order mark as the first character
+ // (0xfeff), with the high-order byte first.
+ QByteArray array("<<\n/Title (\xfe\xff");
+ const ushort *utf16Title = title.utf16();
+ for (int i=0; i < title.size(); ++i) {
+ array.append((*(utf16Title + i)) >> 8);
+ array.append((*(utf16Title + i)) & 0xff);
+ }
+ array.append(")\n/Creator (\xfe\xff");
+ const ushort *utf16Creator = creator.utf16();
+ for (int i=0; i < creator.size(); ++i) {
+ array.append((*(utf16Creator + i)) >> 8);
+ array.append((*(utf16Creator + i)) & 0xff);
+ }
+ array.append(")\n/Producer (Qt " QT_VERSION_STR " (C) 2010 Nokia Corporation and/or its subsidiary(-ies))\n");
+ write(array);
QDateTime now = QDateTime::currentDateTime().toUTC();
QTime t = now.time();
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
index b8eaead..b41dc2c 100644
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ b/src/gui/painting/qwindowsurface_s60.cpp
@@ -145,10 +145,12 @@ QImage* QS60WindowSurface::buffer(const QWidget *widget)
void QS60WindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &)
{
- const QVector<QRect> subRects = region.rects();
- for (int i = 0; i < subRects.count(); ++i) {
- TRect tr = qt_QRect2TRect(subRects[i]);
+ QWExtra *extra = widget->d_func()->extraData();
+ if (extra && !extra->inExpose) {
+ extra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
+ TRect tr = qt_QRect2TRect(region.boundingRect());
widget->winId()->DrawNow(tr);
+ extra->inExpose = false;
}
}