console: clip update rectangle
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 14 Dec 2012 07:54:25 +0000 (08:54 +0100)
committerBlue Swirl <blauwirbel@gmail.com>
Fri, 14 Dec 2012 20:56:26 +0000 (20:56 +0000)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
console.h

index 50a0512f3211c6603704f872a7f380eeaa7dcdd6..edb195087160e0fd1e532369c86c8bd154ef5136 100644 (file)
--- a/console.h
+++ b/console.h
@@ -229,6 +229,16 @@ static inline void unregister_displaychangelistener(DisplayState *ds,
 static inline void dpy_gfx_update(DisplayState *s, int x, int y, int w, int h)
 {
     struct DisplayChangeListener *dcl;
+    int width = pixman_image_get_width(s->surface->image);
+    int height = pixman_image_get_height(s->surface->image);
+
+    x = MAX(x, 0);
+    y = MAX(y, 0);
+    x = MIN(x, width);
+    y = MIN(y, height);
+    w = MIN(w, width - x);
+    h = MIN(h, height - y);
+
     QLIST_FOREACH(dcl, &s->listeners, next) {
         if (dcl->dpy_gfx_update) {
             dcl->dpy_gfx_update(s, x, y, w, h);