OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkRecords_DEFINED | 8 #ifndef SkRecords_DEFINED |
9 #define SkRecords_DEFINED | 9 #define SkRecords_DEFINED |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 M(Restore) \ | 46 M(Restore) \ |
47 M(Save) \ | 47 M(Save) \ |
48 M(SaveLayer) \ | 48 M(SaveLayer) \ |
49 M(SetMatrix) \ | 49 M(SetMatrix) \ |
50 M(TranslateZ) \ | 50 M(TranslateZ) \ |
51 M(Concat) \ | 51 M(Concat) \ |
52 M(ClipPath) \ | 52 M(ClipPath) \ |
53 M(ClipRRect) \ | 53 M(ClipRRect) \ |
54 M(ClipRect) \ | 54 M(ClipRect) \ |
55 M(ClipRegion) \ | 55 M(ClipRegion) \ |
56 M(DrawBitmap) \ | |
57 M(DrawBitmapNine) \ | |
58 M(DrawBitmapRect) \ | |
59 M(DrawBitmapRectFast) \ | |
60 M(DrawBitmapRectFixedSize) \ | |
61 M(DrawDrawable) \ | 56 M(DrawDrawable) \ |
62 M(DrawImage) \ | 57 M(DrawImage) \ |
63 M(DrawImageRect) \ | 58 M(DrawImageRect) \ |
64 M(DrawImageNine) \ | 59 M(DrawImageNine) \ |
65 M(DrawDRRect) \ | 60 M(DrawDRRect) \ |
66 M(DrawOval) \ | 61 M(DrawOval) \ |
67 M(DrawPaint) \ | 62 M(DrawPaint) \ |
68 M(DrawPath) \ | 63 M(DrawPath) \ |
69 M(DrawPatch) \ | 64 M(DrawPatch) \ |
70 M(DrawPicture) \ | 65 M(DrawPicture) \ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 PODArray(T* ptr) : fPtr(ptr) {} | 143 PODArray(T* ptr) : fPtr(ptr) {} |
149 // Default copy and assign. | 144 // Default copy and assign. |
150 | 145 |
151 ACT_AS_PTR(fPtr); | 146 ACT_AS_PTR(fPtr); |
152 private: | 147 private: |
153 T* fPtr; | 148 T* fPtr; |
154 }; | 149 }; |
155 | 150 |
156 #undef ACT_AS_PTR | 151 #undef ACT_AS_PTR |
157 | 152 |
158 // Like SkBitmap, but deep copies pixels if they're not immutable. | |
159 // Using this, we guarantee the immutability of all bitmaps we record. | |
160 class ImmutableBitmap : SkNoncopyable { | |
161 public: | |
162 ImmutableBitmap() {} | |
163 ImmutableBitmap(const SkBitmap& bitmap); | |
164 ImmutableBitmap(ImmutableBitmap&& o) { | |
165 fBitmap.swap(o.fBitmap); | |
166 } | |
167 | |
168 int width() const { return fBitmap.width(); } | |
169 int height() const { return fBitmap.height(); } | |
170 | |
171 // While the pixels are immutable, SkBitmap itself is not thread-safe, so re
turn a copy. | |
172 SkBitmap shallowCopy() const { return fBitmap; } | |
173 private: | |
174 SkBitmap fBitmap; | |
175 }; | |
176 | |
177 // SkPath::getBounds() isn't thread safe unless we precache the bounds in a sing
lethreaded context. | 153 // SkPath::getBounds() isn't thread safe unless we precache the bounds in a sing
lethreaded context. |
178 // SkPath::cheapComputeDirection() is similar. | 154 // SkPath::cheapComputeDirection() is similar. |
179 // Recording is a convenient time to cache these, or we can delay it to between
record and playback. | 155 // Recording is a convenient time to cache these, or we can delay it to between
record and playback. |
180 struct PreCachedPath : public SkPath { | 156 struct PreCachedPath : public SkPath { |
181 PreCachedPath() {} | 157 PreCachedPath() {} |
182 PreCachedPath(const SkPath& path); | 158 PreCachedPath(const SkPath& path); |
183 }; | 159 }; |
184 | 160 |
185 // Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we pre
cache it. | 161 // Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we pre
cache it. |
186 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). | 162 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 RECORD(ClipRect, 0, | 217 RECORD(ClipRect, 0, |
242 SkIRect devBounds; | 218 SkIRect devBounds; |
243 SkRect rect; | 219 SkRect rect; |
244 RegionOpAndAA opAA); | 220 RegionOpAndAA opAA); |
245 RECORD(ClipRegion, 0, | 221 RECORD(ClipRegion, 0, |
246 SkIRect devBounds; | 222 SkIRect devBounds; |
247 SkRegion region; | 223 SkRegion region; |
248 SkRegion::Op op); | 224 SkRegion::Op op); |
249 | 225 |
250 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. | 226 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. |
251 RECORD(DrawBitmap, kDraw_Tag|kHasImage_Tag, | |
252 Optional<SkPaint> paint; | |
253 ImmutableBitmap bitmap; | |
254 SkScalar left; | |
255 SkScalar top); | |
256 RECORD(DrawBitmapNine, kDraw_Tag|kHasImage_Tag, | |
257 Optional<SkPaint> paint; | |
258 ImmutableBitmap bitmap; | |
259 SkIRect center; | |
260 SkRect dst); | |
261 RECORD(DrawBitmapRect, kDraw_Tag|kHasImage_Tag, | |
262 Optional<SkPaint> paint; | |
263 ImmutableBitmap bitmap; | |
264 Optional<SkRect> src; | |
265 SkRect dst); | |
266 RECORD(DrawBitmapRectFast, kDraw_Tag|kHasImage_Tag, | |
267 Optional<SkPaint> paint; | |
268 ImmutableBitmap bitmap; | |
269 Optional<SkRect> src; | |
270 SkRect dst); | |
271 RECORD(DrawBitmapRectFixedSize, kDraw_Tag|kHasImage_Tag, | |
272 SkPaint paint; | |
273 ImmutableBitmap bitmap; | |
274 SkRect src; | |
275 SkRect dst; | |
276 SkCanvas::SrcRectConstraint constraint); | |
277 RECORD(DrawDRRect, kDraw_Tag, | 227 RECORD(DrawDRRect, kDraw_Tag, |
278 SkPaint paint; | 228 SkPaint paint; |
279 SkRRect outer; | 229 SkRRect outer; |
280 SkRRect inner); | 230 SkRRect inner); |
281 RECORD(DrawDrawable, kDraw_Tag, | 231 RECORD(DrawDrawable, kDraw_Tag, |
282 Optional<SkMatrix> matrix; | 232 Optional<SkMatrix> matrix; |
283 SkRect worstCaseBounds; | 233 SkRect worstCaseBounds; |
284 int32_t index); | 234 int32_t index); |
285 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag, | 235 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag, |
286 Optional<SkPaint> paint; | 236 Optional<SkPaint> paint; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 int indexCount); | 336 int indexCount); |
387 RECORD(DrawAnnotation, 0, | 337 RECORD(DrawAnnotation, 0, |
388 SkRect rect; | 338 SkRect rect; |
389 SkString key; | 339 SkString key; |
390 RefBox<SkData> value); | 340 RefBox<SkData> value); |
391 #undef RECORD | 341 #undef RECORD |
392 | 342 |
393 } // namespace SkRecords | 343 } // namespace SkRecords |
394 | 344 |
395 #endif//SkRecords_DEFINED | 345 #endif//SkRecords_DEFINED |
OLD | NEW |