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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 int width() const { return fBitmap.width(); } | 193 int width() const { return fBitmap.width(); } |
194 int height() const { return fBitmap.height(); } | 194 int height() const { return fBitmap.height(); } |
195 | 195 |
196 // While the pixels are immutable, SkBitmap itself is not thread-safe, so re
turn a copy. | 196 // While the pixels are immutable, SkBitmap itself is not thread-safe, so re
turn a copy. |
197 SkBitmap shallowCopy() const { return fBitmap; } | 197 SkBitmap shallowCopy() const { return fBitmap; } |
198 private: | 198 private: |
199 SkBitmap fBitmap; | 199 SkBitmap fBitmap; |
200 }; | 200 }; |
201 | 201 |
202 // SkPath::getBounds() isn't thread safe unless we precache the bounds in a sing
lethreaded context. | 202 // SkPath::getBounds() isn't thread safe unless we precache the bounds in a sing
lethreaded context. |
203 // Recording is a convenient time to do this, but we could delay it to between r
ecord and playback. | 203 // SkPath::cheapComputeDirection() is similar. |
204 struct BoundedPath : public SkPath { | 204 // Recording is a convenient time to cache these, or we can delay it to between
record and playback. |
205 explicit BoundedPath(const SkPath& path) : SkPath(path) { | 205 struct PreCachedPath : public SkPath { |
| 206 explicit PreCachedPath(const SkPath& path) : SkPath(path) { |
206 this->updateBoundsCache(); | 207 this->updateBoundsCache(); |
| 208 SkPath::Direction junk; |
| 209 (void)this->cheapComputeDirection(&junk); |
207 } | 210 } |
208 }; | 211 }; |
209 | 212 |
210 // Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we pre
cache it. | 213 // Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we pre
cache it. |
211 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). | 214 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). |
212 struct TypedMatrix : public SkMatrix { | 215 struct TypedMatrix : public SkMatrix { |
213 explicit TypedMatrix(const SkMatrix& matrix) : SkMatrix(matrix) { | 216 explicit TypedMatrix(const SkMatrix& matrix) : SkMatrix(matrix) { |
214 (void)this->getType(); | 217 (void)this->getType(); |
215 } | 218 } |
216 }; | 219 }; |
217 | 220 |
218 RECORD0(NoOp); | 221 RECORD0(NoOp); |
219 | 222 |
220 RECORD2(Restore, SkIRect, devBounds, TypedMatrix, matrix); | 223 RECORD2(Restore, SkIRect, devBounds, TypedMatrix, matrix); |
221 RECORD0(Save); | 224 RECORD0(Save); |
222 RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas:
:SaveFlags, flags); | 225 RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas:
:SaveFlags, flags); |
223 | 226 |
224 RECORD1(SetMatrix, TypedMatrix, matrix); | 227 RECORD1(SetMatrix, TypedMatrix, matrix); |
225 | 228 |
226 struct RegionOpAndAA { | 229 struct RegionOpAndAA { |
227 RegionOpAndAA(SkRegion::Op op, bool aa) : op(op), aa(aa) {} | 230 RegionOpAndAA(SkRegion::Op op, bool aa) : op(op), aa(aa) {} |
228 SkRegion::Op op : 31; // This really only needs to be 3, but there's no win
today to do so. | 231 SkRegion::Op op : 31; // This really only needs to be 3, but there's no win
today to do so. |
229 unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call t
his an unsigned. | 232 unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call t
his an unsigned. |
230 }; | 233 }; |
231 SK_COMPILE_ASSERT(sizeof(RegionOpAndAA) == 4, RegionOpAndAASize); | 234 SK_COMPILE_ASSERT(sizeof(RegionOpAndAA) == 4, RegionOpAndAASize); |
232 | 235 |
233 RECORD3(ClipPath, SkIRect, devBounds, BoundedPath, path, RegionOpAndAA, opAA); | 236 RECORD3(ClipPath, SkIRect, devBounds, PreCachedPath, path, RegionOpAndAA, opA
A); |
234 RECORD3(ClipRRect, SkIRect, devBounds, SkRRect, rrect, RegionOpAndAA, opAA); | 237 RECORD3(ClipRRect, SkIRect, devBounds, SkRRect, rrect, RegionOpAndAA, opA
A); |
235 RECORD3(ClipRect, SkIRect, devBounds, SkRect, rect, RegionOpAndAA, opAA); | 238 RECORD3(ClipRect, SkIRect, devBounds, SkRect, rect, RegionOpAndAA, opA
A); |
236 RECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, op); | 239 RECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, o
p); |
237 | 240 |
238 RECORD1(BeginCommentGroup, PODArray<char>, description); | 241 RECORD1(BeginCommentGroup, PODArray<char>, description); |
239 RECORD2(AddComment, PODArray<char>, key, PODArray<char>, value); | 242 RECORD2(AddComment, PODArray<char>, key, PODArray<char>, value); |
240 RECORD0(EndCommentGroup); | 243 RECORD0(EndCommentGroup); |
241 | 244 |
242 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. | 245 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. |
243 RECORD4(DrawBitmap, Optional<SkPaint>, paint, | 246 RECORD4(DrawBitmap, Optional<SkPaint>, paint, |
244 ImmutableBitmap, bitmap, | 247 ImmutableBitmap, bitmap, |
245 SkScalar, left, | 248 SkScalar, left, |
246 SkScalar, top); | 249 SkScalar, top); |
(...skipping 14 matching lines...) Expand all Loading... |
261 RECORD4(DrawImage, Optional<SkPaint>, paint, | 264 RECORD4(DrawImage, Optional<SkPaint>, paint, |
262 RefBox<const SkImage>, image, | 265 RefBox<const SkImage>, image, |
263 SkScalar, left, | 266 SkScalar, left, |
264 SkScalar, top); | 267 SkScalar, top); |
265 RECORD4(DrawImageRect, Optional<SkPaint>, paint, | 268 RECORD4(DrawImageRect, Optional<SkPaint>, paint, |
266 RefBox<const SkImage>, image, | 269 RefBox<const SkImage>, image, |
267 Optional<SkRect>, src, | 270 Optional<SkRect>, src, |
268 SkRect, dst); | 271 SkRect, dst); |
269 RECORD2(DrawOval, SkPaint, paint, SkRect, oval); | 272 RECORD2(DrawOval, SkPaint, paint, SkRect, oval); |
270 RECORD1(DrawPaint, SkPaint, paint); | 273 RECORD1(DrawPaint, SkPaint, paint); |
271 RECORD2(DrawPath, SkPaint, paint, BoundedPath, path); | 274 RECORD2(DrawPath, SkPaint, paint, PreCachedPath, path); |
272 RECORD3(DrawPicture, Optional<SkPaint>, paint, | 275 RECORD3(DrawPicture, Optional<SkPaint>, paint, |
273 RefBox<const SkPicture>, picture, | 276 RefBox<const SkPicture>, picture, |
274 TypedMatrix, matrix); | 277 TypedMatrix, matrix); |
275 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, unsigned, count,
SkPoint*, pts); | 278 RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, unsigned, count,
SkPoint*, pts); |
276 RECORD4(DrawPosText, SkPaint, paint, | 279 RECORD4(DrawPosText, SkPaint, paint, |
277 PODArray<char>, text, | 280 PODArray<char>, text, |
278 size_t, byteLength, | 281 size_t, byteLength, |
279 PODArray<SkPoint>, pos); | 282 PODArray<SkPoint>, pos); |
280 RECORD5(DrawPosTextH, SkPaint, paint, | 283 RECORD5(DrawPosTextH, SkPaint, paint, |
281 PODArray<char>, text, | 284 PODArray<char>, text, |
282 unsigned, byteLength, | 285 unsigned, byteLength, |
283 SkScalar, y, | 286 SkScalar, y, |
284 PODArray<SkScalar>, xpos); | 287 PODArray<SkScalar>, xpos); |
285 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); | 288 RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); |
286 RECORD2(DrawRect, SkPaint, paint, SkRect, rect); | 289 RECORD2(DrawRect, SkPaint, paint, SkRect, rect); |
287 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left
, int, top); | 290 RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left
, int, top); |
288 RECORD5(DrawText, SkPaint, paint, | 291 RECORD5(DrawText, SkPaint, paint, |
289 PODArray<char>, text, | 292 PODArray<char>, text, |
290 size_t, byteLength, | 293 size_t, byteLength, |
291 SkScalar, x, | 294 SkScalar, x, |
292 SkScalar, y); | 295 SkScalar, y); |
293 RECORD4(DrawTextBlob, SkPaint, paint, | 296 RECORD4(DrawTextBlob, SkPaint, paint, |
294 RefBox<const SkTextBlob>, blob, | 297 RefBox<const SkTextBlob>, blob, |
295 SkScalar, x, | 298 SkScalar, x, |
296 SkScalar, y); | 299 SkScalar, y); |
297 RECORD5(DrawTextOnPath, SkPaint, paint, | 300 RECORD5(DrawTextOnPath, SkPaint, paint, |
298 PODArray<char>, text, | 301 PODArray<char>, text, |
299 size_t, byteLength, | 302 size_t, byteLength, |
300 BoundedPath, path, | 303 PreCachedPath, path, |
301 TypedMatrix, matrix); | 304 TypedMatrix, matrix); |
302 | 305 |
303 RECORD5(DrawPatch, SkPaint, paint, | 306 RECORD5(DrawPatch, SkPaint, paint, |
304 PODArray<SkPoint>, cubics, | 307 PODArray<SkPoint>, cubics, |
305 PODArray<SkColor>, colors, | 308 PODArray<SkColor>, colors, |
306 PODArray<SkPoint>, texCoords, | 309 PODArray<SkPoint>, texCoords, |
307 RefBox<SkXfermode>, xmode); | 310 RefBox<SkXfermode>, xmode); |
308 | 311 |
309 // This guy is so ugly we just write it manually. | 312 // This guy is so ugly we just write it manually. |
310 struct DrawVertices { | 313 struct DrawVertices { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 #undef RECORD0 | 346 #undef RECORD0 |
344 #undef RECORD1 | 347 #undef RECORD1 |
345 #undef RECORD2 | 348 #undef RECORD2 |
346 #undef RECORD3 | 349 #undef RECORD3 |
347 #undef RECORD4 | 350 #undef RECORD4 |
348 #undef RECORD5 | 351 #undef RECORD5 |
349 | 352 |
350 } // namespace SkRecords | 353 } // namespace SkRecords |
351 | 354 |
352 #endif//SkRecords_DEFINED | 355 #endif//SkRecords_DEFINED |
OLD | NEW |