Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5941)

Unified Diff: chrome/browser/ui/cocoa/background_gradient_view.mm

Issue 867273003: Mac: Optimize toolbar/bookmark drawing during live resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/background_gradient_view.mm
diff --git a/chrome/browser/ui/cocoa/background_gradient_view.mm b/chrome/browser/ui/cocoa/background_gradient_view.mm
index fe583563d12c82fd1f9bb6e30227a9a59cf11d58..fdad7a826f4d3a4cfbdcf6a863d2908f3f3d1efc 100644
--- a/chrome/browser/ui/cocoa/background_gradient_view.mm
+++ b/chrome/browser/ui/cocoa/background_gradient_view.mm
@@ -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];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698