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

Unified Diff: chrome/browser/cocoa/animatable_image.mm

Issue 3072005: Move NSImage-to-CGImageRef conversion code into a common helper function in base/mac_util.h. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix test Created 10 years, 5 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 | « base/mac_util_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/animatable_image.mm
diff --git a/chrome/browser/cocoa/animatable_image.mm b/chrome/browser/cocoa/animatable_image.mm
index db0822417ab6ad117894374fc57a4ac975455bc4..06014c29067ca5b936fa04d2ad4a8d05ab646db2 100644
--- a/chrome/browser/cocoa/animatable_image.mm
+++ b/chrome/browser/cocoa/animatable_image.mm
@@ -5,6 +5,7 @@
#import "chrome/browser/cocoa/animatable_image.h"
#include "base/logging.h"
+#import "base/mac_util.h"
#include "base/scoped_cftyperef.h"
#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
@@ -131,31 +132,10 @@
// image into a bitmap CGImageRef. This is based loosely on
// http://www.cocoadev.com/index.pl?CGImageRef.
- (void)setLayerContents:(CALayer*)layer {
- NSSize size = [image_ size];
- CGContextRef context =
- CGBitmapContextCreate(NULL, // Allow CG to allocate memory.
- size.width,
- size.height,
- 8, // bitsPerComponent
- 0, // bytesPerRow - CG will calculate by default.
- [[NSColorSpace genericRGBColorSpace] CGColorSpace],
- kCGBitmapByteOrder32Host |
- kCGImageAlphaPremultipliedFirst);
-
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:
- [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO]];
- [image_ drawInRect:NSMakeRect(0,0, size.width, size.height)
- fromRect:NSZeroRect
- operation:NSCompositeCopy
- fraction:1.0];
- [NSGraphicsContext restoreGraphicsState];
-
- scoped_cftyperef<CGImageRef> cgImage(CGBitmapContextCreateImage(context));
- CGContextRelease(context);
-
+ scoped_cftyperef<CGImageRef> image(
+ mac_util::CopyNSImageToCGImage(image_.get()));
// Create the layer that will be animated.
- [layer setContents:(id)cgImage.get()];
+ [layer setContents:(id)image.get()];
}
// CAAnimation delegate method called when the animation is complete.
« no previous file with comments | « base/mac_util_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698