src/gui/painting/qbackingstore.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   496 static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately)
   496 static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately)
   497 {
   497 {
   498     if (!widget)
   498     if (!widget)
   499         return;
   499         return;
   500 
   500 
   501 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
       
   502     if (QApplicationPrivate::inSizeMove && widget->internalWinId() && !updateImmediately
       
   503         && !widget->testAttribute(Qt::WA_DontShowOnScreen)) {
       
   504         // Tell Windows to send us a paint event if we're in WM_SIZE/WM_MOVE; posted events
       
   505         // are blocked until the mouse button is released. See task 146849.
       
   506         const QRegion rgn(qt_dirtyRegion(widget));
       
   507         InvalidateRgn(widget->internalWinId(), rgn.handle(), false);
       
   508         qt_widget_private(widget)->dirty = QRegion();
       
   509         return;
       
   510     }
       
   511 #endif
       
   512 
       
   513     if (updateImmediately) {
   501     if (updateImmediately) {
   514         QEvent event(QEvent::UpdateRequest);
   502         QEvent event(QEvent::UpdateRequest);
   515         QApplication::sendEvent(widget, &event);
   503         QApplication::sendEvent(widget, &event);
   516     } else {
   504     } else {
   517         QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
   505         QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
   539     Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
   527     Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
   540     Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
   528     Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
   541     Q_ASSERT(widget->window() == tlw);
   529     Q_ASSERT(widget->window() == tlw);
   542     Q_ASSERT(!rgn.isEmpty());
   530     Q_ASSERT(!rgn.isEmpty());
   543 
   531 
       
   532 #ifndef QT_NO_GRAPHICSEFFECT
   544     widget->d_func()->invalidateGraphicsEffectsRecursively();
   533     widget->d_func()->invalidateGraphicsEffectsRecursively();
       
   534 #endif //QT_NO_GRAPHICSEFFECT
   545 
   535 
   546     if (widget->d_func()->paintOnScreen()) {
   536     if (widget->d_func()->paintOnScreen()) {
   547         if (widget->d_func()->dirty.isEmpty()) {
   537         if (widget->d_func()->dirty.isEmpty()) {
   548             widget->d_func()->dirty = rgn;
   538             widget->d_func()->dirty = rgn;
   549             sendUpdateRequest(widget, updateImmediately);
   539             sendUpdateRequest(widget, updateImmediately);
   569         return; // Already dirty.
   559         return; // Already dirty.
   570     }
   560     }
   571 
   561 
   572     if (invalidateBuffer) {
   562     if (invalidateBuffer) {
   573         const bool eventAlreadyPosted = !dirty.isEmpty();
   563         const bool eventAlreadyPosted = !dirty.isEmpty();
       
   564 #ifndef QT_NO_GRAPHICSEFFECT
   574         if (widget->d_func()->graphicsEffect)
   565         if (widget->d_func()->graphicsEffect)
   575             dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
   566             dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
   576         else
   567         else
       
   568 #endif //QT_NO_GRAPHICSEFFECT
   577             dirty += rgn.translated(offset);
   569             dirty += rgn.translated(offset);
   578         if (!eventAlreadyPosted || updateImmediately)
   570         if (!eventAlreadyPosted || updateImmediately)
   579             sendUpdateRequest(tlw, updateImmediately);
   571             sendUpdateRequest(tlw, updateImmediately);
   580         return;
   572         return;
   581     }
   573     }
   586         return;
   578         return;
   587     }
   579     }
   588 
   580 
   589     if (widget->d_func()->inDirtyList) {
   581     if (widget->d_func()->inDirtyList) {
   590         if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
   582         if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
       
   583 #ifndef QT_NO_GRAPHICSEFFECT
   591             if (widget->d_func()->graphicsEffect)
   584             if (widget->d_func()->graphicsEffect)
   592                 widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
   585                 widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
   593             else
   586             else
       
   587 #endif //QT_NO_GRAPHICSEFFECT
   594                 widget->d_func()->dirty += rgn;
   588                 widget->d_func()->dirty += rgn;
   595         }
   589         }
   596     } else {
   590     } else {
   597         addDirtyWidget(widget, rgn);
   591         addDirtyWidget(widget, rgn);
   598     }
   592     }
   616     Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
   610     Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
   617     Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
   611     Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
   618     Q_ASSERT(widget->window() == tlw);
   612     Q_ASSERT(widget->window() == tlw);
   619     Q_ASSERT(!rect.isEmpty());
   613     Q_ASSERT(!rect.isEmpty());
   620 
   614 
       
   615 #ifndef QT_NO_GRAPHICSEFFECT
   621     widget->d_func()->invalidateGraphicsEffectsRecursively();
   616     widget->d_func()->invalidateGraphicsEffectsRecursively();
       
   617 #endif //QT_NO_GRAPHICSEFFECT
   622 
   618 
   623     if (widget->d_func()->paintOnScreen()) {
   619     if (widget->d_func()->paintOnScreen()) {
   624         if (widget->d_func()->dirty.isEmpty()) {
   620         if (widget->d_func()->dirty.isEmpty()) {
   625             widget->d_func()->dirty = QRegion(rect);
   621             widget->d_func()->dirty = QRegion(rect);
   626             sendUpdateRequest(widget, updateImmediately);
   622             sendUpdateRequest(widget, updateImmediately);
   889         destRect = destRect.translated(dx, dy).intersected(clipR);
   885         destRect = destRect.translated(dx, dy).intersected(clipR);
   890     const QRect sourceRect(destRect.translated(-dx, -dy));
   886     const QRect sourceRect(destRect.translated(-dx, -dy));
   891     const QRect parentRect(rect & clipR);
   887     const QRect parentRect(rect & clipR);
   892 
   888 
   893     bool accelerateMove = accelEnv && isOpaque
   889     bool accelerateMove = accelEnv && isOpaque
   894 #ifndef QT_NO_GRAPHICSCVIEW
   890 #ifndef QT_NO_GRAPHICSVIEW
   895                           // No accelerate move for proxy widgets.
   891                           // No accelerate move for proxy widgets.
   896                           && !tlw->d_func()->extra->proxyWidget
   892                           && !tlw->d_func()->extra->proxyWidget
   897 #endif
   893 #endif
   898                           && !isOverlapped(sourceRect) && !isOverlapped(destRect);
   894                           && !isOverlapped(sourceRect) && !isOverlapped(destRect);
   899 
   895 
   951     QTLWExtra* x = tlw->d_func()->topData();
   947     QTLWExtra* x = tlw->d_func()->topData();
   952     if (x->inTopLevelResize)
   948     if (x->inTopLevelResize)
   953         return;
   949         return;
   954 
   950 
   955     QWidgetBackingStore *wbs = x->backingStore;
   951     QWidgetBackingStore *wbs = x->backingStore;
       
   952     if (!wbs)
       
   953         return;
   956 
   954 
   957     static int accelEnv = -1;
   955     static int accelEnv = -1;
   958     if (accelEnv == -1) {
   956     if (accelEnv == -1) {
   959         accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
   957         accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
   960     }
   958     }
  1187 
  1185 
  1188         const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
  1186         const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
  1189                                            : wd->dirty);
  1187                                            : wd->dirty);
  1190         toClean += widgetDirty;
  1188         toClean += widgetDirty;
  1191 
  1189 
  1192 #ifndef QT_NO_GRAPHICSCVIEW
  1190 #ifndef QT_NO_GRAPHICSVIEW
  1193         if (tlw->d_func()->extra->proxyWidget) {
  1191         if (tlw->d_func()->extra->proxyWidget) {
  1194             resetWidget(w);
  1192             resetWidget(w);
  1195             continue;
  1193             continue;
  1196         }
  1194         }
  1197 #endif
  1195 #endif