Changeset View
Changeset View
Standalone View
Standalone View
effects/showfps/showfps.cpp
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 117 | default: | |||
---|---|---|---|---|---|
118 | fpsTextRect = QRect(x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME); | 118 | fpsTextRect = QRect(x, y, FPS_WIDTH + NUM_PAINTS, MAX_TIME); | ||
119 | textAlign = Qt::AlignTop | Qt::AlignRight; | 119 | textAlign = Qt::AlignTop | Qt::AlignRight; | ||
120 | break; | 120 | break; | ||
121 | } | 121 | } | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | void ShowFpsEffect::prePaintScreen(ScreenPrePaintData& data, int time) | 124 | void ShowFpsEffect::prePaintScreen(ScreenPrePaintData& data, int time) | ||
125 | { | 125 | { | ||
126 | if (time == 0) { | 126 | bool wasRunning = t.isValid(); | ||
zzag: `wasRunning` is unused. | |||||
zzag: Please address this comment before landing. | |||||
127 | // TODO optimized away | 127 | frames[ frames_pos ] = t.restart(); | ||
128 | } | | |||
129 | t.start(); | | |||
130 | frames[ frames_pos ] = t.minute() * 60000 + t.second() * 1000 + t.msec(); | | |||
131 | if (++frames_pos == MAX_FPS) | 128 | if (++frames_pos == MAX_FPS) | ||
132 | frames_pos = 0; | 129 | frames_pos = 0; | ||
133 | effects->prePaintScreen(data, time); | 130 | effects->prePaintScreen(data, time); | ||
134 | data.paint += fps_rect; | 131 | data.paint += fps_rect; | ||
135 | 132 | | |||
136 | paint_size[ paints_pos ] = 0; | 133 | paint_size[ paints_pos ] = 0; | ||
137 | } | 134 | } | ||
138 | 135 | | |||
Show All 14 Lines | |||||
153 | 150 | | |||
154 | void ShowFpsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) | 151 | void ShowFpsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) | ||
155 | { | 152 | { | ||
156 | effects->paintScreen(mask, region, data); | 153 | effects->paintScreen(mask, region, data); | ||
157 | int fps = 0; | 154 | int fps = 0; | ||
158 | for (int i = 0; | 155 | for (int i = 0; | ||
159 | i < MAX_FPS; | 156 | i < MAX_FPS; | ||
160 | ++i) | 157 | ++i) | ||
161 | if (abs(t.minute() * 60000 + t.second() * 1000 + t.msec() - frames[ i ]) < 1000) | 158 | if (abs(t.elapsed() - frames[ i ]) < 1000) | ||
162 | ++fps; // count all frames in the last second | 159 | ++fps; // count all frames in the last second | ||
163 | if (fps > MAX_TIME) | 160 | if (fps > MAX_TIME) | ||
164 | fps = MAX_TIME; // keep it the same height | 161 | fps = MAX_TIME; // keep it the same height | ||
165 | if (effects->isOpenGLCompositing()) { | 162 | if (effects->isOpenGLCompositing()) { | ||
166 | paintGL(fps, data.projectionMatrix()); | 163 | paintGL(fps, data.projectionMatrix()); | ||
167 | glFinish(); // make sure all rendering is done | 164 | glFinish(); // make sure all rendering is done | ||
168 | } | 165 | } | ||
169 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 166 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines |
wasRunning is unused.