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

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

Issue 894423003: Mac: Optimize HistoryOverlayView using layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@themed-drawing
Patch Set: Created 5 years, 11 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/history_overlay_controller.mm
diff --git a/chrome/browser/ui/cocoa/history_overlay_controller.mm b/chrome/browser/ui/cocoa/history_overlay_controller.mm
index 88237a3c6f771d1cc37f5bb940f9d954df5a9270..005913b7fc007e631552059b92c2d165df7ad77b 100644
--- a/chrome/browser/ui/cocoa/history_overlay_controller.mm
+++ b/chrome/browser/ui/cocoa/history_overlay_controller.mm
@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/history_overlay_controller.h"
#include "base/logging.h"
+#include "base/mac/scoped_cftyperef.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "grit/theme_resources.h"
#include "ui/base/resource/resource_bundle.h"
@@ -52,6 +53,10 @@ const CGFloat kShieldHeightCompletionAdjust = 10;
if ((self = [super initWithFrame:frame])) {
mode_ = mode;
+ // A layer-hosting view.
+ [self setLayer:[CALayer layer]];
+ [self setWantsLayer:YES];
+
// If going backward, the arrow needs to be in the right half of the circle,
// so offset the X position.
CGFloat offset = mode_ == kHistoryOverlayModeBack ? kShieldRadius : 0;
@@ -67,11 +72,18 @@ const CGFloat kShieldHeightCompletionAdjust = 10;
return self;
}
-- (void)drawRect:(NSRect)dirtyRect {
- NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:self.bounds];
- NSColor* fillColor = [NSColor colorWithCalibratedWhite:0 alpha:shieldAlpha_];
- [fillColor set];
- [path fill];
+- (void)setFrameSize:(CGSize)frameSize {
+ [super setFrameSize:frameSize];
+ // Draw an oval.
+ CGFloat radius = std::min(frameSize.width, frameSize.height) / 2.0;
Robert Sesek 2015/02/04 00:21:13 Why min here instead of just always width?
Andre 2015/02/04 01:08:55 height >= width always, so that would work. Done.
+ [[self layer] setCornerRadius:radius];
+}
+
+- (void)setShieldAlpha:(CGFloat)shieldAlpha {
+ shieldAlpha_ = shieldAlpha;
+ base::ScopedCFTypeRef<CGColorRef> fillColor(
+ CGColorCreateGenericGray(0, shieldAlpha));
+ [[self layer] setBackgroundColor:fillColor];
}
@end
@@ -129,7 +141,6 @@ const CGFloat kShieldHeightCompletionAdjust = 10;
self.view.frame = frame;
[contentView_ setShieldAlpha:shieldAlpha];
- [contentView_ setNeedsDisplay:YES];
}
- (void)showPanelForView:(NSView*)view {
« 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