Commit 4f0f726c authored by andresantoso's avatar andresantoso Committed by Commit bot

Mac: Optimize toolbar/bookmark drawing during live resize

The default theme's background image is a subtle texture pattern that we can
scale without being easily noticed.
When using the default theme, let the layer get scaled during live resize
and redraw at the end of resize.

TabStripView is changed to no longer be a subclass of
BackgroundGradientView because we don't want to scale its layer (it may
draw a drop arrow).
It is also inefficient for it to call cr_recursivelySetNeedsDisplay.

With this optimization, the following views no longer redraw repeatedly
during live resize (when using default theme):
    ToolbarView
    BookmarkBarToolbarView
    DownloadShelfView
    OmniboxPopupTopSeparatorView

BUG=453996

Review URL: https://codereview.chromium.org/867273003

Cr-Commit-Position: refs/heads/master@{#314661}
parent 715cb510
......@@ -121,10 +121,39 @@
}
}
- (void)viewWillStartLiveResize {
[super viewWillStartLiveResize];
ui::ThemeProvider* themeProvider = [[self window] themeProvider];
if (themeProvider && themeProvider->UsingSystemTheme()) {
// The default theme's background image is a subtle texture pattern that
// we can scale without being easily noticed. Optimize this case by
// skipping redraws during live resize.
[self setLayerContentsRedrawPolicy:
NSViewLayerContentsRedrawOnSetNeedsDisplay];
}
}
- (void)viewDidEndLiveResize {
[super viewDidEndLiveResize];
if ([self layerContentsRedrawPolicy] !=
NSViewLayerContentsRedrawDuringViewResize) {
// If we have been scaling the layer during live resize, now is the time to
// redraw the layer.
[self setLayerContentsRedrawPolicy:
NSViewLayerContentsRedrawDuringViewResize];
[self setNeedsDisplay:YES];
}
}
- (void)setFrameOrigin:(NSPoint)origin {
// The background color depends on the view's vertical position. This impacts
// any child views that draw using this view's functions.
if (NSMinY([self frame]) != origin.y)
// When resizing the window, the view's vertical position (NSMinY) may change
// even though our relative position to the nearest window edge is still the
// same. Don't redraw unnecessarily in this case.
if (![self inLiveResize] && NSMinY([self frame]) != origin.y)
[self cr_recursivelySetNeedsDisplay:YES];
[super setFrameOrigin:origin];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment