winemac: Draw surface region rects separately instead of clipping one big draw.

This commit is contained in:
Ken Thomases 2013-03-28 23:34:03 -05:00 committed by Alexandre Julliard
parent f7406e74ae
commit 0e8b305023
1 changed files with 37 additions and 33 deletions

View File

@ -186,51 +186,55 @@ - (void) drawRect:(NSRect)rect
if (window.surface && window.surface_mutex && if (window.surface && window.surface_mutex &&
!pthread_mutex_lock(window.surface_mutex)) !pthread_mutex_lock(window.surface_mutex))
{ {
CGRect bounds;
const CGRect* rects; const CGRect* rects;
int count; int count;
if (!get_surface_region_rects(window.surface, &rects, &count) || count) if (!get_surface_region_rects(window.surface, &rects, &count))
{ {
CGRect imageRect; bounds = NSRectToCGRect([self bounds]);
CGImageRef image; rects = &bounds;
count = 1;
}
imageRect = NSRectToCGRect(rect); if (count)
image = create_surface_image(window.surface, &imageRect, FALSE); {
CGContextRef context;
int i;
if (image) [window.shape addClip];
context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetBlendMode(context, kCGBlendModeCopy);
for (i = 0; i < count; i++)
{ {
CGContextRef context; CGRect imageRect;
CGImageRef image;
if (rects && count) imageRect = CGRectIntersection(rects[i], NSRectToCGRect(rect));
image = create_surface_image(window.surface, &imageRect, FALSE);
if (image)
{ {
NSBezierPath* surfaceClip = [NSBezierPath bezierPath]; if (window.colorKeyed)
int i;
for (i = 0; i < count; i++)
[surfaceClip appendBezierPathWithRect:NSRectFromCGRect(rects[i])];
[surfaceClip addClip];
}
[window.shape addClip];
if (window.colorKeyed)
{
CGImageRef maskedImage;
CGFloat components[] = { window.colorKeyRed - 0.5, window.colorKeyRed + 0.5,
window.colorKeyGreen - 0.5, window.colorKeyGreen + 0.5,
window.colorKeyBlue - 0.5, window.colorKeyBlue + 0.5 };
maskedImage = CGImageCreateWithMaskingColors(image, components);
if (maskedImage)
{ {
CGImageRelease(image); CGImageRef maskedImage;
image = maskedImage; CGFloat components[] = { window.colorKeyRed - 0.5, window.colorKeyRed + 0.5,
window.colorKeyGreen - 0.5, window.colorKeyGreen + 0.5,
window.colorKeyBlue - 0.5, window.colorKeyBlue + 0.5 };
maskedImage = CGImageCreateWithMaskingColors(image, components);
if (maskedImage)
{
CGImageRelease(image);
image = maskedImage;
}
} }
CGContextDrawImage(context, imageRect, image);
CGImageRelease(image);
} }
context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetBlendMode(context, kCGBlendModeCopy);
CGContextDrawImage(context, imageRect, image);
CGImageRelease(image);
} }
} }