diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 18:10:04 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 18:10:04 +0000 |
commit | 3c60f22dcdbc4b3294d49696b7c841fcffca15a0 (patch) | |
tree | b9f4cde642767a300a5e5ab392820d44de17bee7 /chrome/browser/cocoa | |
parent | 2fee51c880d7dbe4ce3080a4f723e4d978bf3705 (diff) | |
download | chromium_src-3c60f22dcdbc4b3294d49696b7c841fcffca15a0.zip chromium_src-3c60f22dcdbc4b3294d49696b7c841fcffca15a0.tar.gz chromium_src-3c60f22dcdbc4b3294d49696b7c841fcffca15a0.tar.bz2 |
[Mac] Simplify generating composited browser-action image.
Convert from using NSBitmapImageRep plus context manipulation to
-[NSImage lockFocus].
BUG=none
TEST=Browser actions look the same as before.
Review URL: http://codereview.chromium.org/2635005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/extensions/browser_action_button.mm | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_action_button.mm b/chrome/browser/cocoa/extensions/browser_action_button.mm index 946f872..a5a2ace 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 |