68 lines
2.9 KiB
Python
68 lines
2.9 KiB
Python
"""Temporary GTK desktop workload; F9 toggles a decoded-video echo marker."""
|
|
import gi, time, json
|
|
gi.require_version('Gtk', '3.0')
|
|
from gi.repository import Gtk, Gdk, GLib
|
|
|
|
started = time.monotonic()
|
|
draws = 0
|
|
white = False
|
|
win = Gtk.Window(title='VDI Ubuntu quality benchmark')
|
|
area = Gtk.DrawingArea()
|
|
win.add(area)
|
|
area.set_can_focus(True)
|
|
area.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
|
|
|
|
def event(w, e):
|
|
global white
|
|
if getattr(e, 'keyval', None) == Gdk.KEY_F9:
|
|
white = not white
|
|
area.queue_draw_area(2100, 80, 300, 100)
|
|
print(json.dumps({'event': e.type.value_nick, 'keyval': getattr(e, 'keyval', None),
|
|
'button': getattr(e, 'button', None), 'x': getattr(e, 'x', None),
|
|
'y': getattr(e, 'y', None), 't': time.monotonic()}), flush=True)
|
|
return False
|
|
|
|
def draw(w, cr):
|
|
global draws
|
|
draws += 1
|
|
width, height = w.get_allocated_width(), w.get_allocated_height()
|
|
elapsed = time.monotonic() - started
|
|
cr.set_source_rgb(.96, .97, .99); cr.paint()
|
|
cr.select_font_face('sans'); cr.set_font_size(28); cr.set_source_rgb(.08, .12, .18)
|
|
cr.move_to(60, 60); cr.show_text('Ubuntu: native resolution / text / motion / input')
|
|
cr.set_font_size(20); cr.move_to(60, 100); cr.show_text(f'Native desktop: {width} x {height}')
|
|
for row, size in enumerate([12, 14, 16, 18, 20, 24]):
|
|
cr.set_font_size(size); cr.move_to(60, 155 + row * 45)
|
|
cr.show_text(f'{size}px Cloud desktop 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz')
|
|
for i in range(600):
|
|
cr.set_source_rgb(*( (0,0,0) if i % 2 else (1,1,1) ))
|
|
cr.rectangle(60+i, 445, 1, 80); cr.fill()
|
|
for i, color in enumerate([(1,0,0),(0,.65,0),(0,.2,1),(.6,0,.6)]):
|
|
cr.set_source_rgb(*color); cr.set_font_size(18); cr.move_to(60, 565+i*28)
|
|
cr.show_text('Color text 0123456789 - desktop quality test')
|
|
for i, level in enumerate([0, 8, 16, 24, 32, 64, 128, 192, 223, 235, 247, 255]):
|
|
cr.set_source_rgb(*([level/255]*3)); cr.rectangle(900+i*70, 450, 70, 80); cr.fill()
|
|
cr.set_source_rgb(*([1 if white else 0]*3)); cr.rectangle(2100,80,300,100);cr.fill()
|
|
for i in range(5):
|
|
x=70+((elapsed*220+i*173) % max(200,width-400))
|
|
cr.set_source_rgb(.1+i*.14,.35,.8-i*.1);cr.rectangle(x,height-280+i*35,120,28);cr.fill()
|
|
return False
|
|
|
|
def tick():
|
|
area.queue_draw_area(0,max(0,area.get_allocated_height()-300),area.get_allocated_width(),300)
|
|
return True
|
|
|
|
def report():
|
|
elapsed=time.monotonic()-started
|
|
print(json.dumps({'event':'source-stats','draws':draws,'seconds':elapsed,'draw_fps':draws/elapsed}),flush=True)
|
|
return True
|
|
|
|
win.connect('destroy',Gtk.main_quit)
|
|
win.connect('key-press-event',event)
|
|
area.connect('button-press-event',event)
|
|
area.connect('draw',draw)
|
|
win.fullscreen();win.show_all();area.grab_focus()
|
|
GLib.timeout_add(16,tick);GLib.timeout_add_seconds(5,report)
|
|
print('READY',flush=True)
|
|
Gtk.main()
|