Index: src/core/SkRecord.cpp |
diff --git a/src/core/SkRecord.cpp b/src/core/SkRecord.cpp |
index 2d2fa58991329ffad4a00f8822ff0085477164cd..2e03e993b82aaf84ea08634d0fee5dca11e51464 100644 |
--- a/src/core/SkRecord.cpp |
+++ b/src/core/SkRecord.cpp |
@@ -6,6 +6,7 @@ |
*/ |
#include "SkRecord.h" |
+#include <algorithm> |
SkRecord::~SkRecord() { |
Destroyer destroyer; |
@@ -30,3 +31,12 @@ size_t SkRecord::bytesUsed() const { |
} |
return bytes; |
} |
+ |
+void SkRecord::defrag() { |
+ // Remove all the NoOps, preserving the order of other ops, e.g. |
+ // Save, ClipRect, NoOp, DrawRect, NoOp, NoOp, Restore |
+ // -> Save, ClipRect, DrawRect, Restore |
+ Record* noops = std::remove_if(fRecords.get(), fRecords.get() + fCount, |
+ [](Record op) { return op.type() == SkRecords::NoOp_Type; }); |
+ fCount = noops - fRecords.get(); |
+} |