OLD | NEW |
(Empty) | |
| 1 #include "SkRecordCulling.h" |
| 2 |
| 3 #include "SkRecords.h" |
| 4 #include "SkTDArray.h" |
| 5 |
| 6 namespace { |
| 7 |
| 8 struct Annotator { |
| 9 unsigned index; |
| 10 SkTDArray<SkRecords::PushCull*> pushStack; |
| 11 |
| 12 // Do nothing to most record types. |
| 13 template <typename T> void operator()(T*) {} |
| 14 }; |
| 15 |
| 16 template <> void Annotator::operator()(SkRecords::PushCull* push) { |
| 17 // Store the push's index for now. We'll calculate the offset using this in
the paired pop. |
| 18 push->popOffset = index; |
| 19 pushStack.push(push); |
| 20 } |
| 21 |
| 22 template <> void Annotator::operator()(SkRecords::PopCull* pop) { |
| 23 SkRecords::PushCull* push = pushStack.top(); |
| 24 pushStack.pop(); |
| 25 |
| 26 SkASSERT(index > push->popOffset); // push->popOffset holds the ind
ex of the push. |
| 27 push->popOffset = index - push->popOffset; // Now it's the offset between p
ush and pop. |
| 28 } |
| 29 |
| 30 } // namespace |
| 31 |
| 32 void SkRecordAnnotateCullingPairs(SkRecord* record) { |
| 33 Annotator annotator; |
| 34 |
| 35 for (annotator.index = 0; annotator.index < record->count(); annotator.index
++) { |
| 36 record->mutate(annotator.index, annotator); |
| 37 } |
| 38 } |
OLD | NEW |