1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2012 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci#include "include/core/SkString.h" 8cb93a386Sopenharmony_ci#include "tests/PathOpsExtendedTest.h" 9cb93a386Sopenharmony_ci#include "tests/PathOpsThreadedCommon.h" 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_cistatic int loopNo = 1; 12cb93a386Sopenharmony_ci 13cb93a386Sopenharmony_cistatic void testSimplifyQuadralateralsMain(PathOpsThreadState* data) 14cb93a386Sopenharmony_ci{ 15cb93a386Sopenharmony_ci SkASSERT(data); 16cb93a386Sopenharmony_ci PathOpsThreadState& state = *data; 17cb93a386Sopenharmony_ci SkString pathStr; 18cb93a386Sopenharmony_ci int ax = state.fA & 0x03; 19cb93a386Sopenharmony_ci int ay = state.fA >> 2; 20cb93a386Sopenharmony_ci int bx = state.fB & 0x03; 21cb93a386Sopenharmony_ci int by = state.fB >> 2; 22cb93a386Sopenharmony_ci int cx = state.fC & 0x03; 23cb93a386Sopenharmony_ci int cy = state.fC >> 2; 24cb93a386Sopenharmony_ci int dx = state.fD & 0x03; 25cb93a386Sopenharmony_ci int dy = state.fD >> 2; 26cb93a386Sopenharmony_ci for (int e = 0 ; e < 16; ++e) { 27cb93a386Sopenharmony_ci int ex = e & 0x03; 28cb93a386Sopenharmony_ci int ey = e >> 2; 29cb93a386Sopenharmony_ci for (int f = e ; f < 16; ++f) { 30cb93a386Sopenharmony_ci int fx = f & 0x03; 31cb93a386Sopenharmony_ci int fy = f >> 2; 32cb93a386Sopenharmony_ci for (int g = f ; g < 16; ++g) { 33cb93a386Sopenharmony_ci int gx = g & 0x03; 34cb93a386Sopenharmony_ci int gy = g >> 2; 35cb93a386Sopenharmony_ci for (int h = g ; h < 16; ++h) { 36cb93a386Sopenharmony_ci int hx = h & 0x03; 37cb93a386Sopenharmony_ci int hy = h >> 2; 38cb93a386Sopenharmony_ci SkPath path, out; 39cb93a386Sopenharmony_ci path.moveTo(SkIntToScalar(ax), SkIntToScalar(ay)); 40cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(bx), SkIntToScalar(by)); 41cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(cx), SkIntToScalar(cy)); 42cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(dx), SkIntToScalar(dy)); 43cb93a386Sopenharmony_ci path.close(); 44cb93a386Sopenharmony_ci path.moveTo(SkIntToScalar(ex), SkIntToScalar(ey)); 45cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(fx), SkIntToScalar(fy)); 46cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(gx), SkIntToScalar(gy)); 47cb93a386Sopenharmony_ci path.lineTo(SkIntToScalar(hx), SkIntToScalar(hy)); 48cb93a386Sopenharmony_ci path.close(); 49cb93a386Sopenharmony_ci if (state.fReporter->verbose()) { 50cb93a386Sopenharmony_ci pathStr.printf("static void quadralateralSimplify%d(skiatest::Reporter*" 51cb93a386Sopenharmony_ci "reporter, const char* filename) {\n", loopNo); 52cb93a386Sopenharmony_ci pathStr.appendf(" SkPath path;\n"); 53cb93a386Sopenharmony_ci pathStr.appendf(" path.moveTo(%d, %d);\n", ax, ay); 54cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", bx, by); 55cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", cx, cy); 56cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", dx, dy); 57cb93a386Sopenharmony_ci pathStr.appendf(" path.close();\n"); 58cb93a386Sopenharmony_ci pathStr.appendf(" path.moveTo(%d, %d);\n", ex, ey); 59cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", fx, fy); 60cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", gx, gy); 61cb93a386Sopenharmony_ci pathStr.appendf(" path.lineTo(%d, %d);\n", hx, hy); 62cb93a386Sopenharmony_ci pathStr.appendf(" path.close();\n"); 63cb93a386Sopenharmony_ci pathStr.appendf(" testPathSimplify(reporter, path, filename);\n"); 64cb93a386Sopenharmony_ci pathStr.appendf("}\n"); 65cb93a386Sopenharmony_ci state.outputProgress(pathStr.c_str(), SkPathFillType::kWinding); 66cb93a386Sopenharmony_ci } 67cb93a386Sopenharmony_ci testSimplify(path, false, out, state, pathStr.c_str()); 68cb93a386Sopenharmony_ci path.setFillType(SkPathFillType::kEvenOdd); 69cb93a386Sopenharmony_ci if (state.fReporter->verbose()) { 70cb93a386Sopenharmony_ci state.outputProgress(pathStr.c_str(), SkPathFillType::kEvenOdd); 71cb93a386Sopenharmony_ci } 72cb93a386Sopenharmony_ci testSimplify(path, true, out, state, pathStr.c_str()); 73cb93a386Sopenharmony_ci } 74cb93a386Sopenharmony_ci } 75cb93a386Sopenharmony_ci } 76cb93a386Sopenharmony_ci } 77cb93a386Sopenharmony_ci} 78cb93a386Sopenharmony_ci 79cb93a386Sopenharmony_ciDEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) { 80cb93a386Sopenharmony_ci initializeTests(reporter, "testQuadralaterals"); 81cb93a386Sopenharmony_ci PathOpsThreadedTestRunner testRunner(reporter); 82cb93a386Sopenharmony_ci for (int a = 0; a < 16; ++a) { 83cb93a386Sopenharmony_ci for (int b = a ; b < 16; ++b) { 84cb93a386Sopenharmony_ci for (int c = b ; c < 16; ++c) { 85cb93a386Sopenharmony_ci for (int d = c; d < 16; ++d) { 86cb93a386Sopenharmony_ci *testRunner.fRunnables.append() = new PathOpsThreadedRunnable( 87cb93a386Sopenharmony_ci &testSimplifyQuadralateralsMain, a, b, c, d, &testRunner); 88cb93a386Sopenharmony_ci } 89cb93a386Sopenharmony_ci if (!reporter->allowExtendedTest()) goto finish; 90cb93a386Sopenharmony_ci } 91cb93a386Sopenharmony_ci } 92cb93a386Sopenharmony_ci } 93cb93a386Sopenharmony_cifinish: 94cb93a386Sopenharmony_ci testRunner.render(); 95cb93a386Sopenharmony_ci} 96