Ken Thomases : winemac: Initialize window surface to Mac-standard window background color instead of black .
Alexandre Julliard
julliard at winehq.org
Fri Apr 5 14:02:15 CDT 2013
Module: wine
Branch: master
Commit: f37153ac7d43d1ebb157c193b7ca2c61084b8923
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f37153ac7d43d1ebb157c193b7ca2c61084b8923
Author: Ken Thomases <ken at codeweavers.com>
Date: Thu Apr 4 14:26:08 2013 -0500
winemac: Initialize window surface to Mac-standard window background color instead of black.
---
dlls/winemac.drv/cocoa_window.m | 42 +++++++++++++++++++++++++++++++++++++++
dlls/winemac.drv/macdrv_cocoa.h | 1 +
dlls/winemac.drv/surface.c | 5 +++-
3 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index 9911195..6a85d74 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -1796,3 +1796,45 @@ void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c)
[pool release];
}
+
+/***********************************************************************
+ * macdrv_window_background_color
+ *
+ * Returns the standard Mac window background color as a 32-bit value of
+ * the form 0x00rrggbb.
+ */
+uint32_t macdrv_window_background_color(void)
+{
+ static uint32_t result;
+ static dispatch_once_t once;
+
+ // Annoyingly, [NSColor windowBackgroundColor] refuses to convert to other
+ // color spaces (RGB or grayscale). So, the only way to get RGB values out
+ // of it is to draw with it.
+ dispatch_once(&once, ^{
+ OnMainThread(^{
+ unsigned char rgbx[4];
+ unsigned char *planes = rgbx;
+ NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&planes
+ pixelsWide:1
+ pixelsHigh:1
+ bitsPerSample:8
+ samplesPerPixel:3
+ hasAlpha:NO
+ isPlanar:NO
+ colorSpaceName:NSCalibratedRGBColorSpace
+ bitmapFormat:0
+ bytesPerRow:4
+ bitsPerPixel:32];
+ [NSGraphicsContext saveGraphicsState];
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap]];
+ [[NSColor windowBackgroundColor] set];
+ NSRectFill(NSMakeRect(0, 0, 1, 1));
+ [NSGraphicsContext restoreGraphicsState];
+ [bitmap release];
+ result = rgbx[0] << 16 | rgbx[1] << 8 | rgbx[2];
+ });
+ });
+
+ return result;
+}
diff --git a/dlls/winemac.drv/macdrv_cocoa.h b/dlls/winemac.drv/macdrv_cocoa.h
index 46d13a9..c4819c3 100644
--- a/dlls/winemac.drv/macdrv_cocoa.h
+++ b/dlls/winemac.drv/macdrv_cocoa.h
@@ -347,6 +347,7 @@ extern void macdrv_dispose_view(macdrv_view v) DECLSPEC_HIDDEN;
extern void macdrv_set_view_window_and_frame(macdrv_view v, macdrv_window w, CGRect rect) DECLSPEC_HIDDEN;
extern void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
extern void macdrv_remove_view_opengl_context(macdrv_view v, macdrv_opengl_context c) DECLSPEC_HIDDEN;
+extern uint32_t macdrv_window_background_color(void) DECLSPEC_HIDDEN;
/* keyboard */
diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c
index 564d004..a27ff24 100644
--- a/dlls/winemac.drv/surface.c
+++ b/dlls/winemac.drv/surface.c
@@ -236,6 +236,7 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
DWORD *colors;
pthread_mutexattr_t attr;
int err;
+ DWORD window_background;
surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3]));
@@ -286,8 +287,10 @@ struct window_surface *create_surface(macdrv_window window, const RECT *rect,
}
update_blit_data(surface);
surface->use_alpha = use_alpha;
- surface->bits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, surface->info.bmiHeader.biSizeImage);
+ surface->bits = HeapAlloc(GetProcessHeap(), 0, surface->info.bmiHeader.biSizeImage);
if (!surface->bits) goto failed;
+ window_background = macdrv_window_background_color();
+ memset_pattern4(surface->bits, &window_background, surface->info.bmiHeader.biSizeImage);
TRACE("created %p for %p %s bits %p-%p\n", surface, window, wine_dbgstr_rect(rect),
surface->bits, surface->bits + surface->info.bmiHeader.biSizeImage);
More information about the wine-cvs
mailing list