diff options
author | Rhys Kidd <rhyskidd@gmail.com> | 2018-02-26 01:18:54 -0500 |
---|---|---|
committer | Robert Foss <robert.foss@collabora.com> | 2018-02-28 12:09:11 +0100 |
commit | f667f805e3febbc538399334e9e71501c5c28091 (patch) | |
tree | 9c8bf493e5bf9033a40be6e588c03efe127120dd /separate_rects.cpp | |
parent | c7a6d27627aa17944f1f78700cf2d95c8db5d803 (diff) |
drm_hwcomposer: Enable and refactor Separate Rects test
Plumb through the existing test based on known sample data for the
Separate Rect algorithm via Android's NATIVE_TEST harness.
Signed-off-by: Rhys Kidd <rhyskidd@gmail.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Diffstat (limited to 'separate_rects.cpp')
-rw-r--r-- | separate_rects.cpp | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/separate_rects.cpp b/separate_rects.cpp index 9fd1ae4..0e74cfc 100644 --- a/separate_rects.cpp +++ b/separate_rects.cpp @@ -315,102 +315,3 @@ void separate_rects_64(const std::vector<Rect<int>> &in, } } // namespace separate_rects - -#ifdef RECTS_TEST - -using namespace separate_rects; - -int main(int argc, char **argv) { -#define RectSet RectSet<TId, TNum> -#define Rect Rect<TNum> -#define IdSet IdSet<TId> - typedef uint64_t TId; - typedef float TNum; - - std::vector<Rect> in; - std::vector<RectSet> out; - std::vector<RectSet> expected_out; - - in.push_back({0, 0, 4, 5}); - in.push_back({2, 0, 6, 6}); - in.push_back({4, 0, 8, 5}); - in.push_back({0, 7, 8, 9}); - - in.push_back({10, 0, 18, 5}); - in.push_back({12, 0, 16, 5}); - - in.push_back({20, 11, 24, 17}); - in.push_back({22, 13, 26, 21}); - in.push_back({32, 33, 36, 37}); - in.push_back({30, 31, 38, 39}); - - in.push_back({40, 43, 48, 45}); - in.push_back({44, 41, 46, 47}); - - in.push_back({50, 51, 52, 53}); - in.push_back({50, 51, 52, 53}); - in.push_back({50, 51, 52, 53}); - - in.push_back({0, 0, 0, 10}); - in.push_back({0, 0, 10, 0}); - in.push_back({10, 0, 0, 10}); - in.push_back({0, 10, 10, 0}); - - for (int i = 0; i < 100000; i++) { - out.clear(); - separate_rects(in, &out); - } - - for (int i = 0; i < out.size(); i++) { - std::cout << out[i].id_set << "(" << out[i].rect << ")" << std::endl; - } - - std::cout << "# of rects: " << out.size() << std::endl; - - expected_out.push_back(RectSet(IdSet(0), Rect(0, 0, 2, 5))); - expected_out.push_back(RectSet(IdSet(1), Rect(2, 5, 6, 6))); - expected_out.push_back(RectSet(IdSet(1) | 0, Rect(2, 0, 4, 5))); - expected_out.push_back(RectSet(IdSet(1) | 2, Rect(4, 0, 6, 5))); - expected_out.push_back(RectSet(IdSet(2), Rect(6, 0, 8, 5))); - expected_out.push_back(RectSet(IdSet(3), Rect(0, 7, 8, 9))); - expected_out.push_back(RectSet(IdSet(4), Rect(10, 0, 12, 5))); - expected_out.push_back(RectSet(IdSet(5) | 4, Rect(12, 0, 16, 5))); - expected_out.push_back(RectSet(IdSet(4), Rect(16, 0, 18, 5))); - expected_out.push_back(RectSet(IdSet(6), Rect(20, 11, 22, 17))); - expected_out.push_back(RectSet(IdSet(6) | 7, Rect(22, 13, 24, 17))); - expected_out.push_back(RectSet(IdSet(6), Rect(22, 11, 24, 13))); - expected_out.push_back(RectSet(IdSet(7), Rect(22, 17, 24, 21))); - expected_out.push_back(RectSet(IdSet(7), Rect(24, 13, 26, 21))); - expected_out.push_back(RectSet(IdSet(9), Rect(30, 31, 32, 39))); - expected_out.push_back(RectSet(IdSet(8) | 9, Rect(32, 33, 36, 37))); - expected_out.push_back(RectSet(IdSet(9), Rect(32, 37, 36, 39))); - expected_out.push_back(RectSet(IdSet(9), Rect(32, 31, 36, 33))); - expected_out.push_back(RectSet(IdSet(9), Rect(36, 31, 38, 39))); - expected_out.push_back(RectSet(IdSet(10), Rect(40, 43, 44, 45))); - expected_out.push_back(RectSet(IdSet(10) | 11, Rect(44, 43, 46, 45))); - expected_out.push_back(RectSet(IdSet(11), Rect(44, 41, 46, 43))); - expected_out.push_back(RectSet(IdSet(11), Rect(44, 45, 46, 47))); - expected_out.push_back(RectSet(IdSet(10), Rect(46, 43, 48, 45))); - expected_out.push_back(RectSet(IdSet(12) | 13 | 14, Rect(50, 51, 52, 53))); - - for (int i = 0; i < expected_out.size(); i++) { - RectSet &ex_out = expected_out[i]; - if (std::find(out.begin(), out.end(), ex_out) == out.end()) { - std::cout << "Missing Rect: " << ex_out.id_set << "(" << ex_out.rect - << ")" << std::endl; - } - } - - for (int i = 0; i < out.size(); i++) { - RectSet &actual_out = out[i]; - if (std::find(expected_out.begin(), expected_out.end(), actual_out) == - expected_out.end()) { - std::cout << "Extra Rect: " << actual_out.id_set << "(" << actual_out.rect - << ")" << std::endl; - } - } - - return 0; -} - -#endif |