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