History

wayland: clean up, copy less and remove locking on frame done callback (a bit faster redrawing)

Sigrid Solveig Haflínudóttir committed 4 years ago

Commit 6b448b91 parent efe20ef2 files · +17 −22Browse files

Unified · Split

2 files
  1. gui-wl/wl-cb.c +3 −6
  2. gui-wl/wl-screen.c +14 −16
gui-wl/wl-cb.c+3−6
@@ -79,10 +79,8 @@ wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) · 78 unmodified lines
79 wl = data;79 wl = data;
80 wl_callback_destroy(cb);80 wl_callback_destroy(cb);
81 cb = wl_surface_frame(wl->surface);81 cb = wl_surface_frame(wl->surface);
82 qlock(&drawlock);
83 wlflush(wl);
84 qunlock(&drawlock);
85 wl_callback_add_listener(cb, &wl_surface_frame_listener, wl);82 wl_callback_add_listener(cb, &wl_surface_frame_listener, wl);
83 wlflush(wl);
86}84}
87 85
88static void86static void
@@ -93,7 +91,7 @@ keyboard_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int32 · 4 unmodified lines
93 Wlwin *wl;91 Wlwin *wl;
94 92
95 wl = data;93 wl = data;
96 keymap_string = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);94 keymap_string = mmap(nil, size, PROT_READ, MAP_SHARED, fd, 0);
97 xkb_keymap_unref(keymap);95 xkb_keymap_unref(keymap);
98 keymap = xkb_keymap_new_from_string(wl->xkb_context, keymap_string, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);96 keymap = xkb_keymap_new_from_string(wl->xkb_context, keymap_string, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
99 munmap(keymap_string, size);97 munmap(keymap_string, size);
@@ -477,9 +475,8 @@ data_device_handle_selection(void *data, struct wl_data_device *data_device, str · 377 unmodified lines
477 int fds[2];475 int fds[2];
478 476
479 // An application has set the clipboard contents477 // An application has set the clipboard contents
480 if (offer == NULL) {478 if(offer == nil)
481 return;479 return;
482 }
483 480
484 wl = data;481 wl = data;
485 pipe2(fds, O_CLOEXEC);482 pipe2(fds, O_CLOEXEC);
gui-wl/wl-screen.c+14−16
@@ -47,14 +47,17 @@ newwlwin(void) · 46 unmodified lines
47void47void
48wlflush(Wlwin *wl)48wlflush(Wlwin *wl)
49{49{
50 if(wl->dirty == 1)50 Point p;
51 memcpy(wl->shm_data, gscreen->data->bdata, wl->dx*wl->dy*4);
52 51
53 wl_surface_attach(wl->surface, wl->screenbuffer, 0, 0);52 wl_surface_attach(wl->surface, wl->screenbuffer, 0, 0);
54 if(wl->dirty)53 if(wl->dirty){
55 wl_surface_damage(wl->surface, wl->r.min.x, wl->r.min.y, Dx(wl->r), Dy(wl->r));54 p.x = wl->r.min.x;
55 for(p.y = wl->r.min.y; p.y < wl->r.max.y; p.y++)
56 memcpy(wl->shm_data+(p.y*wl->dx+p.x)*4, byteaddr(gscreen, p), Dx(wl->r)*4);
57 wl_surface_damage(wl->surface, p.x, wl->r.min.y, Dx(wl->r), Dy(wl->r));
58 wl->dirty = 0;
59 }
56 wl_surface_commit(wl->surface);60 wl_surface_commit(wl->surface);
57 wl->dirty = 0;
58}61}
59 62
60void63void
@@ -86,9 +89,8 @@ dispatchproc(void *a) · 25 unmodified lines
86{89{
87 Wlwin *wl;90 Wlwin *wl;
88 wl = a;91 wl = a;
89 for(;wl->runing == 1;){92 while(wl->runing)
90 wl_display_dispatch(wl->display);93 wl_display_dispatch(wl->display);
91 }
92}94}
93 95
94static Wlwin*96static Wlwin*
@@ -99,7 +101,7 @@ wlattach(char *label) · 4 unmodified lines
99 101
100 wl = newwlwin();102 wl = newwlwin();
101 gwin = wl;103 gwin = wl;
102 wl->display = wl_display_connect(NULL);104 wl->display = wl_display_connect(nil);
103 if(wl->display == nil)105 if(wl->display == nil)
104 sysfatal("could not connect to display");106 sysfatal("could not connect to display");
105 107
@@ -151,19 +153,15 @@ attachscreen(Rectangle *r, ulong *chan, int *depth, int *width, int *softscreen) · 45 unmodified lines
151void153void
152flushmemscreen(Rectangle r)154flushmemscreen(Rectangle r)
153{155{
154 Wlwin *wl;156 gwin->dirty = 1;
155 157 gwin->r = r;
156 wl = gwin;158 wlflush(gwin);
157 wl->dirty = 1;
158 wl->r = r;
159 wlflush(wl);
160}159}
161 160
162void161void
163screensize(Rectangle r, ulong chan)162screensize(Rectangle r, ulong chan)
164{163{
165 gwin->dirty = 1;164 flushmemscreen(r);
166 gwin->r = r;
167}165}
168 166
169void167void

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t