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

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

Issue 462423006: Allow user-specified clip region for SkiaBitLocker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 4 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
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 explicit SkiaBitLocker(SkCanvas* canvas); 111 explicit SkiaBitLocker(SkCanvas* canvas);
112 SkiaBitLocker(SkCanvas* canvas, const SkIRect& userClipRect);
112 ~SkiaBitLocker(); 113 ~SkiaBitLocker();
113 CGContextRef cgContext(); 114 CGContextRef cgContext();
115 bool hasEmptyClipRegion() const;
114 116
115 private: 117 private:
116 void releaseIfNeeded(); 118 void releaseIfNeeded();
119 SkIRect computeDirtyRect();
120
117 SkCanvas* canvas_; 121 SkCanvas* canvas_;
122
123 // 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
125 // has drawn into.
126 bool userClipRectSpecified_;
127
118 CGContextRef cgContext_; 128 CGContextRef cgContext_;
119 SkBitmap bitmap_; 129 SkBitmap bitmap_;
120 SkIPoint bitmapOffset_; 130 SkIPoint bitmapOffset_;
131
132 // 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
134 // be copied over to |canvas_|.
121 bool useDeviceBits_; 135 bool useDeviceBits_;
136
137 // 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
139 // be copied to |canvas_|. This will happen if |canvas_|'s clip region is
140 // empty.
141 bool bitmapIsDummy_;
122 }; 142 };
123 143
124 144
125 } // namespace gfx 145 } // namespace gfx
126 146
127 #endif // SKIA_EXT_SKIA_UTILS_MAC_H_ 147 #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