| 4029 | |
| 4030 | |
| 4031 | void Widget::startRefreshTimer(bool on) |
| 4032 | // ---------------------------------------------------------------------------- |
| 4033 | // Make sure refresh timer runs if it has to |
| 4034 | // ---------------------------------------------------------------------------- |
| 4035 | { |
| 4036 | if (inOfflineRendering) |
| 4037 | return; |
| 4038 | |
| 4039 | if (!on) |
| 4040 | { |
| 4041 | #ifdef MACOSX_DISPLAYLINK |
| 4042 | if (displayLink && displayLinkStarted) |
| 4043 | { |
| 4044 | CVDisplayLinkStop(displayLink); |
| 4045 | displayLinkStarted = false; |
| 4046 | pendingDisplayLinkEvent = false; |
| 4047 | QCoreApplication::removePostedEvents(this, DisplayLink); |
| 4048 | } |
| 4049 | #else |
| 4050 | timer.stop(); |
| 4051 | #endif |
| 4052 | QCoreApplication::removePostedEvents(this, QEvent::Timer); |
| 4053 | return; |
| 4054 | } |
| 4055 | |
| 4056 | if (inError || !animated) |
| 4057 | return; |
| 4058 | |
| 4059 | #ifdef MACOSX_DISPLAYLINK |
| 4060 | if (!displayLink) |
| 4061 | { |
| 4062 | // Create display link |
| 4063 | CVDisplayLinkCreateWithCGDisplay(getCurrentDisplayID(this), |
| 4064 | &displayLink); |
| 4065 | // Set render callback |
| 4066 | if (displayLink) |
| 4067 | CVDisplayLinkSetOutputCallback(displayLink, &displayLinkCallback, |
| 4068 | this); |
| 4069 | } |
| 4070 | if (displayLink && !displayLinkStarted) |
| 4071 | { |
| 4072 | CVDisplayLinkStart(displayLink); |
| 4073 | displayLinkStarted = true; |
| 4074 | } |
| 4075 | #else |
| 4076 | assert(space || !"No space layout"); |
| 4077 | double next = space->NextRefresh(); |
| 4078 | if (next != DBL_MAX) |
| 4079 | { |
| 4080 | double now = trueCurrentTime(); |
| 4081 | double remaining = next - now; |
| 4082 | if (remaining <= 0) |
| 4083 | remaining = 0.001; |
| 4084 | int ms = remaining * 1000; |
| 4085 | IFTRACE(layoutevents) |
| 4086 | std::cerr << "Starting refresh timer: " << ms << " ms (current " |
| 4087 | "time " << now << " next refresh " << next |
| 4088 | << ")\n"; |
no test coverage detected