 Chromium Code Reviews
 Chromium Code Reviews Issue 6849030:
  Add support for multi resolution icons   (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 6849030:
  Add support for multi resolution icons   (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef SKIA_EXT_SKIA_UTILS_MAC_H_ | 5 #ifndef SKIA_EXT_SKIA_UTILS_MAC_H_ | 
| 6 #define SKIA_EXT_SKIA_UTILS_MAC_H_ | 6 #define SKIA_EXT_SKIA_UTILS_MAC_H_ | 
| 7 #pragma once | 7 #pragma once | 
| 8 | 8 | 
| 9 #include <CoreGraphics/CGColor.h> | 9 #include <CoreGraphics/CGColor.h> | 
| 10 #include <vector> | |
| 10 | 11 | 
| 11 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" | 
| 12 | 13 | 
| 13 struct SkIRect; | 14 struct SkIRect; | 
| 14 struct SkPoint; | 15 struct SkPoint; | 
| 15 struct SkRect; | 16 struct SkRect; | 
| 16 class SkBitmap; | 17 class SkBitmap; | 
| 17 class SkMatrix; | 18 class SkMatrix; | 
| 18 #ifdef __LP64__ | 19 #ifdef __LP64__ | 
| 19 typedef CGSize NSSize; | 20 typedef CGSize NSSize; | 
| 20 #else | 21 #else | 
| 21 typedef struct _NSSize NSSize; | 22 typedef struct _NSSize NSSize; | 
| 22 #endif | 23 #endif | 
| 23 | 24 | 
| 24 #ifdef __OBJC__ | 25 #ifdef __OBJC__ | 
| 25 @class NSImage; | 26 @class NSImage; | 
| 27 @class NSImageRep; | |
| 26 #else | 28 #else | 
| 27 class NSImage; | 29 class NSImage; | 
| 30 class NSImageRep; | |
| 28 #endif | 31 #endif | 
| 29 | 32 | 
| 30 namespace gfx { | 33 namespace gfx { | 
| 31 | 34 | 
| 32 // Converts a Skia point to a CoreGraphics CGPoint. | 35 // Converts a Skia point to a CoreGraphics CGPoint. | 
| 33 // Both use same in-memory format. | 36 // Both use same in-memory format. | 
| 34 inline const CGPoint& SkPointToCGPoint(const SkPoint& point) { | 37 inline const CGPoint& SkPointToCGPoint(const SkPoint& point) { | 
| 35 return reinterpret_cast<const CGPoint&>(point); | 38 return reinterpret_cast<const CGPoint&>(point); | 
| 36 } | 39 } | 
| 37 | 40 | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 57 | 60 | 
| 58 // Converts ARGB to CGColorRef. | 61 // Converts ARGB to CGColorRef. | 
| 59 CGColorRef SkColorToCGColorRef(SkColor color); | 62 CGColorRef SkColorToCGColorRef(SkColor color); | 
| 60 | 63 | 
| 61 // Converts a CGImage to a SkBitmap. | 64 // Converts a CGImage to a SkBitmap. | 
| 62 SkBitmap CGImageToSkBitmap(CGImageRef image); | 65 SkBitmap CGImageToSkBitmap(CGImageRef image); | 
| 63 | 66 | 
| 64 // Draws an NSImage with a given size into a SkBitmap. | 67 // Draws an NSImage with a given size into a SkBitmap. | 
| 65 SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque); | 68 SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque); | 
| 66 | 69 | 
| 70 // Draws an NSImageRep with a given size into a SkBitmap. | |
| 71 SkBitmap NSImageRepToSkBitmap(NSImageRep* image, NSSize size, bool is_opaque); | |
| 
Robert Sesek
2011/04/15 20:27:20
This needs a unit test
 
sail
2011/04/16 01:25:00
Done.
 | |
| 72 | |
| 67 // Given an SkBitmap and a color space, return an autoreleased NSImage. | 73 // Given an SkBitmap and a color space, return an autoreleased NSImage. | 
| 68 NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& icon, | 74 NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& icon, | 
| 69 CGColorSpaceRef colorSpace); | 75 CGColorSpaceRef colorSpace); | 
| 70 | 76 | 
| 71 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. | 77 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. | 
| 72 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. | 78 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. | 
| 73 // TODO(thakis): Remove this -- http://crbug.com/69432 | 79 // TODO(thakis): Remove this -- http://crbug.com/69432 | 
| 74 NSImage* SkBitmapToNSImage(const SkBitmap& icon); | 80 NSImage* SkBitmapToNSImage(const SkBitmap& icon); | 
| 75 | 81 | 
| 82 // Given a vector of SkBitmaps, return an NSImage with each bitmap added | |
| 83 // as a representation. | |
| 84 NSImage* SkBitmapsToNSImage(const std::vector<const SkBitmap*>& bitmaps); | |
| 
Robert Sesek
2011/04/15 20:27:20
This needs a unit test
 
sail
2011/04/16 01:25:00
Done.
Ouch, thanks for asking me to do a unit test
 | |
| 85 | |
| 76 // Returns |[NSImage imageNamed:@"NSApplicationIcon"]| as SkBitmap. | 86 // Returns |[NSImage imageNamed:@"NSApplicationIcon"]| as SkBitmap. | 
| 77 SkBitmap AppplicationIconAtSize(int size); | 87 SkBitmap AppplicationIconAtSize(int size); | 
| 78 | 88 | 
| 79 } // namespace gfx | 89 } // namespace gfx | 
| 80 | 90 | 
| 81 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ | 91 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ | 
| OLD | NEW |