From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LQkeF-0005lr-Vj for qemu-devel@nongnu.org; Sat, 24 Jan 2009 10:42:16 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LQkeF-0005le-8Z for qemu-devel@nongnu.org; Sat, 24 Jan 2009 10:42:15 -0500 Received: from [199.232.76.173] (port=56780 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LQkeE-0005lb-WD for qemu-devel@nongnu.org; Sat, 24 Jan 2009 10:42:15 -0500 Received: from smtp.eu.citrix.com ([62.200.22.115]:55987) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LQkeE-0005UD-Km for qemu-devel@nongnu.org; Sat, 24 Jan 2009 10:42:14 -0500 Message-ID: <497B3574.3060802@eu.citrix.com> Date: Sat, 24 Jan 2009 15:36:20 +0000 From: Stefano Stabellini MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Update cocoa.m to match new DisplayState code References: <3A471E0D-F371-46C4-B0FB-A476D69845CD@digitalescape.info> In-Reply-To: <3A471E0D-F371-46C4-B0FB-A476D69845CD@digitalescape.info> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Samuel Benson wrote: > Hello all, > > Attached patch is an attempt to update cocoa.m to be in sync with the new > displaystate changes committed a few weeks back. > > Tested working on OS X 10.5.6 on G4 and G5 PPC machines. > > Tests and comments welcome. Hi Samuel, thanks for your efforts. > @@ -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. > 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.