qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 3/4] console: pass DisplayAllocator as first argument to methods
Date: Mon, 16 Jan 2012 16:36:36 -0600	[thread overview]
Message-ID: <1326753397-18476-3-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1326753397-18476-1-git-send-email-aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 console.c |   14 ++++++++------
 console.h |   12 ++++++------
 ui/sdl.c  |   10 +++++-----
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/console.c b/console.c
index 1085b07..36b8d76 100644
--- a/console.c
+++ b/console.c
@@ -1271,7 +1271,8 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
     return s;
 }
 
-static DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
+static DisplaySurface* defaultallocator_create_displaysurface(DisplayAllocator *da, 
+                                                              int width, int height)
 {
     DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
 
@@ -1281,8 +1282,9 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
     return surface;
 }
 
-static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
-                                          int width, int height)
+static DisplaySurface* defaultallocator_resize_displaysurface(DisplayAllocator *da, 
+                                                              DisplaySurface *surface,
+                                                              int width, int height)
 {
     int linesize = width * 4;
     qemu_alloc_display(surface, width, height, linesize,
@@ -1328,7 +1330,7 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
     return surface;
 }
 
-static void defaultallocator_free_displaysurface(DisplaySurface *surface)
+static void defaultallocator_free_displaysurface(DisplayAllocator *da, DisplaySurface *surface)
 {
     if (surface == NULL)
         return;
@@ -1380,8 +1382,8 @@ DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *
 {
     if(ds->allocator ==  &default_allocator) {
         DisplaySurface *surf;
-        surf = da->create_displaysurface(ds_get_width(ds), ds_get_height(ds));
-        defaultallocator_free_displaysurface(ds->surface);
+        surf = da->create_displaysurface(da, ds_get_width(ds), ds_get_height(ds));
+        defaultallocator_free_displaysurface(da, ds->surface);
         ds->surface = surf;
         ds->allocator = da;
     }
diff --git a/console.h b/console.h
index e78b359..44c744c 100644
--- a/console.h
+++ b/console.h
@@ -166,9 +166,9 @@ struct DisplayChangeListener {
 };
 
 struct DisplayAllocator {
-    DisplaySurface* (*create_displaysurface)(int width, int height);
-    DisplaySurface* (*resize_displaysurface)(DisplaySurface *surface, int width, int height);
-    void (*free_displaysurface)(DisplaySurface *surface);
+    DisplaySurface* (*create_displaysurface)(DisplayAllocator *da, int width, int height);
+    DisplaySurface* (*resize_displaysurface)(DisplayAllocator *da, DisplaySurface *surface, int width, int height);
+    void (*free_displaysurface)(DisplayAllocator *da, DisplaySurface *surface);
 };
 
 struct DisplayState {
@@ -196,17 +196,17 @@ DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *
 
 static inline DisplaySurface* qemu_create_displaysurface(DisplayState *ds, int width, int height)
 {
-    return ds->allocator->create_displaysurface(width, height);    
+    return ds->allocator->create_displaysurface(ds->allocator, width, height);
 }
 
 static inline DisplaySurface* qemu_resize_displaysurface(DisplayState *ds, int width, int height)
 {
-    return ds->allocator->resize_displaysurface(ds->surface, width, height);
+    return ds->allocator->resize_displaysurface(ds->allocator, ds->surface, width, height);
 }
 
 static inline void qemu_free_displaysurface(DisplayState *ds)
 {
-    ds->allocator->free_displaysurface(ds->surface);
+    ds->allocator->free_displaysurface(ds->allocator, ds->surface);
 }
 
 static inline int is_surface_bgr(DisplaySurface *surface)
diff --git a/ui/sdl.c b/ui/sdl.c
index 2310964..aa9cec5 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -189,7 +189,7 @@ static PixelFormat sdl_to_qemu_pixelformat(SDL_PixelFormat *sdl_pf)
     return qemu_pf;
 }
 
-static DisplaySurface* sdl_create_displaysurface(int width, int height)
+static DisplaySurface* sdl_create_displaysurface(DisplayAllocator *da, int width, int height)
 {
     SDLDisplayState *s = global_sdl_state;
     DisplaySurface *surface = (DisplaySurface*) g_malloc0(sizeof(DisplaySurface));
@@ -235,7 +235,7 @@ static DisplaySurface* sdl_create_displaysurface(int width, int height)
     return surface;
 }
 
-static void sdl_free_displaysurface(DisplaySurface *surface)
+static void sdl_free_displaysurface(DisplayAllocator *da, DisplaySurface *surface)
 {
     SDLDisplayState *s = global_sdl_state;
 
@@ -248,10 +248,10 @@ static void sdl_free_displaysurface(DisplaySurface *surface)
     g_free(surface);
 }
 
-static DisplaySurface* sdl_resize_displaysurface(DisplaySurface *surface, int width, int height)
+static DisplaySurface* sdl_resize_displaysurface(DisplayAllocator *da, DisplaySurface *surface, int width, int height)
 {
-    sdl_free_displaysurface(surface);
-    return sdl_create_displaysurface(width, height);
+    sdl_free_displaysurface(da, surface);
+    return sdl_create_displaysurface(da, width, height);
 }
 
 /* generic keyboard conversion */
-- 
1.7.4.1

  parent reply	other threads:[~2012-01-16 22:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16 22:36 [Qemu-devel] [PATCH 1/4] console: a few cleanups Anthony Liguori
2012-01-16 22:36 ` [Qemu-devel] [PATCH 2/4] sdl: move globals to a state file, update everything accordingly Anthony Liguori
2012-01-16 22:36 ` Anthony Liguori [this message]
2012-01-17  6:16 ` [Qemu-devel] [PATCH 1/4] console: a few cleanups Stefan Weil
2012-01-18  0:49   ` Anthony Liguori
2012-01-18  5:50     ` Stefan Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1326753397-18476-3-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).