[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/4] console: pass DisplayAllocator as first argumen
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 3/4] console: pass DisplayAllocator as first argument to methods |
Date: |
Mon, 16 Jan 2012 16:36:36 -0600 |
Signed-off-by: Anthony Liguori <address@hidden>
---
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