qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Update cocoa.m to match new DisplayState code


From: Samuel Benson
Subject: Re: [Qemu-devel] [PATCH] Update cocoa.m to match new DisplayState code
Date: Sat, 24 Jan 2009 13:16:50 -0600


On Jan 24, 2009, at 9:36 AM, Stefano Stabellini wrote:

Samuel Benson wrote:

@@ -396,18 +397,18 @@ int cocoa_keycode_to_qemu(int keycode)
    if (dataProviderRef)
        CGDataProviderRelease(dataProviderRef);
    if (screenBuffer)
-        free(screenBuffer);
-    screenBuffer = malloc( w * 4 * h );
-
-    ds->data = screenBuffer;
-    ds->linesize =  (w * 4);
-    ds->depth = 32;
-    ds->width = w;
-    ds->height = h;
+        qemu_free(screenBuffer);
+    screenBuffer = qemu_mallocz( w * 4 * h );
+
+    ds->surface->data = screenBuffer;
+    ds->surface->linesize =  (w * 4);
+    ds->surface->pf.depth = 32;
+    ds->surface->width = w;
+    ds->surface->height = h;
#ifdef __LITTLE_ENDIAN__
-    ds->bgr = 1;
+    ds->surface->flags = 0x00;
#else
-    ds->bgr = 0;
+    ds->surface->flags = QEMU_BIG_ENDIAN_FLAG;
#endif

dataProviderRef = CGDataProviderCreateWithData(NULL, screenBuffer,
w * 4 * h, NULL);



It would be better not to change the DisplayState surface from
cocoa\sdl\vnc but try to render the format exposed by the emulated
graphic card ourself.
In fact in most cases the emulated vga exposes a 32bpp surface with
linesize = width * 4, so you don't need to force it yourself.
The only exception is the 16bpp case, but you should be able to render
that as well without too many problems.

The previous code forced this change, and as this code merely synced it to the new structures, I did not think anything to be wrong with it. If the structures come pre initialized,
I'll remove these lines and see if it still works.

The one section I did have trouble understanding was the DisplaySurface flags; are those set
in regards to the host endianness or the guests?

void cocoa_display_init(DisplayState *ds, int full_screen)
{
    COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");

-    // register vga outpu callbacks
-    ds->dpy_update = cocoa_update;
-    ds->dpy_resize = cocoa_resize;
-    ds->dpy_refresh = cocoa_refresh;
+    dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+
+    // register vga output callbacks
+    dcl->dpy_update = cocoa_update;
+    dcl->dpy_resize = cocoa_resize;
+    dcl->dpy_refresh = cocoa_refresh;

+    register_displaychangelistener(ds, dcl);
+
    // give window a initial Size
-    cocoa_resize(ds, 640, 400);
+    cocoa_resize(ds);




The initialization seems correct, the call to cocoa_resize may be
unnecessary.

You are right, quick test showed the initial resize call to be unnecessary.

I've also managed get a hold of an x86 Mac, so I will post a v2 once I test it out there.

        —Sam




reply via email to

[Prev in Thread] Current Thread [Next in Thread]