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 #include "SkRecordDraw.h" | 8 #include "SkRecordDraw.h" |
9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 SkRecords::Draw draw(canvas); | 29 SkRecords::Draw draw(canvas); |
30 for (int i = 0; i < ops.count(); i++) { | 30 for (int i = 0; i < ops.count(); i++) { |
31 if (NULL != callback && callback->abortDrawing()) { | 31 if (NULL != callback && callback->abortDrawing()) { |
32 return; | 32 return; |
33 } | 33 } |
34 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. | 34 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo
w. |
35 } | 35 } |
36 } else { | 36 } else { |
37 // Draw all ops. | 37 // Draw all ops. |
38 for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.n
ext()) { | 38 SkRecords::Draw draw(canvas); |
| 39 for (unsigned i = 0; i < record.count(); i++) { |
39 if (NULL != callback && callback->abortDrawing()) { | 40 if (NULL != callback && callback->abortDrawing()) { |
40 return; | 41 return; |
41 } | 42 } |
42 record.visit<void>(draw.index(), draw); | 43 record.visit<void>(i, draw); |
43 } | 44 } |
44 } | 45 } |
45 } | 46 } |
46 | 47 |
| 48 void SkRecordPartialDraw(const SkRecord& record, |
| 49 SkCanvas* canvas, |
| 50 const SkRect& clearRect, |
| 51 unsigned start, unsigned stop) { |
| 52 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
| 53 |
| 54 stop = SkTMin(stop, record.count()); |
| 55 SkRecords::PartialDraw draw(canvas, clearRect); |
| 56 for (unsigned i = start; i < stop; i++) { |
| 57 record.visit<void>(i, draw); |
| 58 } |
| 59 } |
| 60 |
47 namespace SkRecords { | 61 namespace SkRecords { |
48 | 62 |
49 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip
le threads. | 63 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip
le threads. |
50 static SkBitmap shallow_copy(const SkBitmap& bitmap) { | 64 static SkBitmap shallow_copy(const SkBitmap& bitmap) { |
51 return bitmap; | 65 return bitmap; |
52 } | 66 } |
53 | 67 |
54 // NoOps draw nothing. | 68 // NoOps draw nothing. |
55 template <> void Draw::draw(const NoOp&) {} | 69 template <> void Draw::draw(const NoOp&) {} |
56 | 70 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. | 470 // Used to track the bounds of Save/Restore blocks and the control ops insid
e them. |
457 SkTDArray<SaveBounds> fSaveStack; | 471 SkTDArray<SaveBounds> fSaveStack; |
458 SkTDArray<unsigned> fControlIndices; | 472 SkTDArray<unsigned> fControlIndices; |
459 }; | 473 }; |
460 | 474 |
461 } // namespace SkRecords | 475 } // namespace SkRecords |
462 | 476 |
463 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { | 477 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { |
464 SkRecords::FillBounds(record, bbh); | 478 SkRecords::FillBounds(record, bbh); |
465 } | 479 } |
OLD | NEW |