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

Side by Side Diff: chrome/browser/cocoa/cocoa_utils.mm

Issue 131018: Add favicons to tabs on the Mac (Closed)
Patch Set: Rebase Created 11 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/cocoa_utils.h ('k') | chrome/browser/cocoa/cocoa_utils_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/cocoa_utils.h ('k') | chrome/browser/cocoa/cocoa_utils_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698