Index: chrome/browser/ui/cocoa/tabs/tab_view.mm |
diff --git a/chrome/browser/ui/cocoa/tabs/tab_view.mm b/chrome/browser/ui/cocoa/tabs/tab_view.mm |
index 25b62fe20b762b1c91c3e09e296f4def8bfad53f..8e88fef0a6da3c4188987a1c39cc35524336db5e 100644 |
--- a/chrome/browser/ui/cocoa/tabs/tab_view.mm |
+++ b/chrome/browser/ui/cocoa/tabs/tab_view.mm |
@@ -17,6 +17,7 @@ |
#include "grit/theme_resources.h" |
#include "grit/theme_resources_standard.h" |
#include "ui/base/l10n/l10n_util.h" |
+#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
namespace { |
@@ -652,7 +653,7 @@ const CGFloat kRapidCloseDist = 2.5; |
const CGFloat lineWidth = [self cr_lineWidth]; |
NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
- [context saveGraphicsState]; |
+ gfx::ScopedNSGraphicsContextSaveGState scopedGState(context); |
ThemeService* themeProvider = |
static_cast<ThemeService*>([[self window] themeProvider]); |
@@ -701,7 +702,7 @@ const CGFloat kRapidCloseDist = 2.5; |
CGFloat alertAlpha = [self alertAlpha]; |
if (selected || hoverAlpha > 0 || alertAlpha > 0) { |
// Draw the selected background / glow overlay. |
- [context saveGraphicsState]; |
+ gfx::ScopedNSGraphicsContextSaveGState drawHoverState(context); |
CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); |
CGContextBeginTransparencyLayer(cgContext, 0); |
if (!selected) { |
@@ -712,9 +713,10 @@ const CGFloat kRapidCloseDist = 2.5; |
CGContextSetAlpha(cgContext, backgroundAlpha); |
} |
[path addClip]; |
- [context saveGraphicsState]; |
- [super drawBackground]; |
- [context restoreGraphicsState]; |
+ { |
+ gfx::ScopedNSGraphicsContextSaveGState drawBackgroundState(context); |
+ [super drawBackground]; |
+ } |
// Draw a mouse hover gradient for the default themes. |
if (!selected && hoverAlpha > 0) { |
@@ -738,7 +740,6 @@ const CGFloat kRapidCloseDist = 2.5; |
} |
CGContextEndTransparencyLayer(cgContext); |
- [context restoreGraphicsState]; |
} |
BOOL active = [[self window] isKeyWindow] || [[self window] isMainWindow]; |
@@ -768,11 +769,12 @@ const CGFloat kRapidCloseDist = 2.5; |
[context restoreGraphicsState]; |
// Draw the top stroke. |
- [context saveGraphicsState]; |
- [borderColor set]; |
- [path setLineWidth:lineWidth]; |
- [path stroke]; |
- [context restoreGraphicsState]; |
+ { |
+ gfx::ScopedNSGraphicsContextSaveGState drawBorderState(context); |
+ [borderColor set]; |
+ [path setLineWidth:lineWidth]; |
+ [path stroke]; |
+ } |
// Mimic the tab strip's bottom border, which consists of a dark border |
// and light highlight. |
@@ -788,8 +790,6 @@ const CGFloat kRapidCloseDist = 2.5; |
[highlightColor set]; |
NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); |
} |
- |
- [context restoreGraphicsState]; |
} |
- (void)viewDidMoveToWindow { |