Skip to contentSkip to conversation

cocoa: Fix VBE function Set Display Start

PATCH Superseded Henry Harrington 2 participants 3 messages Nov 21, 2012 – Nov 27, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cocoa: Fix VBE function Set Display Start

Register a dpy_gfx_setdata callback so that the Cocoa code is notified whenever the screen start address changes.

---
 ui/cocoa.m |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
ui/cocoa.m +18 -0
index 87d2e44..97010bc 100644
@@ -265,6 +265,7 @@ static int cocoa_keycode_to_qemu(int keycode)
     BOOL isTabletEnabled;
 }
 - (void) resizeContentToWidth:(int)w height:(int)h displayState:(DisplayState *)ds;
+- (void) updateDataOffset:(DisplayState *)ds;
 - (void) grabMouse;
 - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;
@@ -429,6 +430,17 @@ QemuCocoaView *cocoaView;
     [self setFrame:NSMakeRect(cx, cy, cw, ch)];
 }
 
+- (void) updateDataOffset:(DisplayState *)ds
+{
+    COCOA_DEBUG("QemuCocoaView: UpdateDataOffset\n");
+
+    // update screenBuffer
+    if (dataProviderRef)
+        CGDataProviderRelease(dataProviderRef);
+
+    dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), ds_get_width(ds) * 4 * ds_get_height(ds), NULL);
+}
+
 - (void) toggleFullScreen:(id)sender
 {
     COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n");
@@ -1004,6 +1016,11 @@ static void cocoa_refresh(DisplayState *ds)
     vga_hw_update();
 }
 
+static void cocoa_setdata(DisplayState *ds)
+{
+  [cocoaView updateDataOffset:ds];
+}
+
 static void cocoa_cleanup(void)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n");
@@ -1020,6 +1037,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
     dcl->dpy_gfx_update = cocoa_update;
     dcl->dpy_gfx_resize = cocoa_resize;
     dcl->dpy_refresh = cocoa_refresh;
+    dcl->dpy_gfx_setdata = cocoa_setdata;
 
 	register_displaychangelistener(ds, dcl);
 
Signature · 1 line
1.7.6.1
#1 lore raw

Am 21.11.2012 20:08, schrieb Henry Harrington:

Quoted 21 lines

Register a dpy_gfx_setdata callback so that the Cocoa code is notified whenever the screen start address changes.

---
 ui/cocoa.m |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
ui/cocoa.m +1 -0
index 87d2e44..97010bc 100644
@@ -265,6 +265,7 @@ static int cocoa_keycode_to_qemu(int keycode)
     BOOL isTabletEnabled;
 }
 - (void) resizeContentToWidth:(int)w height:(int)h displayState:(DisplayState *)ds;
+- (void) updateDataOffset:(DisplayState *)ds;
 - (void) grabMouse;
 - (void) ungrabMouse;
 - (void) toggleFullScreen:(id)sender;

ui/cocoa.m QemuCocoaView *cocoaView; · line 439

Quoted 10 lines
ui/cocoa.m +7 -0
@@ -429,6 +430,17 @@ QemuCocoaView *cocoaView;
     [self setFrame:NSMakeRect(cx, cy, cw, ch)];
 }
 
+- (void) updateDataOffset:(DisplayState *)ds
+{
+    COCOA_DEBUG("QemuCocoaView: UpdateDataOffset\n");
+
+    // update screenBuffer
+    if (dataProviderRef)
+        CGDataProviderRelease(dataProviderRef);

Please add braces for if.

ui/cocoa.m QemuCocoaView *cocoaView; · line 441

Quoted 2 lines
ui/cocoa.m +2 -0
+
+    dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), ds_get_width(ds) * 4 * ds_get_height(ds), NULL);

This line seems overly long, please keep within 80 chars.

ui/cocoa.m static void cocoa_refresh(DisplayState *ds) · line 1021

Quoted 12 lines
ui/cocoa.m +5 -0
+}
+
 - (void) toggleFullScreen:(id)sender
 {
     COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n");
@@ -1004,6 +1016,11 @@ static void cocoa_refresh(DisplayState *ds)
     vga_hw_update();
 }
 
+static void cocoa_setdata(DisplayState *ds)
+{
+  [cocoaView updateDataOffset:ds];

Please indent using 4 spaces.

ui/cocoa.m void cocoa_display_init(DisplayState *ds, int full_screen) · line 1043

Quoted 13 lines
ui/cocoa.m +3 -0
+}
+
 static void cocoa_cleanup(void)
 {
     COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n");
@@ -1020,6 +1037,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen)
     dcl->dpy_gfx_update = cocoa_update;
     dcl->dpy_gfx_resize = cocoa_resize;
     dcl->dpy_refresh = cocoa_refresh;
+    dcl->dpy_gfx_setdata = cocoa_setdata;
 
 	register_displaychangelistener(ds, dcl);
 

Apart from the style issues above (you can use scripts/checkpatch.pl to verify) this looks okay. Unfortunately I am not getting pixman built on OSX so am still unable to test...

Am I understanding correctly that this is an optional hook and not a bug fix for 1.3? How can it be verified?

Regards,
Andreas

#2 lore raw
Quoted 4 lines · Andreas Färber

Am 21.11.2012 20:08, schrieb Henry Harrington:
Apart from the style issues above (you can use scripts/checkpatch.pl to verify) this looks okay. Unfortunately I am not getting pixman built on OSX so am still unable to test...

Thanks, I'll fix the style issues and submit a new patch.

Quoted 5 lines

Am I understanding correctly that this is an optional hook and not a bug fix for 1.3? How can it be verified?

Regards,
Andreas

The setdata callback is required, even though the Cocoa UI works reasonably well without it. I've attached a simple testcase, which rapidly switches between two virtual screens using VBE (one is blue/green, and the other is green/red). Without the fix Qemu does not switch between screens.

There was a similar bug in the VNC UI which was fixed in commit 1d3323d.

Henry