| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <base/logging.h> | |
| 6 #include "chrome/browser/cocoa/cocoa_utils.h" | |
| 7 #import <QuartzCore/CIImage.h> | |
| 8 #include "third_party/skia/include/utils/mac/SkCGUtils.h" | |
| 9 #include "third_party/skia/include/core/SkColorPriv.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // Callback passed to CGDataProviderCreateWithData() | |
| 14 void ReleaseData(void* info, const void* pixelData, size_t size) { | |
| 15 // info is a non-const pixelData | |
| 16 if (info) | |
| 17 free(info); | |
| 18 } | |
| 19 | |
| 20 } | |
| 21 | |
| 22 namespace CocoaUtils { | |
| 23 | |
| 24 NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) { | |
| 25 // First convert SkBitmap to CGImageRef. | |
| 26 CGImageRef cgimage = SkCreateCGImageRef(skiaBitmap); | |
| 27 | |
| 28 // Now convert to NSImage. | |
| 29 NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] | |
| 30 initWithCGImage:cgimage] autorelease]; | |
| 31 CFRelease(cgimage); | |
| 32 NSImage* image = [[[NSImage alloc] init] autorelease]; | |
| 33 [image addRepresentation:bitmap]; | |
| 34 return image; | |
| 35 } | |
| 36 | |
| 37 } // namespace CocoaUtils | |
| 38 | |
| OLD | NEW |