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

Unified Diff: skia/ext/skia_utils_mac.mm

Issue 10837158: mac: Delete more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rsesek Created 8 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 side-by-side diff with in-line comments
Download patch
Index: skia/ext/skia_utils_mac.mm
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index 1811daefde2580c033ba632379c66e409e1c3c39..64b14f2eb0afee9433617602f215122914887401 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -7,7 +7,6 @@
#import <AppKit/AppKit.h>
#include "base/logging.h"
-#include "base/mac/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
@@ -57,45 +56,28 @@ SkBitmap NSImageOrNSImageRepToSkBitmap(
// Something went really wrong. Best guess is that the bitmap data is invalid.
DCHECK(context);
- // Save the current graphics context so that we can restore it later.
- NSGraphicsContext* old_context = [NSGraphicsContext currentContext];
[NSGraphicsContext saveGraphicsState];
- // Dummy context that we will draw into.
NSGraphicsContext* context_cocoa =
[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
[NSGraphicsContext setCurrentContext:context_cocoa];
- // This will stretch any images to |size| if it does not fit or is non-square.
NSRect drawRect = NSMakeRect(0, 0, size.width, size.height);
-
- // NSImage does caching such that subsequent drawing is much faster (on my
- // machine, about 4x faster). Unfortunately on 10.5 NSImageRep doesn't do
- // caching. For this reason we draw using an NSImage if available. Once
- // 10.5 is no longer supported we can drop this and always use NSImageRep.
if (image) {
[image drawInRect:drawRect
fromRect:NSZeroRect
operation:NSCompositeCopy
fraction:1.0];
} else {
- // Use NSCompositeCopy if available, it's slightly faster.
- if ([image_rep respondsToSelector:@selector(
- drawInRect:fromRect:operation:fraction:respectFlipped:hints:)]) {
- [image_rep drawInRect:drawRect
- fromRect:NSZeroRect
- operation:NSCompositeCopy
- fraction:1.0
- respectFlipped:NO
- hints:NO];
- } else {
- [image_rep drawInRect:drawRect];
- }
+ [image_rep drawInRect:drawRect
+ fromRect:NSZeroRect
+ operation:NSCompositeCopy
+ fraction:1.0
+ respectFlipped:NO
+ hints:NO];
}
[NSGraphicsContext restoreGraphicsState];
- if (!old_context && base::mac::IsOSLeopardOrEarlier())
- [NSGraphicsContext setCurrentContext:nil];
return bitmap;
}
@@ -224,8 +206,9 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) {
return NSImageOrNSImageRepToSkBitmap(image, nil, size, is_opaque);
}
-SkBitmap NSImageRepToSkBitmap(NSImageRep* image, NSSize size, bool is_opaque) {
- return NSImageOrNSImageRepToSkBitmap(nil, image, size, is_opaque);
+SkBitmap NSImageRepToSkBitmap(
+ NSImageRep* image_rep, NSSize size, bool is_opaque) {
+ return NSImageOrNSImageRepToSkBitmap(nil, image_rep, size, is_opaque);
}
NSBitmapImageRep* SkBitmapToNSBitmapImageRep(const SkBitmap& skiaBitmap) {

Powered by Google App Engine
This is Rietveld 408576698