OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/image/image_skia_util_mac.h" | 5 #include "ui/gfx/image/image_skia_util_mac.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #import <AppKit/AppKit.h> | 10 #import <AppKit/AppKit.h> |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SkBitmap bitmap(gfx::NSImageRepToSkBitmapWithColorSpace(ns_image_rep, | 71 SkBitmap bitmap(gfx::NSImageRepToSkBitmapWithColorSpace(ns_image_rep, |
72 desired_size_for_scale, false, base::mac::GetGenericRGBColorSpace())); | 72 desired_size_for_scale, false, base::mac::GetGenericRGBColorSpace())); |
73 if (bitmap.isNull()) | 73 if (bitmap.isNull()) |
74 continue; | 74 continue; |
75 | 75 |
76 image_skia.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); | 76 image_skia.AddRepresentation(gfx::ImageSkiaRep(bitmap, scale)); |
77 } | 77 } |
78 return image_skia; | 78 return image_skia; |
79 } | 79 } |
80 | 80 |
81 gfx::ImageSkia ApplicationIconAtSize(int desired_size) { | |
82 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; | |
83 return ImageSkiaFromResizedNSImage(image, | |
84 NSMakeSize(desired_size, desired_size)); | |
85 } | |
86 | |
87 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) { | 81 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) { |
88 if (image_skia.isNull()) | 82 if (image_skia.isNull()) |
89 return nil; | 83 return nil; |
90 | 84 |
91 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]); | 85 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]); |
92 image_skia.EnsureRepsForSupportedScales(); | 86 image_skia.EnsureRepsForSupportedScales(); |
93 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); | 87 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); |
94 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); | 88 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); |
95 it != image_reps.end(); ++it) { | 89 it != image_reps.end(); ++it) { |
96 [image addRepresentation: | 90 [image addRepresentation: |
(...skipping 17 matching lines...) Expand all Loading... |
114 [image addRepresentation: | 108 [image addRepresentation: |
115 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), | 109 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), |
116 color_space)]; | 110 color_space)]; |
117 } | 111 } |
118 | 112 |
119 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; | 113 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; |
120 return [image.release() autorelease]; | 114 return [image.release() autorelease]; |
121 } | 115 } |
122 | 116 |
123 } // namespace gfx | 117 } // namespace gfx |
OLD | NEW |