diff options
author | Rob Bradford <rob@linux.intel.com> | 2012-10-02 18:03:15 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-10-04 11:34:09 -0400 |
commit | 371805f76e9cecb57fc77c1a9e58911ba2fd1628 (patch) | |
tree | d2cf78aed53bc2313ea48eeba6e9f8a295fbe757 | |
parent | fecf332e19f731c26fc9d7c6d5cad540a2da554f (diff) |
simple-shm: Draw the test motif surrounded by a white border
We can then use a wl_surface_damage to just trigger the compositor to update
just a selected region of the buffer and thus test damaging a sub region.
-rw-r--r-- | clients/simple-shm.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/clients/simple-shm.c b/clients/simple-shm.c index e8dc620b..d0aeeb22 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -160,10 +160,10 @@ destroy_window(struct window *window) } static void -paint_pixels(void *image, int width, int height, uint32_t time) +paint_pixels(void *image, int padding, int width, int height, uint32_t time) { - const int halfh = height / 2; - const int halfw = width / 2; + const int halfh = padding + (height - padding * 2) / 2; + const int halfw = padding + (width - padding * 2) / 2; int ir, or; uint32_t *pixel = image; int y; @@ -174,11 +174,13 @@ paint_pixels(void *image, int width, int height, uint32_t time) or *= or; ir *= ir; - for (y = 0; y < height; y++) { + pixel += padding * width; + for (y = padding; y < height - padding; y++) { int x; int y2 = (y - halfh) * (y - halfh); - for (x = 0; x < width; x++) { + pixel += padding; + for (x = padding; x < width - padding; x++) { uint32_t v; /* squared distance from center */ @@ -198,6 +200,8 @@ paint_pixels(void *image, int width, int height, uint32_t time) *pixel++ = v; } + + pixel += padding; } } @@ -208,9 +212,9 @@ redraw(void *data, struct wl_callback *callback, uint32_t time) { struct window *window = data; - paint_pixels(window->shm_data, window->width, window->height, time); + paint_pixels(window->shm_data, 20, window->width, window->height, time); wl_surface_damage(window->surface, - 0, 0, window->width, window->height); + 20, 20, window->width - 40, window->height - 40); if (callback) wl_callback_destroy(callback); @@ -329,7 +333,9 @@ main(int argc, char **argv) sigint.sa_flags = SA_RESETHAND; sigaction(SIGINT, &sigint, NULL); + memset(window->shm_data, 0xff, window->width * window->height * 4); wl_surface_attach(window->surface, window->buffer, 0, 0); + redraw(window, NULL, 0); while (running) |