| 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 #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 | 7 |
| 8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 CGColorSpaceRef colorSpace); | 101 CGColorSpaceRef colorSpace); |
| 102 | 102 |
| 103 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. | 103 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. |
| 104 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. | 104 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. |
| 105 // TODO(thakis): Remove this -- http://crbug.com/69432 | 105 // TODO(thakis): Remove this -- http://crbug.com/69432 |
| 106 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon); | 106 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon); |
| 107 | 107 |
| 108 // Converts a SkCanvas temporarily to a CGContext | 108 // Converts a SkCanvas temporarily to a CGContext |
| 109 class SK_API SkiaBitLocker { | 109 class SK_API SkiaBitLocker { |
| 110 public: | 110 public: |
| 111 // TODO(ccameron): delete this constructor |
| 111 explicit SkiaBitLocker(SkCanvas* canvas); | 112 explicit SkiaBitLocker(SkCanvas* canvas); |
| 112 SkiaBitLocker(SkCanvas* canvas, const SkIRect& userClipRect); | 113 SkiaBitLocker(SkCanvas* canvas, |
| 114 const SkIRect& userClipRect, |
| 115 SkScalar bitmapScaleFactor = 1); |
| 113 ~SkiaBitLocker(); | 116 ~SkiaBitLocker(); |
| 114 CGContextRef cgContext(); | 117 CGContextRef cgContext(); |
| 115 bool hasEmptyClipRegion() const; | 118 bool hasEmptyClipRegion() const; |
| 116 | 119 |
| 117 private: | 120 private: |
| 118 void releaseIfNeeded(); | 121 void releaseIfNeeded(); |
| 119 SkIRect computeDirtyRect(); | 122 SkIRect computeDirtyRect(); |
| 120 | 123 |
| 121 SkCanvas* canvas_; | 124 SkCanvas* canvas_; |
| 122 | 125 |
| 123 // If the user specified a clip rect it would draw into then the locker may | 126 // If the user specified a clip rect it would draw into then the locker may |
| 124 // skip the step of searching for a rect bounding the pixels that the user | 127 // skip the step of searching for a rect bounding the pixels that the user |
| 125 // has drawn into. | 128 // has drawn into. |
| 126 bool userClipRectSpecified_; | 129 bool userClipRectSpecified_; |
| 127 | 130 |
| 128 CGContextRef cgContext_; | 131 CGContextRef cgContext_; |
| 129 SkBitmap bitmap_; | 132 SkBitmap bitmap_; |
| 130 SkIPoint bitmapOffset_; | 133 SkIPoint bitmapOffset_; |
| 134 SkScalar bitmapScaleFactor_; |
| 131 | 135 |
| 132 // True if we are drawing to |canvas_|'s SkBaseDevice's bits directly through | 136 // True if we are drawing to |canvas_|'s SkBaseDevice's bits directly through |
| 133 // |bitmap_|. Otherwise, the bits in |bitmap_| are our allocation and need to | 137 // |bitmap_|. Otherwise, the bits in |bitmap_| are our allocation and need to |
| 134 // be copied over to |canvas_|. | 138 // be copied over to |canvas_|. |
| 135 bool useDeviceBits_; | 139 bool useDeviceBits_; |
| 136 | 140 |
| 137 // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating | 141 // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating |
| 138 // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not | 142 // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not |
| 139 // be copied to |canvas_|. This will happen if |canvas_|'s clip region is | 143 // be copied to |canvas_|. This will happen if |canvas_|'s clip region is |
| 140 // empty. | 144 // empty. |
| 141 bool bitmapIsDummy_; | 145 bool bitmapIsDummy_; |
| 142 }; | 146 }; |
| 143 | 147 |
| 144 | 148 |
| 145 } // namespace gfx | 149 } // namespace gfx |
| 146 | 150 |
| 147 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ | 151 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ |
| OLD | NEW |