Changeset 152315 in webkit


Ignore:
Timestamp:
Jul 2, 2013 12:50:24 PM (11 years ago)
Author:
andersca@apple.com
Message:

Always flip the coordinate system before drawing NSViews from Widget::paint
https://bugs.webkit.org/show_bug.cgi?id=118318
<rdar://problem/13895483>

Reviewed by Beth Dakin.

Undo the change that would not flip on 10.9; turns out the bug was in AppKit. Also remove the
_hasCanDrawSubviewsIntoLayerOrAncestor workaround since drawing works correctly now.

Also, pass flipped:NO when creating the NSGraphicsContext to indicate that the graphics context
is unflipped as far as AppKit knows (since we flipped it earlier).

  • platform/mac/WidgetMac.mm:

(WebCore::Widget::paint):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152313 r152315  
     12013-07-02  Anders Carlsson  <andersca@apple.com>
     2
     3        Always flip the coordinate system before drawing NSViews from Widget::paint
     4        https://bugs.webkit.org/show_bug.cgi?id=118318
     5        <rdar://problem/13895483>
     6
     7        Reviewed by Beth Dakin.
     8
     9        Undo the change that would not flip on 10.9; turns out the bug was in AppKit. Also remove the
     10        _hasCanDrawSubviewsIntoLayerOrAncestor workaround since drawing works correctly now.
     11
     12        Also, pass flipped:NO when creating the NSGraphicsContext to indicate that the graphics context
     13        is unflipped as far as AppKit knows (since we flipped it earlier).
     14
     15        * platform/mac/WidgetMac.mm:
     16        (WebCore::Widget::paint):
     17
    1182013-06-26  Robert Hogan  <robert@webkit.org>
    219
  • trunk/Source/WebCore/platform/mac/WidgetMac.mm

    r151926 r152315  
    5555@interface NSView (Widget)
    5656- (void)visibleRectDidChange;
    57 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    58 - (BOOL)_hasCanDrawSubviewsIntoLayerOrAncestor;
    59 #endif
    6057@end
    6158
     
    212209    RefPtr<Widget> protectedThis(this);
    213210
    214     BOOL hasCanDrawSubviewsIntoLayerOrAncestor = NO;
    215 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    216     hasCanDrawSubviewsIntoLayerOrAncestor = [view _hasCanDrawSubviewsIntoLayerOrAncestor];
    217 #endif
    218    
    219211    NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
    220     if (currentContext == [[view window] graphicsContext] || ![currentContext isDrawingToScreen] || hasCanDrawSubviewsIntoLayerOrAncestor) {
     212    if (currentContext == [[view window] graphicsContext] || ![currentContext isDrawingToScreen]) {
    221213        // This is the common case of drawing into a window or an inclusive layer, or printing.
    222214        BEGIN_BLOCK_OBJC_EXCEPTIONS;
     
    250242    NSRect viewFrame = [view frame];
    251243    NSRect viewBounds = [view bounds];
     244
    252245    // Set up the translation and (flipped) orientation of the graphics context. In normal drawing, AppKit does it as it descends down
    253     // the view hierarchy.
    254     bool shouldFlipContext = true;
    255 #if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    256     shouldFlipContext = false;
    257 #endif
    258     if (shouldFlipContext) {
    259         CGContextTranslateCTM(cgContext, viewFrame.origin.x - viewBounds.origin.x, viewFrame.origin.y + viewFrame.size.height + viewBounds.origin.y);
    260         CGContextScaleCTM(cgContext, 1, -1);
    261     } else
    262         CGContextTranslateCTM(cgContext, viewFrame.origin.x - viewBounds.origin.x, viewFrame.origin.y + viewBounds.origin.y);
     246    // the view hierarchy. Since Widget::paint is always called with a context that has a flipped coordinate system, and
     247    // -[NSView displayRectIgnoringOpacity:inContext:] expects an unflipped context we always flip here.
     248    CGContextTranslateCTM(cgContext, viewFrame.origin.x - viewBounds.origin.x, viewFrame.origin.y + viewFrame.size.height + viewBounds.origin.y);
     249    CGContextScaleCTM(cgContext, 1, -1);
    263250
    264251    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    265252    {
    266         NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES];
     253        NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:NO];
    267254        [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]] inContext:nsContext];
    268255    }
Note: See TracChangeset for help on using the changeset viewer.