<div dir="ltr">You sure this has to change?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 2:32 PM, Derek Foreman <span dir="ltr"><<a href="mailto:derekf@osg.samsung.com" target="_blank">derekf@osg.samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We've been setting up the viewport by moving the start pointer of the<br>
draw buffer, but later when we want to post damage in buffer co-ordinates<br>
we'll need to keep track of the x,y offsets anyway.<br>
<br>
Signed-off-by: Derek Foreman <<a href="mailto:derekf@osg.samsung.com">derekf@osg.samsung.com</a>><br>
---<br>
 clients/simple-damage.c | 58 +++++++++++++++++++++++++++++--------------------<br>
 1 file changed, 34 insertions(+), 24 deletions(-)<br>
<br>
diff --git a/clients/simple-damage.c b/clients/simple-damage.c<br>
index 13e220a..0551b9d 100644<br>
--- a/clients/simple-damage.c<br>
+++ b/clients/simple-damage.c<br>
@@ -454,8 +454,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
 {<br>
        struct window *window = data;<br>
        struct buffer *buffer;<br>
-       int off_x, off_y, bwidth, bheight, bborder, bpitch, bradius;<br>
-       uint32_t *buffer_data;<br>
+       int off_x = 0, off_y = 0;<br>
+       int bwidth, bheight, bborder, bpitch, bradius;<br>
        float bx, by;<br>
<br>
        buffer = window_next_buffer(window);<br>
@@ -494,8 +494,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
        bborder = window->border * window->scale;<br>
        bradius = window->ball.radius * window->scale;<br>
<br>
-       buffer_data = buffer->shm_data;<br>
        if (window->viewport) {<br>
+               int tx, ty;<br>
                /* Fill the whole thing with red to detect viewport errors */<br>
                paint_box(buffer->shm_data, bpitch, 0, 0, bwidth, bheight,<br>
                          0xffff0000);<br>
@@ -508,35 +508,41 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
                bheight /= 2;<br>
<br>
                /* Offset the drawing region */<br>
-               off_x = (window->width / 3) * window->scale;<br>
-               off_y = (window->height / 5) * window->scale;<br>
+               tx = (window->width / 3) * window->scale;<br>
+               ty = (window->height / 5) * window->scale;<br>
                switch (window->transform) {<br>
                default:<br>
                case WL_OUTPUT_TRANSFORM_NORMAL:<br>
-                       buffer_data += off_y * bpitch + off_x;<br>
+                       off_y = ty;<br>
+                       off_x = tx;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_90:<br>
-                       buffer_data += off_x * bpitch + (bwidth - off_y);<br>
+                       off_y = tx;<br>
+                       off_x = bwidth - ty;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_180:<br>
-                       buffer_data += (bheight - off_y) * bpitch +<br>
-                                      (bwidth - off_x);<br>
+                       off_y = bheight - ty;<br>
+                       off_x = bwidth - tx;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_270:<br>
-                       buffer_data += (bheight - off_x) * bpitch + off_y;<br>
+                       off_y = bheight - tx;<br>
+                       off_x = ty;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_FLIPPED:<br>
-                       buffer_data += off_y * bpitch + (bwidth - off_x);<br>
+                       off_y = ty;<br>
+                       off_x = bwidth - tx;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_FLIPPED_90:<br>
-                       buffer_data += (bheight - off_x) * bpitch +<br>
-                                      (bwidth - off_y);<br>
+                       off_y = bheight - tx;<br>
+                       off_x = bwidth - ty;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_FLIPPED_180:<br>
-                       buffer_data += (bheight - off_y) * bpitch + off_x;<br>
+                       off_y = bheight - ty;<br>
+                       off_x = tx;<br>
                        break;<br>
                case WL_OUTPUT_TRANSFORM_FLIPPED_270:<br>
-                       buffer_data += off_x * bpitch + off_y;<br>
+                       off_y = tx;<br>
+                       off_x = ty;<br>
                        break;<br>
                }<br>
                wl_viewport_set_source(window->viewport,<br>
@@ -547,15 +553,17 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
        }<br>
<br>
        /* Paint the border */<br>
-       paint_box(buffer_data, bpitch, 0, 0, bwidth, bborder, 0xffffffff);<br>
-       paint_box(buffer_data, bpitch, 0, 0, bborder, bheight, 0xffffffff);<br>
-       paint_box(buffer_data, bpitch,<br>
-                 bwidth - bborder, 0, bborder, bheight, 0xffffffff);<br>
-       paint_box(buffer_data, bpitch,<br>
-                 0, bheight - bborder, bwidth, bborder, 0xffffffff);<br>
+       paint_box(buffer->shm_data, bpitch, off_x, off_y,<br>
+                 bwidth, bborder, 0xffffffff);<br>
+       paint_box(buffer->shm_data, bpitch, off_x, off_y,<br>
+                 bborder, bheight, 0xffffffff);<br>
+       paint_box(buffer->shm_data, bpitch, off_x + bwidth - bborder, off_y,<br>
+                 bborder, bheight, 0xffffffff);<br>
+       paint_box(buffer->shm_data, bpitch, off_x, off_y + bheight - bborder,<br>
+                 bwidth, bborder, 0xffffffff);<br>
<br>
        /* fill with translucent */<br>
-       paint_box(buffer_data, bpitch, bborder, bborder,<br>
+       paint_box(buffer->shm_data, bpitch, off_x + bborder, off_y + bborder,<br>
                  bwidth - 2 * bborder, bheight - 2 * bborder, 0x80000000);<br>
<br>
        /* Damage where the ball was */<br>
@@ -570,7 +578,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
        window_get_transformed_ball(window, &bx, &by);<br>
<br>
        /* Paint the ball */<br>
-       paint_circle(buffer_data, bpitch, bx, by, bradius, 0xff00ff00);<br>
+       paint_circle(buffer->shm_data, bpitch, off_x + bx, off_y + by,<br>
+                    bradius, 0xff00ff00);<br>
<br>
        if (print_debug) {<br>
                printf("Ball now located at (%f, %f)\n",<br>
@@ -580,7 +589,8 @@ redraw(void *data, struct wl_callback *callback, uint32_t time)<br>
                       bradius);<br>
<br>
                printf("Buffer damage rectangle: (%d, %d) @ %dx%d\n",<br>
-                      (int)(bx - bradius), (int)(by - bradius),<br>
+                      (int)(bx - bradius) + off_x,<br>
+                      (int)(by - bradius) + off_y,<br>
                       bradius * 2 + 1, bradius * 2 + 1);<br>
        }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.6.2<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div>