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

Unified Diff: tests/RecordCullingTest.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 8 months 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/record/SkRecords.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordCullingTest.cpp
diff --git a/tests/RecordCullingTest.cpp b/tests/RecordCullingTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6711c6f67d3c238056e841e29dbfcf06de3cd7a
--- /dev/null
+++ b/tests/RecordCullingTest.cpp
@@ -0,0 +1,41 @@
+#include "Test.h"
+
+#include "SkRecord.h"
+#include "SkRecordCulling.h"
+#include "SkRecorder.h"
+#include "SkRecords.h"
+
+struct PushCullScanner {
+ template <typename T> void operator()(const T&) {}
+
+ SkTDArray<unsigned> fPopOffsets;
+};
+
+template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) {
+ *fPopOffsets.append() = record.popOffset;
+}
+
+
+DEF_TEST(RecordCulling, r) {
+ SkRecord record;
+ SkRecorder recorder(&record, 1920, 1080);
+
+ recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
+
+ recorder.pushCull(SkRect::MakeWH(100, 100));
+ recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
+ recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
+ recorder.pushCull(SkRect::MakeWH(5, 5));
+ recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
+ recorder.popCull();
+ recorder.popCull();
+
+ SkRecordAnnotateCullingPairs(&record);
+
+ PushCullScanner scan;
+ record.visit(scan);
+
+ REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count());
+ REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]);
+ REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]);
+}
« no previous file with comments | « src/record/SkRecords.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698