2014-04-08 20:17:26 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#include "SkRecord.h"
|
|
|
|
#include "SkRecorder.h"
|
|
|
|
#include "SkRecords.h"
|
|
|
|
|
|
|
|
#define COUNT(T) + 1
|
|
|
|
static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
|
|
|
|
#undef COUNT
|
|
|
|
|
2014-04-08 23:31:35 +00:00
|
|
|
// Tallies the types of commands it sees into a histogram.
|
2014-04-08 20:17:26 +00:00
|
|
|
class Tally {
|
|
|
|
public:
|
2014-04-08 23:31:35 +00:00
|
|
|
Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); }
|
2014-04-08 20:17:26 +00:00
|
|
|
|
2014-04-08 23:31:35 +00:00
|
|
|
template <typename T>
|
|
|
|
void operator()(const T&) { ++fHistogram[T::kType]; }
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
int count() const { return fHistogram[T::kType]; }
|
2014-04-08 20:17:26 +00:00
|
|
|
|
|
|
|
private:
|
2014-04-08 23:31:35 +00:00
|
|
|
int fHistogram[kRecordTypes];
|
2014-04-08 20:17:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DEF_TEST(Recorder, r) {
|
|
|
|
SkRecord record;
|
|
|
|
SkRecorder recorder(&record, 1920, 1080);
|
|
|
|
|
|
|
|
recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
|
|
|
|
|
2014-04-08 23:31:35 +00:00
|
|
|
Tally tally;
|
|
|
|
record.visit(tally);
|
2014-04-08 20:17:26 +00:00
|
|
|
|
2014-04-08 23:31:35 +00:00
|
|
|
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>());
|
2014-04-08 20:17:26 +00:00
|
|
|
}
|