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

Unified Diff: tests/GrTRecorderTest.cpp

Issue 1035083004: Add ReverseIter to GrTRecorder (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_ongetblendmode
Patch Set: Rearrange headers Created 5 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/gpu/GrTRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GrTRecorderTest.cpp
diff --git a/tests/GrTRecorderTest.cpp b/tests/GrTRecorderTest.cpp
index fde70ac8e8dc56b4914cb1c1811d8b5c19669a17..cef870fa90a008a5660835f393a5aed94abc9a28 100644
--- a/tests/GrTRecorderTest.cpp
+++ b/tests/GrTRecorderTest.cpp
@@ -5,14 +5,15 @@
* found in the LICENSE file.
*/
-#if SK_SUPPORT_GPU
-
-#include "GrTRecorder.h"
#include "SkMatrix.h"
#include "SkRandom.h"
#include "SkString.h"
#include "Test.h"
+#if SK_SUPPORT_GPU
+
+#include "GrTRecorder.h"
+
////////////////////////////////////////////////////////////////////////////////
static int activeRecorderItems = 0;
@@ -101,6 +102,15 @@ static void test_extra_data(skiatest::Reporter* reporter) {
}
REPORTER_ASSERT(reporter, !iter.next());
+ ExtraData::Recorder::ReverseIter reverseIter(recorder);
+ for (int i = 99; i >= 0; --i) {
+ REPORTER_ASSERT(reporter, i == reverseIter->fData);
+ for (int j = 0; j < i; j++) {
+ REPORTER_ASSERT(reporter, i == reverseIter->extraData()[j]);
+ }
+ REPORTER_ASSERT(reporter, reverseIter.previous() == !!i);
+ }
+
recorder.reset();
REPORTER_ASSERT(reporter, 0 == activeRecorderItems);
}
@@ -197,19 +207,20 @@ public:
virtual ClassType getType() { return kSubclassEmpty_ClassType; }
};
+class Order {
+public:
+ Order() { this->reset(); }
+ void reset() { fCurrent = 0; }
+ ClassType next() {
+ fCurrent = 1664525 * fCurrent + 1013904223;
+ return static_cast<ClassType>(fCurrent % kNumClassTypes);
+ }
+private:
+ uint32_t fCurrent;
+};
+static void test_subclasses_iters(skiatest::Reporter*, Order&, Base::Recorder::Iter&,
+ Base::Recorder::ReverseIter&, int = 0);
static void test_subclasses(skiatest::Reporter* reporter) {
- class Order {
- public:
- Order() { this->reset(); }
- void reset() { fCurrent = 0; }
- ClassType next() {
- fCurrent = 1664525 * fCurrent + 1013904223;
- return static_cast<ClassType>(fCurrent % kNumClassTypes);
- }
- private:
- uint32_t fCurrent;
- };
-
Base::Recorder recorder(1024);
Order order;
@@ -244,15 +255,33 @@ static void test_subclasses(skiatest::Reporter* reporter) {
order.reset();
Base::Recorder::Iter iter(recorder);
- for (int i = 0; i < 1000; ++i) {
- REPORTER_ASSERT(reporter, iter.next());
- REPORTER_ASSERT(reporter, order.next() == iter->getType());
- iter->validate(reporter);
- }
+ Base::Recorder::ReverseIter reverseIter(recorder);
+
+ test_subclasses_iters(reporter, order, iter, reverseIter);
+
REPORTER_ASSERT(reporter, !iter.next());
// Don't reset the recorder. It should automatically destruct all its items.
}
+static void test_subclasses_iters(skiatest::Reporter* reporter, Order& order,
+ Base::Recorder::Iter& iter,
+ Base::Recorder::ReverseIter& reverseIter, int i) {
+ if (i >= 1000) {
+ return;
+ }
+
+ ClassType classType = order.next();
+
+ REPORTER_ASSERT(reporter, iter.next());
+ REPORTER_ASSERT(reporter, classType == iter->getType());
+ iter->validate(reporter);
+
+ test_subclasses_iters(reporter, order, iter, reverseIter, i + 1);
+
+ REPORTER_ASSERT(reporter, classType == reverseIter->getType());
+ reverseIter->validate(reporter);
+ REPORTER_ASSERT(reporter, reverseIter.previous() == !!i);
+}
DEF_GPUTEST(GrTRecorder, reporter, factory) {
test_empty_back_and_pop(reporter);
« no previous file with comments | « src/gpu/GrTRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698