Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: src/core/SkRecord.cpp

Issue 1461663003: Add SkRecord::defrag(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkRecordOpts.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+}
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkRecordOpts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698