[PATCH 2/2] simple-shm: Draw the test motif surrounded by a white border
Hársszegi Tibor
Tibor.Harsszegi at scientificgames.hu
Tue Oct 2 22:32:59 PDT 2012
aok, thanks!
> -----Original Message-----
> From: Pekka Paalanen [mailto:ppaalanen at gmail.com]
> Sent: Wednesday, October 03, 2012 7:32 AM
> To: Hársszegi Tibor
> Cc: Rob Bradford; wayland-devel at lists.freedesktop.org; Rob Bradford
> Subject: Re: [PATCH 2/2] simple-shm: Draw the test motif
> surrounded by a white border
>
> On Tue, 2 Oct 2012 21:15:36 +0200
> Hársszegi Tibor <Tibor.Harsszegi at scientificgames.hu> wrote:
>
> > Call me lame, but what happens with "small" windows (e.g <20x20)?
>
> simple-shm is not resizeable.
>
> > ________________________________________
> > Feladó: Rob Bradford [rob at robster.org.uk]
> > Küldve: 2012. október 2. 19:03
> > Címzett: wayland-devel at lists.freedesktop.org
> > Másolatot kap: Rob Bradford
> > Tárgy: [PATCH 2/2] simple-shm: Draw the test motif
> surrounded by a white border
> >
> > From: Rob Bradford <rob at linux.intel.com>
> >
> > 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.
> > ---
> > clients/simple-shm.c | 20 +++++++++++++-------
> > 1 file changed, 13 insertions(+), 7 deletions(-)
>
> Rob,
>
> both patches look good to me, didn't test.
>
> Thanks,
> pq
>
>
> >
> > diff --git a/clients/simple-shm.c b/clients/simple-shm.c index
> > e8dc620..d0aeeb2 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)
> > --
> > 1.7.11.2
>
More information about the wayland-devel
mailing list