| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 90                                                 CGColorSpaceRef colorSpace); | 90                                                 CGColorSpaceRef colorSpace); | 
| 91 | 91 | 
| 92 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. | 92 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. | 
| 93 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. | 93 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. | 
| 94 // TODO(thakis): Remove this -- http://crbug.com/69432 | 94 // TODO(thakis): Remove this -- http://crbug.com/69432 | 
| 95 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon); | 95 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon); | 
| 96 | 96 | 
| 97 // Converts a SkCanvas temporarily to a CGContext | 97 // Converts a SkCanvas temporarily to a CGContext | 
| 98 class SK_API SkiaBitLocker { | 98 class SK_API SkiaBitLocker { | 
| 99  public: | 99  public: | 
| 100   // TODO(ccameron): delete this constructor | 100   /** | 
| 101   explicit SkiaBitLocker(SkCanvas* canvas); | 101     User clip rect is an *additional* clip to be applied in addition to the | 
|  | 102     current state of the canvas, in *local* rather than device coordinates. | 
|  | 103     If no additional clipping is desired, pass in | 
|  | 104     SkIRect::MakeSize(canvas->getBaseLayerSize()) transformed by the inverse | 
|  | 105     CTM. | 
|  | 106    */ | 
| 102   SkiaBitLocker(SkCanvas* canvas, | 107   SkiaBitLocker(SkCanvas* canvas, | 
| 103                 const SkIRect& userClipRect, | 108                 const SkIRect& userClipRect, | 
| 104                 SkScalar bitmapScaleFactor = 1); | 109                 SkScalar bitmapScaleFactor = 1); | 
| 105   ~SkiaBitLocker(); | 110   ~SkiaBitLocker(); | 
| 106   CGContextRef cgContext(); | 111   CGContextRef cgContext(); | 
| 107   bool hasEmptyClipRegion() const; | 112   bool hasEmptyClipRegion() const; | 
| 108 | 113 | 
| 109  private: | 114  private: | 
| 110   void releaseIfNeeded(); | 115   void releaseIfNeeded(); | 
| 111   SkIRect computeDirtyRect(); | 116   SkIRect computeDirtyRect(); | 
| 112 | 117 | 
| 113   SkCanvas* canvas_; | 118   SkCanvas* canvas_; | 
| 114 | 119 | 
| 115   // If the user specified a clip rect it would draw into then the locker may |  | 
| 116   // skip the step of searching for a rect bounding the pixels that the user |  | 
| 117   // has drawn into. |  | 
| 118   bool userClipRectSpecified_; |  | 
| 119 |  | 
| 120   CGContextRef cgContext_; | 120   CGContextRef cgContext_; | 
| 121   // offscreen_ is only valid if useDeviceBits_ is false | 121   // offscreen_ is only valid if useDeviceBits_ is false | 
| 122   SkBitmap offscreen_; | 122   SkBitmap offscreen_; | 
| 123   SkIPoint bitmapOffset_; | 123   SkIPoint bitmapOffset_; | 
| 124   SkScalar bitmapScaleFactor_; | 124   SkScalar bitmapScaleFactor_; | 
| 125 | 125 | 
| 126   // True if we are drawing to |canvas_|'s backing store directly. | 126   // True if we are drawing to |canvas_|'s backing store directly. | 
| 127   // Otherwise, the bits in |bitmap_| are our allocation and need to | 127   // Otherwise, the bits in |bitmap_| are our allocation and need to | 
| 128   // be copied over to |canvas_|. | 128   // be copied over to |canvas_|. | 
| 129   bool useDeviceBits_; | 129   bool useDeviceBits_; | 
| 130 | 130 | 
| 131   // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating | 131   // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating | 
| 132   // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not | 132   // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not | 
| 133   // be copied to |canvas_|. This will happen if |canvas_|'s clip region is | 133   // be copied to |canvas_|. This will happen if |canvas_|'s clip region is | 
| 134   // empty. | 134   // empty. | 
| 135   bool bitmapIsDummy_; | 135   bool bitmapIsDummy_; | 
| 136 }; | 136 }; | 
| 137 | 137 | 
| 138 | 138 | 
| 139 }  // namespace skia | 139 }  // namespace skia | 
| 140 | 140 | 
| 141 #endif  // SKIA_EXT_SKIA_UTILS_MAC_H_ | 141 #endif  // SKIA_EXT_SKIA_UTILS_MAC_H_ | 
| OLD | NEW | 
|---|