All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [6683] Update cocoa.m to match new DisplayState code (Samuel Benson)
@ 2009-03-04 19:25 Anthony Liguori
  2009-03-05 11:05 ` Stefano Stabellini
  0 siblings, 1 reply; 2+ messages in thread
From: Anthony Liguori @ 2009-03-04 19:25 UTC (permalink / raw)
  To: qemu-devel

Revision: 6683
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6683
Author:   aliguori
Date:     2009-03-04 19:25:22 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
Update cocoa.m to match new DisplayState code (Samuel Benson)

Version 2 does as follows:

[1]: Corrects endianness on issues by using native BGR to RGB conversion
[2]: Uses DisplayState accessors for obtaining graphics context information,
     which
[3]: Removes now unused variables, and
[4]: Allows reading of varying color modes (32bit/24/16), and converting to
     native colorspace
[5]: Attempts to keep itself centered on screen (as opposed to bottom right,
     which immediately goes off screen after bios load) on context changes
    (window resizes)

Testing working on i386 (gentoo, Windows 2000) and PPC (debian) guests on PPC
and x86 Macs.

In regards to [4], Windows 2000 displays fine on quick tests, but on the lowest
setting I could test, 16bit color depth at 4bpp, colors are slightly off. I
used gentoo install-x86-minimal-2008.0 in framebuffer mode to test above
setting; the usual grey text is now blue, and Tux appears to be BGR shifted. I
do not know if previous code worked at such a low color setting.

Signed-off-by: Samuel Benson <qemu_ml@digitalescape.info> 

Modified Paths:
--------------
    trunk/cocoa.m

Modified: trunk/cocoa.m
===================================================================
--- trunk/cocoa.m	2009-03-04 12:18:15 UTC (rev 6682)
+++ trunk/cocoa.m	2009-03-04 19:25:22 UTC (rev 6683)
@@ -57,7 +57,7 @@
 int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
 NSWindow *normalWindow;
 id cocoaView;
-static void *screenBuffer;
+static DisplayChangeListener *dcl;
 
 int gArgc;
 char **gArgv;
@@ -292,9 +292,6 @@
 {
     COCOA_DEBUG("QemuCocoaView: dealloc\n");
 
-    if (screenBuffer)
-        free(screenBuffer);
-
     if (dataProviderRef)
         CGDataProviderRelease(dataProviderRef);
 
@@ -305,9 +302,6 @@
 {
     COCOA_DEBUG("QemuCocoaView: drawRect\n");
 
-    if ((int)screenBuffer == -1)
-        return;
-
     // get CoreGraphic context
     CGContextRef viewContextRef = [[NSGraphicsContext currentContext] graphicsPort];
     CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone);
@@ -320,10 +314,10 @@
             screen.height, //height
             screen.bitsPerComponent, //bitsPerComponent
             screen.bitsPerPixel, //bitsPerPixel
-            (screen.width * 4), //bytesPerRow
+            (screen.width * (screen.bitsPerComponent/2)), //bytesPerRow
 #if __LITTLE_ENDIAN__
             CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4
-            kCGImageAlphaNoneSkipLast,
+            kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
 #else
             CGColorSpaceCreateDeviceRGB(), //colorspace for OS X < 10.4 (actually ppc)
             kCGImageAlphaNoneSkipFirst, //bitmapInfo
@@ -395,22 +389,12 @@
     // update screenBuffer
     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;
-#ifdef __LITTLE_ENDIAN__
-    ds->bgr = 1;
-#else
-    ds->bgr = 0;
-#endif
+    //sync host window color space with guests
+	screen.bitsPerPixel = ds_get_bits_per_pixel(ds);
+	screen.bitsPerComponent = ds_get_bytes_per_pixel(ds) * 2;
 
-    dataProviderRef = CGDataProviderCreateWithData(NULL, screenBuffer, w * 4 * h, NULL);
+    dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), w * 4 * h, NULL);
 
     // update windows
     if (isFullscreen) {
@@ -423,6 +407,7 @@
     }
     screen.width = w;
     screen.height = h;
+	[normalWindow center];
     [self setContentDimensions];
     [self setFrame:NSMakeRect(cx, cy, cw, ch)];
 }
@@ -740,6 +725,7 @@
         [normalWindow setTitle:[NSString stringWithFormat:@"QEMU"]];
         [normalWindow setContentView:cocoaView];
         [normalWindow makeKeyAndOrderFront:self];
+		[normalWindow center];
 
     }
     return self;
@@ -939,11 +925,11 @@
     [cocoaView displayRect:rect];
 }
 
-static void cocoa_resize(DisplayState *ds, int w, int h)
+static void cocoa_resize(DisplayState *ds)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
 
-    [cocoaView resizeContentToWidth:w height:h displayState:ds];
+    [cocoaView resizeContentToWidth:(int)(ds_get_width(ds)) height:(int)(ds_get_height(ds)) displayState:ds];
 }
 
 static void cocoa_refresh(DisplayState *ds)
@@ -975,20 +961,21 @@
 static void cocoa_cleanup(void)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n");
-
+	qemu_free(dcl);
 }
 
 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;
 
-    // give window a initial Size
-    cocoa_resize(ds, 640, 400);
+	register_displaychangelistener(ds, dcl);
 
     // register cleanup function
     atexit(cocoa_cleanup);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [6683] Update cocoa.m to match new DisplayState code (Samuel Benson)
  2009-03-04 19:25 [Qemu-devel] [6683] Update cocoa.m to match new DisplayState code (Samuel Benson) Anthony Liguori
@ 2009-03-05 11:05 ` Stefano Stabellini
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Stabellini @ 2009-03-05 11:05 UTC (permalink / raw)
  To: qemu-devel

Anthony Liguori wrote:

> Revision: 6683
>           http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6683
> Author:   aliguori
> Date:     2009-03-04 19:25:22 +0000 (Wed, 04 Mar 2009)
> Log Message:
> -----------
> Update cocoa.m to match new DisplayState code (Samuel Benson)
> 
> Version 2 does as follows:
> 
> [1]: Corrects endianness on issues by using native BGR to RGB conversion
> [2]: Uses DisplayState accessors for obtaining graphics context information,
>      which
> [3]: Removes now unused variables, and
> [4]: Allows reading of varying color modes (32bit/24/16), and converting to
>      native colorspace
> [5]: Attempts to keep itself centered on screen (as opposed to bottom right,
>      which immediately goes off screen after bios load) on context changes
>     (window resizes)
> 
> Testing working on i386 (gentoo, Windows 2000) and PPC (debian) guests on PPC
> and x86 Macs.
> 
> In regards to [4], Windows 2000 displays fine on quick tests, but on the lowest
> setting I could test, 16bit color depth at 4bpp, colors are slightly off. I
> used gentoo install-x86-minimal-2008.0 in framebuffer mode to test above
> setting; the usual grey text is now blue, and Tux appears to be BGR shifted. I
> do not know if previous code worked at such a low color setting.
> 
> Signed-off-by: Samuel Benson <qemu_ml@digitalescape.info> 
> 

Please read this message:

http://lists.gnu.org/archive/html/qemu-devel/2009-03/msg00034.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-03-05 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-04 19:25 [Qemu-devel] [6683] Update cocoa.m to match new DisplayState code (Samuel Benson) Anthony Liguori
2009-03-05 11:05 ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.