| 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> | |
| 8 #include <limits> | |
| 9 | |
| 10 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 11 #include <stddef.h> | 8 #include <stddef.h> |
| 12 | 9 |
| 10 #include <cmath> |
| 11 #include <limits> |
| 12 #include <memory> |
| 13 |
| 13 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 14 #include "base/mac/scoped_nsobject.h" | 15 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Returns NSImageRep whose pixel size most closely matches |desired_size|. | 22 // Returns NSImageRep whose pixel size most closely matches |desired_size|. |
| 23 NSImageRep* GetNSImageRepWithPixelSize(NSImage* image, | 23 NSImageRep* GetNSImageRepWithPixelSize(NSImage* image, |
| 24 NSSize desired_size) { | 24 NSSize desired_size) { |
| 25 float smallest_diff = std::numeric_limits<float>::max(); | 25 float smallest_diff = std::numeric_limits<float>::max(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 [image addRepresentation: | 109 [image addRepresentation: |
| 110 skia::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), | 110 skia::SkBitmapToNSBitmapImageRepWithColorSpace(it->sk_bitmap(), |
| 111 color_space)]; | 111 color_space)]; |
| 112 } | 112 } |
| 113 | 113 |
| 114 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; | 114 [image setSize:NSMakeSize(image_skia.width(), image_skia.height())]; |
| 115 return [image.release() autorelease]; | 115 return [image.release() autorelease]; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace gfx | 118 } // namespace gfx |
| OLD | NEW |