Changeset View
Changeset View
Standalone View
Standalone View
effects/showfps/showfps.cpp
Show First 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 182 | { | |||
---|---|---|---|---|---|
196 | QVector<float> verts; | 196 | QVector<float> verts; | ||
197 | verts.reserve(12); | 197 | verts.reserve(12); | ||
198 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y; | 198 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y; | ||
199 | verts << x << y; | 199 | verts << x << y; | ||
200 | verts << x << y + MAX_TIME; | 200 | verts << x << y + MAX_TIME; | ||
201 | verts << x << y + MAX_TIME; | 201 | verts << x << y + MAX_TIME; | ||
202 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y + MAX_TIME; | 202 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y + MAX_TIME; | ||
203 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y; | 203 | verts << x + 2 * NUM_PAINTS + FPS_WIDTH << y; | ||
204 | vbo->setData(6, 2, verts.constData(), NULL); | 204 | vbo->setData(6, 2, verts.constData(), nullptr); | ||
205 | vbo->render(GL_TRIANGLES); | 205 | vbo->render(GL_TRIANGLES); | ||
206 | y += MAX_TIME; // paint up from the bottom | 206 | y += MAX_TIME; // paint up from the bottom | ||
207 | color.setRed(0); | 207 | color.setRed(0); | ||
208 | color.setGreen(0); | 208 | color.setGreen(0); | ||
209 | vbo->setColor(color); | 209 | vbo->setColor(color); | ||
210 | verts.clear(); | 210 | verts.clear(); | ||
211 | verts << x + FPS_WIDTH << y - fps; | 211 | verts << x + FPS_WIDTH << y - fps; | ||
212 | verts << x << y - fps; | 212 | verts << x << y - fps; | ||
213 | verts << x << y; | 213 | verts << x << y; | ||
214 | verts << x << y; | 214 | verts << x << y; | ||
215 | verts << x + FPS_WIDTH << y; | 215 | verts << x + FPS_WIDTH << y; | ||
216 | verts << x + FPS_WIDTH << y - fps; | 216 | verts << x + FPS_WIDTH << y - fps; | ||
217 | vbo->setData(6, 2, verts.constData(), NULL); | 217 | vbo->setData(6, 2, verts.constData(), nullptr); | ||
218 | vbo->render(GL_TRIANGLES); | 218 | vbo->render(GL_TRIANGLES); | ||
219 | 219 | | |||
220 | 220 | | |||
221 | color.setBlue(0); | 221 | color.setBlue(0); | ||
222 | vbo->setColor(color); | 222 | vbo->setColor(color); | ||
223 | QVector<float> vertices; | 223 | QVector<float> vertices; | ||
224 | for (int i = 10; | 224 | for (int i = 10; | ||
225 | i < MAX_TIME; | 225 | i < MAX_TIME; | ||
226 | i += 10) { | 226 | i += 10) { | ||
227 | vertices << x << y - i; | 227 | vertices << x << y - i; | ||
228 | vertices << x + FPS_WIDTH << y - i; | 228 | vertices << x + FPS_WIDTH << y - i; | ||
229 | } | 229 | } | ||
230 | vbo->setData(vertices.size() / 2, 2, vertices.constData(), NULL); | 230 | vbo->setData(vertices.size() / 2, 2, vertices.constData(), nullptr); | ||
231 | vbo->render(GL_LINES); | 231 | vbo->render(GL_LINES); | ||
232 | x += FPS_WIDTH; | 232 | x += FPS_WIDTH; | ||
233 | 233 | | |||
234 | // Paint FPS graph | 234 | // Paint FPS graph | ||
235 | paintFPSGraph(x, y); | 235 | paintFPSGraph(x, y); | ||
236 | x += NUM_PAINTS; | 236 | x += NUM_PAINTS; | ||
237 | 237 | | |||
238 | // Paint amount of rendered pixels graph | 238 | // Paint amount of rendered pixels graph | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 397 | if (effects->isOpenGLCompositing()) { | |||
401 | vbo->reset(); | 401 | vbo->reset(); | ||
402 | vbo->setColor(color); | 402 | vbo->setColor(color); | ||
403 | QVector<float> verts; | 403 | QVector<float> verts; | ||
404 | // First draw the lines | 404 | // First draw the lines | ||
405 | foreach (int h, lines) { | 405 | foreach (int h, lines) { | ||
406 | verts << x << y - h; | 406 | verts << x << y - h; | ||
407 | verts << x + values.count() << y - h; | 407 | verts << x + values.count() << y - h; | ||
408 | } | 408 | } | ||
409 | vbo->setData(verts.size() / 2, 2, verts.constData(), NULL); | 409 | vbo->setData(verts.size() / 2, 2, verts.constData(), nullptr); | ||
410 | vbo->render(GL_LINES); | 410 | vbo->render(GL_LINES); | ||
411 | // Then the graph values | 411 | // Then the graph values | ||
412 | int lastValue = 0; | 412 | int lastValue = 0; | ||
413 | verts.clear(); | 413 | verts.clear(); | ||
414 | for (int i = 0; i < values.count(); i++) { | 414 | for (int i = 0; i < values.count(); i++) { | ||
415 | int value = values[ i ]; | 415 | int value = values[ i ]; | ||
416 | if (colorize && value != lastValue) { | 416 | if (colorize && value != lastValue) { | ||
417 | if (!verts.isEmpty()) { | 417 | if (!verts.isEmpty()) { | ||
418 | vbo->setData(verts.size() / 2, 2, verts.constData(), NULL); | 418 | vbo->setData(verts.size() / 2, 2, verts.constData(), nullptr); | ||
419 | vbo->render(GL_LINES); | 419 | vbo->render(GL_LINES); | ||
420 | } | 420 | } | ||
421 | verts.clear(); | 421 | verts.clear(); | ||
422 | if (value <= 10) { | 422 | if (value <= 10) { | ||
423 | color = QColor(0, 255, 0); | 423 | color = QColor(0, 255, 0); | ||
424 | } else if (value <= 20) { | 424 | } else if (value <= 20) { | ||
425 | color = QColor(255, 255, 0); | 425 | color = QColor(255, 255, 0); | ||
426 | } else if (value <= 50) { | 426 | } else if (value <= 50) { | ||
427 | color = QColor(255, 0, 0); | 427 | color = QColor(255, 0, 0); | ||
428 | } else { | 428 | } else { | ||
429 | color = QColor(0, 0, 0); | 429 | color = QColor(0, 0, 0); | ||
430 | } | 430 | } | ||
431 | vbo->setColor(color); | 431 | vbo->setColor(color); | ||
432 | } | 432 | } | ||
433 | verts << x + values.count() - i << y; | 433 | verts << x + values.count() - i << y; | ||
434 | verts << x + values.count() - i << y - value; | 434 | verts << x + values.count() - i << y - value; | ||
435 | lastValue = value; | 435 | lastValue = value; | ||
436 | } | 436 | } | ||
437 | if (!verts.isEmpty()) { | 437 | if (!verts.isEmpty()) { | ||
438 | vbo->setData(verts.size() / 2, 2, verts.constData(), NULL); | 438 | vbo->setData(verts.size() / 2, 2, verts.constData(), nullptr); | ||
439 | vbo->render(GL_LINES); | 439 | vbo->render(GL_LINES); | ||
440 | } | 440 | } | ||
441 | } | 441 | } | ||
442 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 442 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
443 | if (effects->compositingType() == XRenderCompositing) { | 443 | if (effects->compositingType() == XRenderCompositing) { | ||
444 | xcb_pixmap_t pixmap = xcb_generate_id(xcbConnection()); | 444 | xcb_pixmap_t pixmap = xcb_generate_id(xcbConnection()); | ||
445 | xcb_create_pixmap(xcbConnection(), 32, pixmap, x11RootWindow(), values.count(), MAX_TIME); | 445 | xcb_create_pixmap(xcbConnection(), 32, pixmap, x11RootWindow(), values.count(), MAX_TIME); | ||
446 | XRenderPicture p(pixmap, 32); | 446 | XRenderPicture p(pixmap, 32); | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |