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

Side by Side Diff: ui/gfx/image/image_skia_util_mac.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 11
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #include "base/memory/scoped_nsobject.h" 13 #include "base/mac/scoped_nsobject.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "skia/ext/skia_utils_mac.h" 15 #include "skia/ext/skia_utils_mac.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/image/image_skia.h" 17 #include "ui/gfx/image/image_skia.h"
18 18
19 namespace { 19 namespace {
20 20
21 // Returns NSImageRep whose pixel size most closely matches |desired_size|. 21 // Returns NSImageRep whose pixel size most closely matches |desired_size|.
22 NSImageRep* GetNSImageRepWithPixelSize(NSImage* image, 22 NSImageRep* GetNSImageRepWithPixelSize(NSImage* image,
23 NSSize desired_size) { 23 NSSize desired_size) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 gfx::ImageSkia ApplicationIconAtSize(int desired_size) { 82 gfx::ImageSkia ApplicationIconAtSize(int desired_size) {
83 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; 83 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"];
84 return ImageSkiaFromResizedNSImage(image, 84 return ImageSkiaFromResizedNSImage(image,
85 NSMakeSize(desired_size, desired_size)); 85 NSMakeSize(desired_size, desired_size));
86 } 86 }
87 87
88 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) { 88 NSImage* NSImageFromImageSkia(const gfx::ImageSkia& image_skia) {
89 if (image_skia.isNull()) 89 if (image_skia.isNull())
90 return nil; 90 return nil;
91 91
92 scoped_nsobject<NSImage> image([[NSImage alloc] init]); 92 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]);
93 image_skia.EnsureRepsForSupportedScaleFactors(); 93 image_skia.EnsureRepsForSupportedScaleFactors();
94 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); 94 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps();
95 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); 95 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
96 it != image_reps.end(); ++it) { 96 it != image_reps.end(); ++it) {
97 [image addRepresentation: 97 [image addRepresentation:
98 gfx::SkBitmapToNSBitmapImageRep(it->sk_bitmap())]; 98 gfx::SkBitmapToNSBitmapImageRep(it->sk_bitmap())];
99 } 99 }
100 100
101 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; 101 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())];
102 return [image.release() autorelease]; 102 return [image.release() autorelease];
103 } 103 }
104 104
105 NSImage* NSImageFromImageSkiaWithColorSpace(const gfx::ImageSkia& image_skia, 105 NSImage* NSImageFromImageSkiaWithColorSpace(const gfx::ImageSkia& image_skia,
106 CGColorSpaceRef color_space) { 106 CGColorSpaceRef color_space) {
107 if (image_skia.isNull()) 107 if (image_skia.isNull())
108 return nil; 108 return nil;
109 109
110 scoped_nsobject<NSImage> image([[NSImage alloc] init]); 110 base::scoped_nsobject<NSImage> image([[NSImage alloc] init]);
111 image_skia.EnsureRepsForSupportedScaleFactors(); 111 image_skia.EnsureRepsForSupportedScaleFactors();
112 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps(); 112 std::vector<gfx::ImageSkiaRep> image_reps = image_skia.image_reps();
113 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin(); 113 for (std::vector<gfx::ImageSkiaRep>::const_iterator it = image_reps.begin();
114 it != image_reps.end(); ++it) { 114 it != image_reps.end(); ++it) {
115 [image addRepresentation: 115 [image addRepresentation:
116 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), 116 gfx::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(),
117 color_space)]; 117 color_space)];
118 } 118 }
119 119
120 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; 120 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())];
121 return [image.release() autorelease]; 121 return [image.release() autorelease];
122 } 122 }
123 123
124 } // namespace gfx 124 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698