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

Unified Diff: chrome/browser/cocoa/extensions/browser_action_button.mm

Issue 2635005: [Mac] Simplify generating composited browser-action image. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: scoped_nsobject -> earlier -autorelease Created 10 years, 6 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/cocoa/extensions/browser_action_button.mm
diff --git a/chrome/browser/cocoa/extensions/browser_action_button.mm b/chrome/browser/cocoa/extensions/browser_action_button.mm
index 946f87229b8b3ad4efe070ad2fd2da66029961d2..a5a2aceb5cfe4350892628c5bd4f9931a37d6af4 100644
--- a/chrome/browser/cocoa/extensions/browser_action_button.mm
+++ b/chrome/browser/cocoa/extensions/browser_action_button.mm
@@ -283,22 +283,9 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
- (NSImage*)compositedImage {
NSRect bounds = NSMakeRect(0, 0, kBrowserActionWidth, kBrowserActionHeight);
- NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc]
- initWithBitmapDataPlanes:NULL
- pixelsWide:NSWidth(bounds)
- pixelsHigh:NSHeight(bounds)
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSCalibratedRGBColorSpace
- bitmapFormat:0
- bytesPerRow:0
- bitsPerPixel:0];
+ NSImage* image = [[[NSImage alloc] initWithSize:bounds.size] autorelease];
+ [image lockFocus];
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:
- [NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap]];
[[NSColor clearColor] set];
NSRectFill(bounds);
[[self cell] setIconShadow];
@@ -319,11 +306,8 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
bounds.origin.x -= kShadowOffset;
[[self cell] drawBadgeWithinFrame:bounds];
- [NSGraphicsContext restoreGraphicsState];
- NSImage* compositeImage =
- [[[NSImage alloc] initWithSize:[bitmap size]] autorelease];
- [compositeImage addRepresentation:bitmap];
- return compositeImage;
+ [image unlockFocus];
+ return image;
}
@end
« 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