Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: skia/ext/skia_utils_mac.h

Issue 2705723002: Convert SkiaBitLocker to use PaintCanvas (Closed)
Patch Set: Remove rogue cc:: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 SkRect; 16 struct SkRect;
17 class SkCanvas;
18 class SkMatrix; 17 class SkMatrix;
19 #ifdef __LP64__ 18 #ifdef __LP64__
20 typedef CGSize NSSize; 19 typedef CGSize NSSize;
21 #else 20 #else
22 typedef struct _NSSize NSSize; 21 typedef struct _NSSize NSSize;
23 #endif 22 #endif
24 23
25 #ifdef __OBJC__ 24 #ifdef __OBJC__
26 @class NSBitmapImageRep; 25 @class NSBitmapImageRep;
27 @class NSImage; 26 @class NSImage;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 85
87 // Given an SkBitmap and a color space, return an autoreleased NSImage. 86 // Given an SkBitmap and a color space, return an autoreleased NSImage.
88 SK_API NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& icon, 87 SK_API NSImage* SkBitmapToNSImageWithColorSpace(const SkBitmap& icon,
89 CGColorSpaceRef colorSpace); 88 CGColorSpaceRef colorSpace);
90 89
91 // Given an SkBitmap, return an autoreleased NSImage in the generic color space. 90 // Given an SkBitmap, return an autoreleased NSImage in the generic color space.
92 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead. 91 // DEPRECATED, use SkBitmapToNSImageWithColorSpace() instead.
93 // TODO(thakis): Remove this -- http://crbug.com/69432 92 // TODO(thakis): Remove this -- http://crbug.com/69432
94 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon); 93 SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon);
95 94
96 // Converts a SkCanvas temporarily to a CGContext
97 class SK_API SkiaBitLocker {
98 public:
99 /**
100 User clip rect is an *additional* clip to be applied in addition to the
101 current state of the canvas, in *local* rather than device coordinates.
102 If no additional clipping is desired, pass in
103 SkIRect::MakeSize(canvas->getBaseLayerSize()) transformed by the inverse
104 CTM.
105 */
106 SkiaBitLocker(SkCanvas* canvas,
107 const SkIRect& userClipRect,
108 SkScalar bitmapScaleFactor = 1);
109 ~SkiaBitLocker();
110 CGContextRef cgContext();
111 bool hasEmptyClipRegion() const;
112
113 private:
114 void releaseIfNeeded();
115 SkIRect computeDirtyRect();
116
117 SkCanvas* canvas_;
118
119 CGContextRef cgContext_;
120 // offscreen_ is only valid if useDeviceBits_ is false
121 SkBitmap offscreen_;
122 SkIPoint bitmapOffset_;
123 SkScalar bitmapScaleFactor_;
124
125 // True if we are drawing to |canvas_|'s backing store directly.
126 // Otherwise, the bits in |bitmap_| are our allocation and need to
127 // be copied over to |canvas_|.
128 bool useDeviceBits_;
129
130 // True if |bitmap_| is a dummy 1x1 bitmap allocated for the sake of creating
131 // a non-NULL CGContext (it is invalid to use a NULL CGContext), and will not
132 // be copied to |canvas_|. This will happen if |canvas_|'s clip region is
133 // empty.
134 bool bitmapIsDummy_;
135 };
136
137
138 } // namespace skia 95 } // namespace skia
139 96
140 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ 97 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/skia_utils_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698