diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-01 15:36:05 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-02-01 15:36:05 (GMT) |
commit | 7e8d20de90af2e5ea199b6a92830cc223cea777b (patch) | |
tree | 89364f787fad44c2fdea1de6358140c568a82e7a /src/gui/painting/qpainter.cpp | |
parent | f3cf5dd98e321980984288a1768f3375a8349800 (diff) | |
parent | afe0f17eb5974adbedd1bc1f2fcd98459d92df47 (diff) | |
download | Qt-7e8d20de90af2e5ea199b6a92830cc223cea777b.zip Qt-7e8d20de90af2e5ea199b6a92830cc223cea777b.tar.gz Qt-7e8d20de90af2e5ea199b6a92830cc223cea777b.tar.bz2 |
Merge branch '4.6' into qstatictext-4.6
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4f675ae..4338a5f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1376,9 +1376,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. @@ -1986,9 +1983,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: @@ -2012,9 +2014,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() */ @@ -7502,10 +7504,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. @@ -7515,9 +7522,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() */ @@ -7549,14 +7557,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) @@ -7567,6 +7585,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 @@ -7588,9 +7607,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) @@ -7603,6 +7631,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) return widgetPrivate->redirected(offset); } + if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0) + return 0; + QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); Q_ASSERT(redirections != 0); @@ -7620,6 +7651,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) void qt_painter_removePaintDevice(QPaintDevice *dev) { + if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0) + return; + QMutex *mutex = 0; QT_TRY { mutex = globalRedirectionsMutex(); |