| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <vector> |
| 11 | 11 |
| 12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 | 13 |
| 14 struct SkIRect; | 14 struct SkIRect; |
| 15 struct SkPoint; | 15 struct SkPoint; |
| 16 struct SkRect; | 16 struct SkRect; |
| 17 class SkBitmap; | 17 class SkBitmap; |
| 18 class SkCanvas; | 18 class SkCanvas; |
| 19 class SkMatrix; | 19 class SkMatrix; |
| 20 #ifdef __LP64__ | 20 #ifdef __LP64__ |
| 21 typedef CGSize NSSize; | 21 typedef CGSize NSSize; |
| 22 #else | 22 #else |
| 23 typedef struct _NSSize NSSize; | 23 typedef struct _NSSize NSSize; |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #ifdef __OBJC__ | 26 #ifdef __OBJC__ |
| 27 @class NSImage; | 27 @class NSImage; |
| 28 @class NSImageRep; | 28 @class NSImageRep; |
| 29 @class NSColor; |
| 29 #else | 30 #else |
| 30 class NSImage; | 31 class NSImage; |
| 31 class NSImageRep; | 32 class NSImageRep; |
| 33 class NSColor; |
| 32 #endif | 34 #endif |
| 33 | 35 |
| 34 namespace gfx { | 36 namespace gfx { |
| 35 | 37 |
| 36 // Converts a Skia point to a CoreGraphics CGPoint. | 38 // Converts a Skia point to a CoreGraphics CGPoint. |
| 37 // Both use same in-memory format. | 39 // Both use same in-memory format. |
| 38 inline const CGPoint& SkPointToCGPoint(const SkPoint& point) { | 40 inline const CGPoint& SkPointToCGPoint(const SkPoint& point) { |
| 39 return reinterpret_cast<const CGPoint&>(point); | 41 return reinterpret_cast<const CGPoint&>(point); |
| 40 } | 42 } |
| 41 | 43 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 55 // Converts a Skia rect to a CoreGraphics CGRect. | 57 // Converts a Skia rect to a CoreGraphics CGRect. |
| 56 CGRect SkIRectToCGRect(const SkIRect& rect); | 58 CGRect SkIRectToCGRect(const SkIRect& rect); |
| 57 CGRect SkRectToCGRect(const SkRect& rect); | 59 CGRect SkRectToCGRect(const SkRect& rect); |
| 58 | 60 |
| 59 // Converts CGColorRef to the ARGB layout Skia expects. | 61 // Converts CGColorRef to the ARGB layout Skia expects. |
| 60 SkColor CGColorRefToSkColor(CGColorRef color); | 62 SkColor CGColorRefToSkColor(CGColorRef color); |
| 61 | 63 |
| 62 // Converts ARGB to CGColorRef. | 64 // Converts ARGB to CGColorRef. |
| 63 CGColorRef SkColorToCGColorRef(SkColor color); | 65 CGColorRef SkColorToCGColorRef(SkColor color); |
| 64 | 66 |
| 67 // Converts ARGB to NSColor. |
| 68 NSColor* SkColorToCalibratedNSColor(SkColor color); |
| 69 |
| 65 // Converts a CGImage to a SkBitmap. | 70 // Converts a CGImage to a SkBitmap. |
| 66 SkBitmap CGImageToSkBitmap(CGImageRef image); | 71 SkBitmap CGImageToSkBitmap(CGImageRef image); |
| 67 | 72 |
| 68 // Draws an NSImage with a given size into a SkBitmap. | 73 // Draws an NSImage with a given size into a SkBitmap. |
| 69 SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque); | 74 SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque); |
| 70 | 75 |
| 71 // Draws an NSImageRep with a given size into a SkBitmap. | 76 // Draws an NSImageRep with a given size into a SkBitmap. |
| 72 SkBitmap NSImageRepToSkBitmap(NSImageRep* image, NSSize size, bool is_opaque); | 77 SkBitmap NSImageRepToSkBitmap(NSImageRep* image, NSSize size, bool is_opaque); |
| 73 | 78 |
| 74 // Given an SkBitmap and a color space, return an autoreleased NSImage. | 79 // Given an SkBitmap and a color space, return an autoreleased NSImage. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 private: | 102 private: |
| 98 void releaseIfNeeded(); | 103 void releaseIfNeeded(); |
| 99 SkCanvas* canvas_; | 104 SkCanvas* canvas_; |
| 100 CGContextRef cgContext_; | 105 CGContextRef cgContext_; |
| 101 }; | 106 }; |
| 102 | 107 |
| 103 | 108 |
| 104 } // namespace gfx | 109 } // namespace gfx |
| 105 | 110 |
| 106 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ | 111 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ |
| OLD | NEW |