Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. void MWindow::paintEvent(QPaintEvent *event)
  2. {
  3. Q_D(MWindow);
  4. #ifdef M_USE_OPENGL
  5. if (!MApplication::softwareRendering()) {
  6. MGLES2Renderer::activate(d->glContext);
  7. }
  8. #endif // M_USE_OPENGL
  9. if (d->beforeFirstPaintEvent) {
  10. d->beforeFirstPaintEvent = false;
  11. d->disableAutomaticBackgroundRepainting();
  12. }
  13.  
  14. // FIXME: disabled for the meego graphicssystem right now until we have a solution for NB#205680
  15. if (!isOnDisplay() && !MGraphicsSystemHelper::isRunningMeeGoGraphicsSystem()) {
  16. // we allow some paint events when we are not visible as we might have a race between
  17. // the visibility information and the paint events
  18. if (d->invisiblePaintCounter < d->allowedPaintEventsWhenInvisible) {
  19. mDebug("MWindow::paintEvent") << "Application is not visible. Paint event allowed nevertheless.";
  20. ++d->invisiblePaintCounter;
  21. } else {
  22. mWarning("MWindow::paintEvent") << "Application is not visible. Paint event discarded. Make sure the application does not paint in the first place.";
  23. event->accept();
  24. d->discardedPaintEvent = true;
  25. return;
  26. }
  27. }
  28.  
  29. if (isInSwitcher()) {
  30. if (!d->timeSinceLastPaintInSwitcher.isValid()) {
  31. d->timeSinceLastPaintInSwitcher.start();
  32. d->updateIsPending = false;
  33. } else {
  34. const int maxFpsInSwitcher = 5;
  35. const int minDelay = 1000. / maxFpsInSwitcher;
  36. qint64 msSinceLastPaint = d->timeSinceLastPaintInSwitcher.elapsed();
  37. if (msSinceLastPaint < minDelay) {
  38. event->accept();
  39. if (!d->updateIsPending) {
  40. // trigger a new paint event as otherwise the screen may not be up to date
  41. QTimer::singleShot(minDelay, viewport(), SLOT(update()));
  42. d->updateIsPending = true;
  43. }
  44. return;
  45. } else {
  46. d->timeSinceLastPaintInSwitcher.restart();
  47. d->updateIsPending = false;
  48. }
  49. }
  50. }
  51.  
  52. QGraphicsView::paintEvent(event);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement