| 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 |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "third_party/skia/include/core/SkPixmap.h" | 13 #include "third_party/skia/include/core/SkPixmap.h" |
| 14 | 14 |
| 15 struct SkIRect; | 15 struct SkIRect; |
| 16 struct SkPoint; | 16 struct SkPoint; |
| 17 struct SkRect; | 17 struct SkRect; |
| 18 class SkCanvas; | 18 class CdlCanvas; |
| 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 NSBitmapImageRep; | 27 @class NSBitmapImageRep; |
| 28 @class NSImage; | 28 @class NSImage; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 /** | 100 /** |
| 101 User clip rect is an *additional* clip to be applied in addition to the | 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. | 102 current state of the canvas, in *local* rather than device coordinates. |
| 103 If no additional clipping is desired, pass in | 103 If no additional clipping is desired, pass in |
| 104 SkIRect::MakeSize(canvas->getBaseLayerSize()) transformed by the inverse | 104 SkIRect::MakeSize(canvas->getBaseLayerSize()) transformed by the inverse |
| 105 CTM. | 105 CTM. |
| 106 */ | 106 */ |
| 107 SkiaBitLocker(SkCanvas* canvas, | 107 SkiaBitLocker(CdlCanvas* canvas, |
| 108 const SkIRect& userClipRect, | 108 const SkIRect& userClipRect, |
| 109 SkScalar bitmapScaleFactor = 1); | 109 SkScalar bitmapScaleFactor = 1); |
| 110 ~SkiaBitLocker(); | 110 ~SkiaBitLocker(); |
| 111 CGContextRef cgContext(); | 111 CGContextRef cgContext(); |
| 112 bool hasEmptyClipRegion() const; | 112 bool hasEmptyClipRegion() const; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 void releaseIfNeeded(); | 115 void releaseIfNeeded(); |
| 116 SkIRect computeDirtyRect(); | 116 SkIRect computeDirtyRect(); |
| 117 | 117 |
| 118 SkCanvas* canvas_; | 118 CdlCanvas* canvas_; |
| 119 | 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 |