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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.mm

Issue 7572031: Always call the class methods to save/restore contexts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ensure saving before context access Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h"
6 6
7 #include "chrome/browser/ntp_background_util.h" 7 #include "chrome/browser/ntp_background_util.h"
8 #include "chrome/browser/themes/theme_service.h" 8 #include "chrome/browser/themes/theme_service.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it 49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it
50 // to morph the bubble to a regular bar (shape and colour). 50 // to morph the bubble to a regular bar (shape and colour).
51 CGFloat morph = [controller_ detachedMorphProgress]; 51 CGFloat morph = [controller_ detachedMorphProgress];
52 52
53 NSRect bounds = [self bounds]; 53 NSRect bounds = [self bounds];
54 54
55 ui::ThemeProvider* themeProvider = [controller_ themeProvider]; 55 ui::ThemeProvider* themeProvider = [controller_ themeProvider];
56 if (!themeProvider) 56 if (!themeProvider)
57 return; 57 return;
58 58
59 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
59 NSGraphicsContext* context = [NSGraphicsContext currentContext]; 60 NSGraphicsContext* context = [NSGraphicsContext currentContext];
60 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context);
61 61
62 // Draw the background. 62 // Draw the background.
63 { 63 {
64 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so 64 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so
65 // explicitly scope this. 65 // explicitly scope this.
66 // 66 //
67 // Paint the entire bookmark bar, even if the damage rect is much smaller 67 // Paint the entire bookmark bar, even if the damage rect is much smaller
68 // because PaintBackgroundDetachedMode() assumes that area's origin is 68 // because PaintBackgroundDetachedMode() assumes that area's origin is
69 // (0, 0) and that its size is the size of the bookmark bar. 69 // (0, 0) and that its size is the size of the bookmark bar.
70 // 70 //
(...skipping 25 matching lines...) Expand all
96 96
97 // Draw the rounded rectangle. 97 // Draw the rounded rectangle.
98 NSColor* toolbarColor = 98 NSColor* toolbarColor =
99 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); 99 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true);
100 CGFloat alpha = morph * [toolbarColor alphaComponent]; 100 CGFloat alpha = morph * [toolbarColor alphaComponent];
101 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. 101 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity.
102 [border fill]; 102 [border fill];
103 103
104 // Fade in/out the background. 104 // Fade in/out the background.
105 { 105 {
106 gfx::ScopedNSGraphicsContextSaveGState bgScopedState(context); 106 gfx::ScopedNSGraphicsContextSaveGState bgScopedState;
107 [border setClip]; 107 [border setClip];
108 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; 108 CGContextRef cgContext = (CGContextRef)[context graphicsPort];
Mark Mentovai 2011/08/04 23:20:17 Does [NSGraphicContext currentContext] belong righ
Avi (use Gerrit) 2011/08/05 00:18:50 Done.
109 CGContextBeginTransparencyLayer(cgContext, NULL); 109 CGContextBeginTransparencyLayer(cgContext, NULL);
110 CGContextSetAlpha(cgContext, 1 - morph); 110 CGContextSetAlpha(cgContext, 1 - morph);
111 [context setPatternPhase:[[self window] themePatternPhase]]; 111 [context setPatternPhase:[[self window] themePatternPhase]];
112 [self drawBackgroundWithOpaque:YES]; 112 [self drawBackgroundWithOpaque:YES];
113 CGContextEndTransparencyLayer(cgContext); 113 CGContextEndTransparencyLayer(cgContext);
114 } 114 }
115 115
116 // Draw the border of the rounded rectangle. 116 // Draw the border of the rounded rectangle.
117 NSColor* borderColor = themeProvider->GetNSColor( 117 NSColor* borderColor = themeProvider->GetNSColor(
118 ThemeService::COLOR_TOOLBAR_BUTTON_STROKE, true); 118 ThemeService::COLOR_TOOLBAR_BUTTON_STROKE, true);
(...skipping 12 matching lines...) Expand all
131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, 131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5,
132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); 132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5);
133 CGFloat dividerWidth = 133 CGFloat dividerWidth =
134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; 134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5;
135 [divider moveToPoint:dividerStart]; 135 [divider moveToPoint:dividerStart];
136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; 136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)];
137 [divider stroke]; 137 [divider stroke];
138 } 138 }
139 139
140 @end // @implementation BookmarkBarToolbarView 140 @end // @implementation BookmarkBarToolbarView
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/download/download_item_cell.mm » ('j') | chrome/browser/ui/cocoa/tabs/tab_view.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698