qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] [v2] Update cocoa.m to match new DisplayState code
Date: Sun, 25 Jan 2009 16:30:31 -0600	[thread overview]
Message-ID: <497CE807.7030104@codemonkey.ws> (raw)
In-Reply-To: <BAY110-DAV109C3779452C63A1222FA7B9CD0@phx.gbl>

C.W. Betts wrote:
> It would help if the patch file was included.  Either the mail browser 
> that I use (Mac OS X Mail) or the mail transport messes up the 
> formatting, making it hard to apply the patch using the patch command.

Inlining is fine (and preferred to me) but Samuel's mail client munged 
the white space in the patch.

Regards,

Anthony Liguori

> On Jan 25, 2009, at 1:23 AM, Samuel Benson wrote:
>
>> diff --git a/cocoa.m b/cocoa.m
>> index fe13952..55ff2b4 100644
>> --- a/cocoa.m
>> +++ b/cocoa.m
>> @@ -57,7 +57,7 @@ typedef struct {
>> 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 @@ int cocoa_keycode_to_qemu(int keycode)
>> {
>>     COCOA_DEBUG("QemuCocoaView: dealloc\n");
>>
>> -    if (screenBuffer)
>> -        free(screenBuffer);
>> -
>>     if (dataProviderRef)
>>         CGDataProviderRelease(dataProviderRef);
>>
>> @@ -305,9 +302,6 @@ int cocoa_keycode_to_qemu(int keycode)
>> {
>>     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 @@ int cocoa_keycode_to_qemu(int keycode)
>>             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 @@ int cocoa_keycode_to_qemu(int keycode)
>>     // 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
>>
>> -    dataProviderRef = CGDataProviderCreateWithData(NULL, 
>> screenBuffer, w * 4 * h, NULL);
>> +    //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, 
>> ds_get_data(ds), w * 4 * h, NULL);
>>
>>     // update windows
>>     if (isFullscreen) {
>> @@ -423,6 +407,7 @@ int cocoa_keycode_to_qemu(int keycode)
>>     }
>>     screen.width = w;
>>     screen.height = h;
>> + [normalWindow center];
>>     [self setContentDimensions];
>>     [self setFrame:NSMakeRect(cx, cy, cw, ch)];
>> }
>> @@ -740,6 +725,7 @@ int cocoa_keycode_to_qemu(int keycode)
>>         [normalWindow setTitle:[NSString stringWithFormat:@"QEMU"]];
>>         [normalWindow setContentView:cocoaView];
>>         [normalWindow makeKeyAndOrderFront:self];
>> + [normalWindow center];
>>
>>     }
>>     return self;
>> @@ -939,11 +925,11 @@ static void cocoa_update(DisplayState *ds, int 
>> x, int y, int w, int h)
>>     [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_refresh(DisplayState *ds)
>> 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);
>>
>

  parent reply	other threads:[~2009-01-25 22:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-25  8:23 [Qemu-devel] [PATCH] [v2] Update cocoa.m to match new DisplayState code Samuel Benson
     [not found] ` <2DDD067A-BDFD-4A05-9022-2FF16F4075C2@hotmail.com>
2009-01-25 22:15   ` C.W. Betts
2009-01-25 22:28     ` Samuel Benson
2009-01-25 22:30     ` Anthony Liguori [this message]
2009-01-26 11:05 ` Stefano Stabellini
2009-01-27  3:29   ` Samuel Benson
2009-01-27 10:47     ` Stefano Stabellini
2009-01-27 21:35       ` Samuel Benson
2009-01-28 10:47         ` Stefano Stabellini
2009-01-26 18:26 ` Stefano Stabellini
2009-01-26 18:26 ` Stefano Stabellini
2009-02-28 15:09 ` Andreas Färber
2009-03-02 11:33   ` Stefano Stabellini
2009-03-03 17:15 ` Anthony Liguori

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=497CE807.7030104@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --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).