Disable layer-backed view on Yosemite (close #258)

This commit is contained in:
1024jp 2015-01-15 12:12:55 +01:00
parent 657caa3d88
commit 3de1517cb3
5 changed files with 27 additions and 17 deletions

View File

@ -39,6 +39,7 @@ Change Log
- Now, Utility actions perform with multiple selection.
- Delay timing to save text key bindings setting.
- Localize document types.
- Improve text rendering with non-opaque view.
- Tweak text view drawing peformance.

View File

@ -34,6 +34,9 @@
#import "constants.h"
const CGFloat kMinVerticalThickness = 32.0;
@interface CELineNumberView ()
@property (nonatomic) NSTimer *draggingTimer;
@ -155,7 +158,7 @@ static const NSString *LineNumberFontName;
CGFloat charWidth = advance.width;
// prepare frame width
CGFloat width = kDefaultLineNumWidth;
CGFloat width = kMinVerticalThickness;
// adjust drawing coordinate
NSPoint relativePoint = [self convertPoint:NSZeroPoint fromView:[self textView]];
@ -235,7 +238,7 @@ static const NSString *LineNumberFontName;
}
// adjust thickness
CGFloat requiredWidth = MAX(numberOfDigits(lineNum) * charWidth + 3 * kLineNumPadding, kDefaultLineNumWidth);
CGFloat requiredWidth = MAX(numberOfDigits(lineNum) * charWidth + 3 * kLineNumPadding, kMinVerticalThickness);
[self setRuleThickness:ceil(requiredWidth)];
CGContextRestoreGState(context);
@ -256,7 +259,7 @@ static const NSString *LineNumberFontName;
- (CGFloat)requiredThickness
// ------------------------------------------------------
{
return [self ruleThickness];
return MAX(kMinVerticalThickness, [self ruleThickness]);
}

View File

@ -128,6 +128,10 @@ static NSPoint kTextContainerOrigin;
// setup theme
[self setTheme:[CETheme themeWithName:[defaults stringForKey:CEDefaultThemeKey]]];
// set layer drawing policies
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
[self setLayerContentsPlacement:NSViewLayerContentsPlacementScaleAxesIndependently];
// set values
_autoTabExpandEnabled = [defaults boolForKey:CEDefaultAutoExpandTabKey];
[self setSmartInsertDeleteEnabled:[defaults boolForKey:CEDefaultSmartInsertAndDeleteKey]];
@ -203,11 +207,6 @@ static NSPoint kTextContainerOrigin;
//
[[self window] setBackgroundColor:[[self theme] backgroundColor]];
//
[[self enclosingScrollView] setWantsLayer:YES];
[[[self enclosingScrollView] contentView] setCopiesOnScroll:YES];
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay];
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didWindowOpacityChange:)
@ -1449,18 +1448,27 @@ static NSPoint kTextContainerOrigin;
// ------------------------------------------------------
///
/// window's opacity did change
- (void)didWindowOpacityChange:(NSNotification *)notification
// ------------------------------------------------------
{
// layer-backed
[self setDrawsBackground:[[self window] isOpaque]];
BOOL isOpaque = [[self window] isOpaque];
//
//
// (2014-10 by 1024jp)
[[self layer] setNeedsDisplayOnBoundsChange:[[self window] isOpaque]];
// let text view have own background if possible
[self setDrawsBackground:isOpaque];
// By opaque window, turn `copiesOnScroll` on to enable Responsive Scrolling with traditional drawing.
// -> Better not using layer-backed view to avoid ugly text rendering and performance issue (1024jp on 2015-01)
// cf. Responsive Scrolling section in the Release Notes for OS X 10.9
[[[self enclosingScrollView] contentView] setCopiesOnScroll:isOpaque];
// Make view layer-backed in order to disable dropshadow from letters on Mavericks and earlier (1024jp on 2015-01)
// -> This makes scrolling laggy on huge file.
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9) {
[[self enclosingScrollView] setWantsLayer:!isOpaque];
}
// redraw visible area
[self setNeedsDisplayInRect:[self visibleRect] avoidAdditionalLayout:YES];
}

View File

@ -412,7 +412,6 @@ extern NSString *const CEOutlineItemFontItalicKey;
extern NSString *const CEOutlineItemUnderlineMaskKey;
// layout constants
extern CGFloat const kDefaultLineNumWidth;
extern CGFloat const kLineNumPadding;
extern NSString *const kNavigationBarFontName;

View File

@ -358,7 +358,6 @@ NSString *const CEOutlineItemFontItalicKey = @"outlineItemFontItalic";
NSString *const CEOutlineItemUnderlineMaskKey = @"outlineItemUnderlineMask";
// layout constants
CGFloat const kDefaultLineNumWidth = 32.0;
CGFloat const kLineNumPadding = 3.0;
NSString *const kNavigationBarFontName = @"Helvetica";