Patchwork [2/3] remove knowledge of defaultallocator_free_displaysurface from sdl.c

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 10, 2010, 11:29 p.m.
Message ID <1265844597-29941-3-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/45075/
State New
Headers show

Comments

Paolo Bonzini - Feb. 10, 2010, 11:29 p.m.
Let register_displayallocator hand over the old width/height to the new
allocator.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	So these functions will be made static when moved to console.c.

 sdl.c |    4 ----
 vl.c  |    8 +++++++-
 2 files changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/sdl.c b/sdl.c
index cf27ad2..a9b4323 100644
--- a/sdl.c
+++ b/sdl.c
@@ -872,10 +872,6 @@  void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     da->resize_displaysurface = sdl_resize_displaysurface;
     da->free_displaysurface = sdl_free_displaysurface;
     if (register_displayallocator(ds, da) == da) {
-        DisplaySurface *surf;
-        surf = sdl_create_displaysurface(ds_get_width(ds), ds_get_height(ds));
-        defaultallocator_free_displaysurface(ds->surface);
-        ds->surface = surf;
         dpy_resize(ds);
     }
 
diff --git a/vl.c b/vl.c
index 94aeb5e..8e8b4d1 100644
--- a/vl.c
+++ b/vl.c
@@ -2598,7 +2598,13 @@  DisplayState *get_displaystate(void)
 
 DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *da)
 {
-    if(ds->allocator ==  &default_allocator) ds->allocator = da;
+    if(ds->allocator ==  &default_allocator) {
+        DisplaySurface *surf;
+        surf = da->create_displaysurface(ds_get_width(ds), ds_get_height(ds));
+        defaultallocator_free_displaysurface(ds->surface);
+        ds->surface = surf;
+        ds->allocator = da;
+    }
     return ds->allocator;
 }