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

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_view.mm

Issue 6904026: Add and use gfx::ScopedNSGraphicsContextState (ui/gfx/scoped_ns_graphics_context_state_mac.h). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename Created 9 years, 8 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
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 {
« no previous file with comments | « chrome/browser/ui/cocoa/styled_text_field_cell.mm ('k') | chrome/browser/ui/cocoa/wrench_menu/wrench_menu_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698