winemac: Properly ignore attempts to set a window's shape to its current shape.

NSBezierPath doesn't override the -isEqual: method to actually compare paths,
so it just falls back to object identity which, in our case, makes paths seem
like they're never equal.

Also, memcmp()-ing the rectangle array is almost certainly faster than any
general test for equality between two paths.
This commit is contained in:
Ken Thomases 2014-10-02 17:06:19 -05:00 committed by Alexandre Julliard
parent 170d80dc90
commit 31d7f61cc3
2 changed files with 18 additions and 8 deletions

View File

@ -44,6 +44,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
pthread_mutex_t* surface_mutex;
NSBezierPath* shape;
NSData* shapeData;
BOOL shapeChangedSinceLastDraw;
BOOL colorKeyed;

View File

@ -182,6 +182,7 @@ @interface WineWindow ()
@property (nonatomic) pthread_mutex_t* surface_mutex;
@property (copy, nonatomic) NSBezierPath* shape;
@property (copy, nonatomic) NSData* shapeData;
@property (nonatomic) BOOL shapeChangedSinceLastDraw;
@property (readonly, nonatomic) BOOL needsTransparency;
@ -540,7 +541,7 @@ @implementation WineWindow
@synthesize disabled, noActivate, floating, fullscreen, fakingClose, latentParentWindow, hwnd, queue;
@synthesize surface, surface_mutex;
@synthesize shape, shapeChangedSinceLastDraw;
@synthesize shape, shapeData, shapeChangedSinceLastDraw;
@synthesize colorKeyed, colorKeyRed, colorKeyGreen, colorKeyBlue;
@synthesize usePerPixelAlpha;
@synthesize imeData, commandDone;
@ -634,6 +635,7 @@ - (void) dealloc
[latentChildWindows release];
[latentParentWindow release];
[shape release];
[shapeData release];
[super dealloc];
}
@ -1401,7 +1403,6 @@ - (void) checkTransparency
- (void) setShape:(NSBezierPath*)newShape
{
if (shape == newShape) return;
if (shape && newShape && [shape isEqual:newShape]) return;
if (shape)
{
@ -2379,16 +2380,24 @@ void macdrv_set_window_shape(macdrv_window w, const CGRect *rects, int count)
OnMainThread(^{
if (!rects || !count)
{
window.shape = nil;
window.shapeData = nil;
}
else
{
NSBezierPath* path;
unsigned int i;
size_t length = sizeof(*rects) * count;
if (window.shapeData.length != length || memcmp(window.shapeData.bytes, rects, length))
{
NSBezierPath* path;
unsigned int i;
path = [NSBezierPath bezierPath];
for (i = 0; i < count; i++)
[path appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
window.shape = path;
path = [NSBezierPath bezierPath];
for (i = 0; i < count; i++)
[path appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
window.shape = path;
window.shapeData = [NSData dataWithBytes:rects length:length];
}
}
});