2013-04-08 11:50:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PathOpsExtendedTest.h"
|
2013-04-10 15:55:37 +00:00
|
|
|
#include "PathOpsThreadedCommon.h"
|
2013-04-08 11:50:46 +00:00
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
|
|
|
#include "SkMatrix.h"
|
2015-07-07 19:21:21 +00:00
|
|
|
#include "SkMutex.h"
|
2014-04-26 03:04:35 +00:00
|
|
|
#include "SkPaint.h"
|
2013-04-08 11:50:46 +00:00
|
|
|
#include "SkStream.h"
|
|
|
|
|
2015-08-26 12:15:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-04-08 11:50:46 +00:00
|
|
|
#ifdef SK_BUILD_FOR_MAC
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result
|
|
|
|
SkDEBUGPARAMS(bool skipAssert)
|
|
|
|
SkDEBUGPARAMS(const char* testName));
|
|
|
|
|
|
|
|
bool SimplifyDebug(const SkPath& one, SkPath* result
|
|
|
|
SkDEBUGPARAMS(bool skipAssert)
|
|
|
|
SkDEBUGPARAMS(const char* testName));
|
|
|
|
|
2013-04-08 11:50:46 +00:00
|
|
|
static const char marker[] =
|
|
|
|
"</div>\n"
|
|
|
|
"\n"
|
|
|
|
"<script type=\"text/javascript\">\n"
|
|
|
|
"\n"
|
|
|
|
"var testDivs = [\n";
|
|
|
|
|
|
|
|
static const char* opStrs[] = {
|
2015-03-26 14:52:43 +00:00
|
|
|
"kDifference_SkPathOp",
|
|
|
|
"kIntersect_SkPathOp",
|
|
|
|
"kUnion_SkPathOp",
|
2016-07-18 17:01:36 +00:00
|
|
|
"kXOR_PathOp",
|
2015-03-26 14:52:43 +00:00
|
|
|
"kReverseDifference_SkPathOp",
|
2013-04-08 11:50:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const char* opSuffixes[] = {
|
|
|
|
"d",
|
|
|
|
"i",
|
|
|
|
"u",
|
2013-04-10 15:55:37 +00:00
|
|
|
"o",
|
2016-07-18 17:01:36 +00:00
|
|
|
"r",
|
2013-04-08 11:50:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-09 12:04:29 +00:00
|
|
|
enum class ExpectSuccess {
|
|
|
|
kNo,
|
|
|
|
kYes,
|
|
|
|
kFlaky
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class SkipAssert {
|
|
|
|
kNo,
|
|
|
|
kYes
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class ExpectMatch {
|
|
|
|
kNo,
|
|
|
|
kYes,
|
|
|
|
kFlaky
|
|
|
|
};
|
|
|
|
|
2013-06-04 17:59:42 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
static void showPathData(const SkPath& path) {
|
2013-07-08 17:17:02 +00:00
|
|
|
SkPath::RawIter iter(path);
|
2013-04-08 11:50:46 +00:00
|
|
|
uint8_t verb;
|
|
|
|
SkPoint pts[4];
|
2014-04-14 17:08:59 +00:00
|
|
|
SkPoint firstPt = {0, 0}, lastPt = {0, 0};
|
2013-07-15 13:29:13 +00:00
|
|
|
bool firstPtSet = false;
|
|
|
|
bool lastPtSet = true;
|
2013-04-08 11:50:46 +00:00
|
|
|
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
2014-06-17 12:15:38 +00:00
|
|
|
if (firstPtSet && lastPtSet && firstPt != lastPt) {
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, lastPt.fY,
|
|
|
|
firstPt.fX, firstPt.fY);
|
|
|
|
lastPtSet = false;
|
|
|
|
}
|
2013-07-15 13:29:13 +00:00
|
|
|
firstPt = pts[0];
|
|
|
|
firstPtSet = true;
|
2013-04-08 11:50:46 +00:00
|
|
|
continue;
|
|
|
|
case SkPath::kLine_Verb:
|
2013-04-10 15:55:37 +00:00
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", pts[0].fX, pts[0].fY,
|
|
|
|
pts[1].fX, pts[1].fY);
|
2013-07-15 13:29:13 +00:00
|
|
|
lastPt = pts[1];
|
|
|
|
lastPtSet = true;
|
2013-04-08 11:50:46 +00:00
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n",
|
2013-04-10 15:55:37 +00:00
|
|
|
pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
|
2013-07-15 13:29:13 +00:00
|
|
|
lastPt = pts[2];
|
|
|
|
lastPtSet = true;
|
2013-04-08 11:50:46 +00:00
|
|
|
break;
|
2015-03-26 14:52:43 +00:00
|
|
|
case SkPath::kConic_Verb:
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}, //weight=%1.9g\n",
|
|
|
|
pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY,
|
|
|
|
iter.conicWeight());
|
|
|
|
lastPt = pts[2];
|
|
|
|
lastPtSet = true;
|
|
|
|
break;
|
2013-04-08 11:50:46 +00:00
|
|
|
case SkPath::kCubic_Verb:
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n",
|
2013-04-10 15:55:37 +00:00
|
|
|
pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY,
|
|
|
|
pts[3].fX, pts[3].fY);
|
2013-07-15 13:29:13 +00:00
|
|
|
lastPt = pts[3];
|
|
|
|
lastPtSet = true;
|
2013-04-08 11:50:46 +00:00
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
2013-07-15 13:29:13 +00:00
|
|
|
if (firstPtSet && lastPtSet && firstPt != lastPt) {
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, lastPt.fY,
|
|
|
|
firstPt.fX, firstPt.fY);
|
|
|
|
}
|
|
|
|
firstPtSet = lastPtSet = false;
|
2013-04-08 11:50:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("bad verb");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-06-17 12:15:38 +00:00
|
|
|
if (firstPtSet && lastPtSet && firstPt != lastPt) {
|
|
|
|
SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, lastPt.fY,
|
|
|
|
firstPt.fX, firstPt.fY);
|
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
2013-06-04 17:59:42 +00:00
|
|
|
#endif
|
2013-04-08 11:50:46 +00:00
|
|
|
|
|
|
|
void showOp(const SkPathOp op) {
|
|
|
|
switch (op) {
|
2015-03-26 14:52:43 +00:00
|
|
|
case kDifference_SkPathOp:
|
2013-04-08 11:50:46 +00:00
|
|
|
SkDebugf("op difference\n");
|
|
|
|
break;
|
2015-03-26 14:52:43 +00:00
|
|
|
case kIntersect_SkPathOp:
|
2013-04-08 11:50:46 +00:00
|
|
|
SkDebugf("op intersect\n");
|
|
|
|
break;
|
2015-03-26 14:52:43 +00:00
|
|
|
case kUnion_SkPathOp:
|
2013-04-08 11:50:46 +00:00
|
|
|
SkDebugf("op union\n");
|
|
|
|
break;
|
2015-03-26 14:52:43 +00:00
|
|
|
case kXOR_SkPathOp:
|
2013-04-08 11:50:46 +00:00
|
|
|
SkDebugf("op xor\n");
|
|
|
|
break;
|
2015-03-26 14:52:43 +00:00
|
|
|
case kReverseDifference_SkPathOp:
|
2013-04-25 11:51:54 +00:00
|
|
|
SkDebugf("op reverse difference\n");
|
|
|
|
break;
|
2013-04-08 11:50:46 +00:00
|
|
|
default:
|
|
|
|
SkASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-18 15:58:21 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
static char hexorator(int x) {
|
|
|
|
if (x < 10) {
|
|
|
|
return x + '0';
|
|
|
|
}
|
|
|
|
x -= 10;
|
|
|
|
SkASSERT(x < 26);
|
|
|
|
return x + 'A';
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void ShowTestName(PathOpsThreadState* state, int a, int b, int c, int d) {
|
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
state->fSerialNo[0] = hexorator(state->fA);
|
|
|
|
state->fSerialNo[1] = hexorator(state->fB);
|
|
|
|
state->fSerialNo[2] = hexorator(state->fC);
|
|
|
|
state->fSerialNo[3] = hexorator(state->fD);
|
|
|
|
state->fSerialNo[4] = hexorator(a);
|
|
|
|
state->fSerialNo[5] = hexorator(b);
|
|
|
|
state->fSerialNo[6] = hexorator(c);
|
|
|
|
state->fSerialNo[7] = hexorator(d);
|
|
|
|
state->fSerialNo[8] = '\0';
|
|
|
|
SkDebugf("%s\n", state->fSerialNo);
|
|
|
|
if (strcmp(state->fSerialNo, state->fKey) == 0) {
|
|
|
|
SkDebugf("%s\n", state->fPathStr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-08 11:50:46 +00:00
|
|
|
const int bitWidth = 64;
|
|
|
|
const int bitHeight = 64;
|
|
|
|
|
|
|
|
static void scaleMatrix(const SkPath& one, const SkPath& two, SkMatrix& scale) {
|
|
|
|
SkRect larger = one.getBounds();
|
|
|
|
larger.join(two.getBounds());
|
|
|
|
SkScalar largerWidth = larger.width();
|
|
|
|
if (largerWidth < 4) {
|
|
|
|
largerWidth = 4;
|
|
|
|
}
|
|
|
|
SkScalar largerHeight = larger.height();
|
|
|
|
if (largerHeight < 4) {
|
|
|
|
largerHeight = 4;
|
|
|
|
}
|
|
|
|
SkScalar hScale = (bitWidth - 2) / largerWidth;
|
|
|
|
SkScalar vScale = (bitHeight - 2) / largerHeight;
|
|
|
|
scale.reset();
|
|
|
|
scale.preScale(hScale, vScale);
|
2015-10-16 16:03:38 +00:00
|
|
|
larger.fLeft *= hScale;
|
|
|
|
larger.fRight *= hScale;
|
|
|
|
larger.fTop *= vScale;
|
|
|
|
larger.fBottom *= vScale;
|
|
|
|
SkScalar dx = -16000 > larger.fLeft ? -16000 - larger.fLeft
|
|
|
|
: 16000 < larger.fRight ? 16000 - larger.fRight : 0;
|
|
|
|
SkScalar dy = -16000 > larger.fTop ? -16000 - larger.fTop
|
|
|
|
: 16000 < larger.fBottom ? 16000 - larger.fBottom : 0;
|
|
|
|
scale.postTranslate(dx, dy);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pathsDrawTheSame(SkBitmap& bits, const SkPath& scaledOne, const SkPath& scaledTwo,
|
|
|
|
int& error2x2) {
|
|
|
|
if (bits.width() == 0) {
|
2014-02-13 14:41:43 +00:00
|
|
|
bits.allocN32Pixels(bitWidth * 2, bitHeight);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
SkCanvas canvas(bits);
|
|
|
|
canvas.drawColor(SK_ColorWHITE);
|
|
|
|
SkPaint paint;
|
|
|
|
canvas.save();
|
|
|
|
const SkRect& bounds1 = scaledOne.getBounds();
|
|
|
|
canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1);
|
|
|
|
canvas.drawPath(scaledOne, paint);
|
|
|
|
canvas.restore();
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(-bounds1.fLeft + 1 + bitWidth, -bounds1.fTop + 1);
|
|
|
|
canvas.drawPath(scaledTwo, paint);
|
|
|
|
canvas.restore();
|
|
|
|
int errors2 = 0;
|
|
|
|
int errors = 0;
|
|
|
|
for (int y = 0; y < bitHeight - 1; ++y) {
|
|
|
|
uint32_t* addr1 = bits.getAddr32(0, y);
|
|
|
|
uint32_t* addr2 = bits.getAddr32(0, y + 1);
|
|
|
|
uint32_t* addr3 = bits.getAddr32(bitWidth, y);
|
|
|
|
uint32_t* addr4 = bits.getAddr32(bitWidth, y + 1);
|
|
|
|
for (int x = 0; x < bitWidth - 1; ++x) {
|
|
|
|
// count 2x2 blocks
|
|
|
|
bool err = addr1[x] != addr3[x];
|
|
|
|
if (err) {
|
|
|
|
errors2 += addr1[x + 1] != addr3[x + 1]
|
|
|
|
&& addr2[x] != addr4[x] && addr2[x + 1] != addr4[x + 1];
|
|
|
|
errors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error2x2 = errors2;
|
|
|
|
return errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pathsDrawTheSame(const SkPath& one, const SkPath& two, SkBitmap& bits, SkPath& scaledOne,
|
|
|
|
SkPath& scaledTwo, int& error2x2) {
|
|
|
|
SkMatrix scale;
|
|
|
|
scaleMatrix(one, two, scale);
|
|
|
|
one.transform(scale, &scaledOne);
|
|
|
|
two.transform(scale, &scaledTwo);
|
|
|
|
return pathsDrawTheSame(bits, scaledOne, scaledTwo, error2x2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths) {
|
|
|
|
if (!drawPaths) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
const SkRect& bounds1 = one.getBounds();
|
|
|
|
const SkRect& bounds2 = two.getBounds();
|
|
|
|
SkRect larger = bounds1;
|
|
|
|
larger.join(bounds2);
|
|
|
|
SkBitmap bits;
|
|
|
|
char out[256];
|
2013-12-17 19:22:07 +00:00
|
|
|
int bitWidth = SkScalarCeilToInt(larger.width()) + 2;
|
2013-04-08 11:50:46 +00:00
|
|
|
if (bitWidth * 2 + 1 >= (int) sizeof(out)) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-17 19:22:07 +00:00
|
|
|
int bitHeight = SkScalarCeilToInt(larger.height()) + 2;
|
2013-04-08 11:50:46 +00:00
|
|
|
if (bitHeight >= (int) sizeof(out)) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-13 14:41:43 +00:00
|
|
|
bits.allocN32Pixels(bitWidth * 2, bitHeight);
|
2013-04-08 11:50:46 +00:00
|
|
|
SkCanvas canvas(bits);
|
|
|
|
canvas.drawColor(SK_ColorWHITE);
|
|
|
|
SkPaint paint;
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1);
|
|
|
|
canvas.drawPath(one, paint);
|
|
|
|
canvas.restore();
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(-bounds1.fLeft + 1 + bitWidth, -bounds1.fTop + 1);
|
|
|
|
canvas.drawPath(two, paint);
|
|
|
|
canvas.restore();
|
|
|
|
for (int y = 0; y < bitHeight; ++y) {
|
|
|
|
uint32_t* addr1 = bits.getAddr32(0, y);
|
|
|
|
int x;
|
|
|
|
char* outPtr = out;
|
|
|
|
for (x = 0; x < bitWidth; ++x) {
|
|
|
|
*outPtr++ = addr1[x] == (uint32_t) -1 ? '_' : 'x';
|
|
|
|
}
|
|
|
|
*outPtr++ = '|';
|
|
|
|
for (x = bitWidth; x < bitWidth * 2; ++x) {
|
|
|
|
*outPtr++ = addr1[x] == (uint32_t) -1 ? '_' : 'x';
|
|
|
|
}
|
|
|
|
*outPtr++ = '\0';
|
|
|
|
SkDebugf("%s\n", out);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-26 14:52:43 +00:00
|
|
|
int comparePaths(skiatest::Reporter* reporter, const char* filename, const SkPath& one,
|
2014-04-14 17:08:59 +00:00
|
|
|
const SkPath& two, SkBitmap& bitmap) {
|
2013-04-08 11:50:46 +00:00
|
|
|
int errors2x2;
|
|
|
|
SkPath scaledOne, scaledTwo;
|
2014-04-14 17:08:59 +00:00
|
|
|
(void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2);
|
2013-04-08 11:50:46 +00:00
|
|
|
if (errors2x2 == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
const int MAX_ERRORS = 9;
|
|
|
|
return errors2x2 > MAX_ERRORS ? errors2x2 : 0;
|
|
|
|
}
|
|
|
|
|
2014-04-14 17:08:59 +00:00
|
|
|
static SkTDArray<SkPathOp> gTestOp;
|
|
|
|
|
|
|
|
static void showPathOpPath(const char* testName, const SkPath& one, const SkPath& two,
|
|
|
|
const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo,
|
|
|
|
const SkPathOp shapeOp, const SkMatrix& scale) {
|
2013-04-15 19:13:59 +00:00
|
|
|
SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs));
|
2014-04-14 17:08:59 +00:00
|
|
|
if (!testName) {
|
2015-04-20 15:31:59 +00:00
|
|
|
testName = "xOp";
|
2014-04-14 17:08:59 +00:00
|
|
|
}
|
2016-05-26 16:01:47 +00:00
|
|
|
SkDebugf("static void %s_%s(skiatest::Reporter* reporter, const char* filename) {\n",
|
|
|
|
testName, opSuffixes[shapeOp]);
|
2014-04-14 17:08:59 +00:00
|
|
|
*gTestOp.append() = shapeOp;
|
2013-06-04 17:59:42 +00:00
|
|
|
SkDebugf(" SkPath path, pathB;\n");
|
2014-07-18 12:08:14 +00:00
|
|
|
SkPathOpsDebug::ShowOnePath(a, "path", false);
|
|
|
|
SkPathOpsDebug::ShowOnePath(b, "pathB", false);
|
2014-04-14 17:08:59 +00:00
|
|
|
SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[shapeOp]);
|
2013-06-04 17:59:42 +00:00
|
|
|
SkDebugf("}\n");
|
2015-10-16 16:03:38 +00:00
|
|
|
drawAsciiPaths(scaledOne, scaledTwo, true);
|
2014-04-14 17:08:59 +00:00
|
|
|
}
|
|
|
|
|
2016-05-05 00:12:46 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(compareDebugOut3);
|
2015-05-13 17:13:17 +00:00
|
|
|
|
2014-04-14 17:08:59 +00:00
|
|
|
static int comparePaths(skiatest::Reporter* reporter, const char* testName, const SkPath& one,
|
|
|
|
const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkBitmap& bitmap,
|
2014-11-13 14:58:52 +00:00
|
|
|
const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix& scale,
|
2016-08-09 12:04:29 +00:00
|
|
|
ExpectMatch expectMatch) {
|
2013-04-08 11:50:46 +00:00
|
|
|
int errors2x2;
|
2014-11-13 14:58:52 +00:00
|
|
|
const int MAX_ERRORS = 8;
|
2014-04-14 17:08:59 +00:00
|
|
|
(void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2);
|
2016-08-09 12:04:29 +00:00
|
|
|
if (ExpectMatch::kNo == expectMatch) {
|
2015-05-13 17:13:17 +00:00
|
|
|
if (errors2x2 < MAX_ERRORS) {
|
2014-11-13 14:58:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
if (errors2x2 == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
2016-08-09 12:04:29 +00:00
|
|
|
if (ExpectMatch::kYes == expectMatch && errors2x2 >= MAX_ERRORS) {
|
2014-04-14 17:08:59 +00:00
|
|
|
SkAutoMutexAcquire autoM(compareDebugOut3);
|
|
|
|
showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
|
2015-04-29 15:28:30 +00:00
|
|
|
SkDebugf("\n/*");
|
2013-04-08 11:50:46 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0);
|
2015-04-29 15:28:30 +00:00
|
|
|
SkDebugf(" */\n");
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
2015-05-13 17:13:17 +00:00
|
|
|
return errors2x2 >= MAX_ERRORS ? errors2x2 : 0;
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 16:15:44 +00:00
|
|
|
// Default values for when reporter->verbose() is false.
|
2014-04-14 17:08:59 +00:00
|
|
|
static int testNumber = 55;
|
2013-10-02 16:15:44 +00:00
|
|
|
static const char* testName = "pathOpTest";
|
2013-04-10 15:55:37 +00:00
|
|
|
|
|
|
|
static void writeTestName(const char* nameSuffix, SkMemoryWStream& outFile) {
|
|
|
|
outFile.writeText(testName);
|
|
|
|
outFile.writeDecAsText(testNumber);
|
2014-04-14 17:08:59 +00:00
|
|
|
++testNumber;
|
2013-04-10 15:55:37 +00:00
|
|
|
if (nameSuffix) {
|
|
|
|
outFile.writeText(nameSuffix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void outputToStream(const char* pathStr, const char* pathPrefix, const char* nameSuffix,
|
|
|
|
const char* testFunction, bool twoPaths, SkMemoryWStream& outFile) {
|
2014-04-14 17:08:59 +00:00
|
|
|
#if 0
|
2015-03-26 14:52:43 +00:00
|
|
|
outFile.writeText("\n<div id=\"");
|
2013-04-10 15:55:37 +00:00
|
|
|
writeTestName(nameSuffix, outFile);
|
|
|
|
outFile.writeText("\">\n");
|
|
|
|
if (pathPrefix) {
|
|
|
|
outFile.writeText(pathPrefix);
|
|
|
|
}
|
|
|
|
outFile.writeText(pathStr);
|
|
|
|
outFile.writeText("</div>\n\n");
|
|
|
|
|
|
|
|
outFile.writeText(marker);
|
|
|
|
outFile.writeText(" ");
|
|
|
|
writeTestName(nameSuffix, outFile);
|
|
|
|
outFile.writeText(",\n\n\n");
|
2014-04-14 17:08:59 +00:00
|
|
|
#endif
|
2013-04-10 15:55:37 +00:00
|
|
|
outFile.writeText("static void ");
|
|
|
|
writeTestName(nameSuffix, outFile);
|
2014-04-14 17:08:59 +00:00
|
|
|
outFile.writeText("(skiatest::Reporter* reporter) {\n SkPath path");
|
2013-04-10 15:55:37 +00:00
|
|
|
if (twoPaths) {
|
|
|
|
outFile.writeText(", pathB");
|
|
|
|
}
|
|
|
|
outFile.writeText(";\n");
|
|
|
|
if (pathPrefix) {
|
|
|
|
outFile.writeText(pathPrefix);
|
|
|
|
}
|
|
|
|
outFile.writeText(pathStr);
|
|
|
|
outFile.writeText(" ");
|
|
|
|
outFile.writeText(testFunction);
|
|
|
|
outFile.writeText("\n}\n\n");
|
2014-04-14 17:08:59 +00:00
|
|
|
#if 0
|
2013-04-10 15:55:37 +00:00
|
|
|
outFile.writeText("static void (*firstTest)() = ");
|
|
|
|
writeTestName(nameSuffix, outFile);
|
|
|
|
outFile.writeText(";\n\n");
|
|
|
|
|
|
|
|
outFile.writeText("static struct {\n");
|
|
|
|
outFile.writeText(" void (*fun)();\n");
|
|
|
|
outFile.writeText(" const char* str;\n");
|
|
|
|
outFile.writeText("} tests[] = {\n");
|
|
|
|
outFile.writeText(" TEST(");
|
|
|
|
writeTestName(nameSuffix, outFile);
|
|
|
|
outFile.writeText("),\n");
|
2014-04-14 17:08:59 +00:00
|
|
|
#endif
|
2013-04-10 15:55:37 +00:00
|
|
|
outFile.flush();
|
|
|
|
}
|
|
|
|
|
2016-05-05 00:12:46 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(simplifyDebugOut);
|
2015-03-26 14:52:43 +00:00
|
|
|
|
2013-04-10 15:55:37 +00:00
|
|
|
bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& state,
|
|
|
|
const char* pathStr) {
|
2013-04-08 11:50:46 +00:00
|
|
|
SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType;
|
|
|
|
path.setFillType(fillType);
|
2015-03-26 14:52:43 +00:00
|
|
|
state.fReporter->bumpTestCount();
|
2013-04-26 19:51:16 +00:00
|
|
|
if (!Simplify(path, &out)) {
|
|
|
|
SkDebugf("%s did not expect failure\n", __FUNCTION__);
|
|
|
|
REPORTER_ASSERT(state.fReporter, 0);
|
|
|
|
return false;
|
|
|
|
}
|
2013-07-16 16:11:16 +00:00
|
|
|
if (!state.fReporter->verbose()) {
|
2013-04-08 11:50:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-08-27 14:41:13 +00:00
|
|
|
int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitmap);
|
2015-03-26 14:52:43 +00:00
|
|
|
if (result) {
|
2014-04-14 17:08:59 +00:00
|
|
|
SkAutoMutexAcquire autoM(simplifyDebugOut);
|
2013-04-08 11:50:46 +00:00
|
|
|
char temp[8192];
|
|
|
|
sk_bzero(temp, sizeof(temp));
|
|
|
|
SkMemoryWStream stream(temp, sizeof(temp));
|
2015-08-27 14:41:13 +00:00
|
|
|
const char* pathPrefix = nullptr;
|
|
|
|
const char* nameSuffix = nullptr;
|
2013-04-08 11:50:46 +00:00
|
|
|
if (fillType == SkPath::kEvenOdd_FillType) {
|
|
|
|
pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n";
|
|
|
|
nameSuffix = "x";
|
|
|
|
}
|
2014-04-14 17:08:59 +00:00
|
|
|
const char testFunction[] = "testSimplify(reporter, path);";
|
2013-04-10 15:55:37 +00:00
|
|
|
outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, stream);
|
2015-02-19 14:32:12 +00:00
|
|
|
SkDebugf("%s", temp);
|
2013-04-10 15:55:37 +00:00
|
|
|
REPORTER_ASSERT(state.fReporter, 0);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
2013-04-10 15:55:37 +00:00
|
|
|
state.fReporter->bumpTestCount();
|
2013-04-08 11:50:46 +00:00
|
|
|
return result == 0;
|
|
|
|
}
|
|
|
|
|
2015-03-26 14:52:43 +00:00
|
|
|
static bool inner_simplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename,
|
2016-07-18 17:01:36 +00:00
|
|
|
ExpectSuccess expectSuccess, SkipAssert skipAssert, ExpectMatch expectMatch) {
|
2015-03-26 14:52:43 +00:00
|
|
|
#if 0 && DEBUG_SHOW_TEST_NAME
|
2013-04-18 15:58:21 +00:00
|
|
|
showPathData(path);
|
|
|
|
#endif
|
2013-04-08 11:50:46 +00:00
|
|
|
SkPath out;
|
2016-07-18 17:01:36 +00:00
|
|
|
if (!SimplifyDebug(path, &out SkDEBUGPARAMS(SkipAssert::kYes == skipAssert)
|
|
|
|
SkDEBUGPARAMS(testName))) {
|
|
|
|
if (ExpectSuccess::kYes == expectSuccess) {
|
|
|
|
SkDebugf("%s did not expect %s failure\n", __FUNCTION__, filename);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
2013-04-26 19:51:16 +00:00
|
|
|
return false;
|
2016-07-18 17:01:36 +00:00
|
|
|
} else {
|
|
|
|
if (ExpectSuccess::kNo == expectSuccess) {
|
|
|
|
SkDebugf("%s %s unexpected success\n", __FUNCTION__, filename);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
2013-04-26 19:51:16 +00:00
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
SkBitmap bitmap;
|
2015-03-26 14:52:43 +00:00
|
|
|
int errors = comparePaths(reporter, filename, path, out, bitmap);
|
2016-07-18 17:01:36 +00:00
|
|
|
if (ExpectMatch::kNo == expectMatch) {
|
2015-03-26 14:52:43 +00:00
|
|
|
if (!errors) {
|
|
|
|
SkDebugf("%s failing test %s now succeeds\n", __FUNCTION__, filename);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
return false;
|
|
|
|
}
|
2016-08-09 12:04:29 +00:00
|
|
|
} else if (ExpectMatch::kYes == expectMatch && errors) {
|
2013-04-08 11:50:46 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
2013-04-10 15:55:37 +00:00
|
|
|
reporter->bumpTestCount();
|
2015-03-26 14:52:43 +00:00
|
|
|
return errors == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename) {
|
2016-07-18 17:01:36 +00:00
|
|
|
return inner_simplify(reporter, path, filename, ExpectSuccess::kYes, SkipAssert::kNo,
|
|
|
|
ExpectMatch::kYes);
|
|
|
|
}
|
|
|
|
|
2016-08-31 21:36:29 +00:00
|
|
|
bool testSimplifyFuzz(skiatest::Reporter* reporter, const SkPath& path, const char* filename) {
|
|
|
|
return inner_simplify(reporter, path, filename, ExpectSuccess::kFlaky, SkipAssert::kYes,
|
|
|
|
ExpectMatch::kFlaky);
|
2015-03-26 14:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool testSimplifyCheck(skiatest::Reporter* reporter, const SkPath& path, const char* filename,
|
|
|
|
bool checkFail) {
|
2016-07-18 17:01:36 +00:00
|
|
|
return inner_simplify(reporter, path, filename, checkFail ?
|
|
|
|
ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
|
2014-04-14 17:08:59 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) {
|
|
|
|
SkDebugf("\n");
|
|
|
|
showPathData(a);
|
|
|
|
showOp(shapeOp);
|
|
|
|
showPathData(b);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-16 16:11:16 +00:00
|
|
|
static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
|
2016-07-18 17:01:36 +00:00
|
|
|
const SkPathOp shapeOp, const char* testName, ExpectSuccess expectSuccess,
|
|
|
|
SkipAssert skipAssert, ExpectMatch expectMatch) {
|
2015-03-26 14:52:43 +00:00
|
|
|
#if 0 && DEBUG_SHOW_TEST_NAME
|
2014-04-14 17:08:59 +00:00
|
|
|
showName(a, b, shapeOp);
|
2013-04-08 11:50:46 +00:00
|
|
|
#endif
|
|
|
|
SkPath out;
|
2016-07-18 17:01:36 +00:00
|
|
|
if (!OpDebug(a, b, shapeOp, &out SkDEBUGPARAMS(SkipAssert::kYes == skipAssert)
|
2016-06-08 11:28:19 +00:00
|
|
|
SkDEBUGPARAMS(testName))) {
|
2016-07-18 17:01:36 +00:00
|
|
|
if (ExpectSuccess::kYes == expectSuccess) {
|
|
|
|
SkDebugf("%s %s did not expect failure\n", __FUNCTION__, testName);
|
2016-06-28 16:23:57 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
2013-04-26 19:51:16 +00:00
|
|
|
return false;
|
2016-07-18 17:01:36 +00:00
|
|
|
} else {
|
|
|
|
if (ExpectSuccess::kNo == expectSuccess) {
|
|
|
|
SkDebugf("%s %s unexpected success\n", __FUNCTION__, testName);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
}
|
2013-04-26 19:51:16 +00:00
|
|
|
}
|
2015-03-26 14:52:43 +00:00
|
|
|
if (!reporter->verbose()) {
|
2013-07-16 16:11:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
SkPath pathOut, scaledPathOut;
|
|
|
|
SkRegion rgnA, rgnB, openClip, rgnOut;
|
|
|
|
openClip.setRect(-16000, -16000, 16000, 16000);
|
|
|
|
rgnA.setPath(a, openClip);
|
|
|
|
rgnB.setPath(b, openClip);
|
|
|
|
rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp);
|
|
|
|
rgnOut.getBoundaryPath(&pathOut);
|
|
|
|
|
|
|
|
SkMatrix scale;
|
|
|
|
scaleMatrix(a, b, scale);
|
|
|
|
SkRegion scaledRgnA, scaledRgnB, scaledRgnOut;
|
|
|
|
SkPath scaledA, scaledB;
|
|
|
|
scaledA.addPath(a, scale);
|
|
|
|
scaledA.setFillType(a.getFillType());
|
|
|
|
scaledB.addPath(b, scale);
|
|
|
|
scaledB.setFillType(b.getFillType());
|
|
|
|
scaledRgnA.setPath(scaledA, openClip);
|
|
|
|
scaledRgnB.setPath(scaledB, openClip);
|
|
|
|
scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp);
|
|
|
|
scaledRgnOut.getBoundaryPath(&scaledPathOut);
|
|
|
|
SkBitmap bitmap;
|
|
|
|
SkPath scaledOut;
|
|
|
|
scaledOut.addPath(out, scale);
|
|
|
|
scaledOut.setFillType(out.getFillType());
|
2014-04-14 17:08:59 +00:00
|
|
|
int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, scaledOut, bitmap,
|
2016-08-09 12:04:29 +00:00
|
|
|
a, b, shapeOp, scale, expectMatch);
|
2013-04-10 15:55:37 +00:00
|
|
|
reporter->bumpTestCount();
|
2013-04-08 11:50:46 +00:00
|
|
|
return result == 0;
|
|
|
|
}
|
|
|
|
|
2013-07-16 16:11:16 +00:00
|
|
|
bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
|
2014-11-13 14:58:52 +00:00
|
|
|
const SkPathOp shapeOp, const char* testName) {
|
2016-07-18 17:01:36 +00:00
|
|
|
return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kYes, SkipAssert::kNo,
|
|
|
|
ExpectMatch::kYes);
|
2014-11-13 14:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool testPathOpCheck(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
|
|
|
|
const SkPathOp shapeOp, const char* testName, bool checkFail) {
|
2016-07-18 17:01:36 +00:00
|
|
|
return innerPathOp(reporter, a, b, shapeOp, testName, checkFail ?
|
|
|
|
ExpectSuccess::kYes : ExpectSuccess::kNo, SkipAssert::kNo, ExpectMatch::kNo);
|
2013-07-16 16:11:16 +00:00
|
|
|
}
|
|
|
|
|
2016-08-31 21:36:29 +00:00
|
|
|
bool testPathOpFuzz(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
|
2016-08-09 12:04:29 +00:00
|
|
|
const SkPathOp shapeOp, const char* testName) {
|
|
|
|
return innerPathOp(reporter, a, b, shapeOp, testName, ExpectSuccess::kFlaky, SkipAssert::kYes,
|
|
|
|
ExpectMatch::kFlaky);
|
|
|
|
}
|
|
|
|
|
2016-07-18 17:01:36 +00:00
|
|
|
bool testPathOpFail(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
|
2014-04-14 17:08:59 +00:00
|
|
|
const SkPathOp shapeOp, const char* testName) {
|
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
showName(a, b, shapeOp);
|
|
|
|
#endif
|
2015-04-20 15:31:59 +00:00
|
|
|
SkPath orig;
|
|
|
|
orig.lineTo(54, 43);
|
|
|
|
SkPath out = orig;
|
2014-04-14 17:08:59 +00:00
|
|
|
if (Op(a, b, shapeOp, &out) ) {
|
|
|
|
SkDebugf("%s test is expected to fail\n", __FUNCTION__);
|
|
|
|
REPORTER_ASSERT(reporter, 0);
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-20 15:31:59 +00:00
|
|
|
SkASSERT(out == orig);
|
2014-04-14 17:08:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-05 00:12:46 +00:00
|
|
|
SK_DECLARE_STATIC_MUTEX(gMutex);
|
2013-10-02 14:49:34 +00:00
|
|
|
|
SkThreadPool ~~> SkTaskGroup
SkTaskGroup is like SkThreadPool except the threads stay in
one global pool. Each SkTaskGroup itself is tiny (4 bytes)
and its wait() method applies only to tasks add()ed to that
instance, not the whole thread pool.
This means we don't need to bring up new thread pools when
tests themselves want to use multithreading (e.g. pathops,
quilt). We just create a new SkTaskGroup and wait for that
to complete. This should be more efficient, and allow us
to expand where we use threads to really latency sensitive
places. E.g. we can probably now use these in nanobench
for CPU .skp rendering.
Now that all threads are sharing the same pool, I think we
can remove most of the custom mechanism pathops tests use
to control threading. They'll just ride on the global pool
with all other tests now.
This (temporarily?) removes the GPU multithreading feature
from DM, which we don't use.
On my desktop, DM runs a little faster (57s -> 55s) in
Debug, and a lot faster in Release (36s -> 24s). The bots
show speedups of similar proportions, cutting more than a
minute off the N4/Release and Win7/Debug runtimes.
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/9c7207b5dc71dc5a96a2eb107d401133333d5b6f
R=caryclark@google.com, bsalomon@google.com, bungeman@google.com, mtklein@google.com, reed@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/531653002
2014-09-03 22:34:37 +00:00
|
|
|
void initializeTests(skiatest::Reporter* reporter, const char* test) {
|
2013-10-02 14:49:34 +00:00
|
|
|
if (reporter->verbose()) {
|
|
|
|
SkAutoMutexAcquire lock(gMutex);
|
|
|
|
testName = test;
|
|
|
|
size_t testNameSize = strlen(test);
|
|
|
|
SkFILEStream inFile("../../experimental/Intersection/op.htm");
|
|
|
|
if (inFile.isValid()) {
|
|
|
|
SkTDArray<char> inData;
|
2014-04-14 17:08:59 +00:00
|
|
|
inData.setCount((int) inFile.getLength());
|
2013-10-02 14:49:34 +00:00
|
|
|
size_t inLen = inData.count();
|
|
|
|
inFile.read(inData.begin(), inLen);
|
2015-08-27 14:41:13 +00:00
|
|
|
inFile.setPath(nullptr);
|
2013-10-02 14:49:34 +00:00
|
|
|
char* insert = strstr(inData.begin(), marker);
|
|
|
|
if (insert) {
|
|
|
|
insert += sizeof(marker) - 1;
|
|
|
|
const char* numLoc = insert + 4 /* indent spaces */ + testNameSize - 1;
|
|
|
|
testNumber = atoi(numLoc) + 1;
|
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 15:55:37 +00:00
|
|
|
void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFillType) {
|
|
|
|
const char testFunction[] = "testSimplify(path);";
|
2015-08-27 14:41:13 +00:00
|
|
|
const char* pathPrefix = nullptr;
|
|
|
|
const char* nameSuffix = nullptr;
|
2013-04-08 11:50:46 +00:00
|
|
|
if (pathFillType == SkPath::kEvenOdd_FillType) {
|
|
|
|
pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n";
|
|
|
|
nameSuffix = "x";
|
|
|
|
}
|
2013-04-10 15:55:37 +00:00
|
|
|
SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
|
|
|
|
outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, rRamStream);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 15:55:37 +00:00
|
|
|
void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) {
|
|
|
|
const char testFunction[] = "testOp(path);";
|
2013-04-15 19:13:59 +00:00
|
|
|
SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes));
|
2013-04-08 11:50:46 +00:00
|
|
|
const char* nameSuffix = opSuffixes[op];
|
2013-04-10 15:55:37 +00:00
|
|
|
SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
|
2015-08-27 14:41:13 +00:00
|
|
|
outputToStream(pathStr, nullptr, nameSuffix, testFunction, true, rRamStream);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
|
2014-04-14 17:08:59 +00:00
|
|
|
void (*firstTest)(skiatest::Reporter* , const char* filename),
|
2015-03-26 14:52:43 +00:00
|
|
|
void (*skipTest)(skiatest::Reporter* , const char* filename),
|
2014-04-14 17:08:59 +00:00
|
|
|
void (*stopTest)(skiatest::Reporter* , const char* filename), bool reverse) {
|
2013-04-08 11:50:46 +00:00
|
|
|
size_t index;
|
|
|
|
if (firstTest) {
|
|
|
|
index = count - 1;
|
|
|
|
while (index > 0 && tests[index].fun != firstTest) {
|
|
|
|
--index;
|
|
|
|
}
|
2013-05-07 18:51:31 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
2015-03-26 14:52:43 +00:00
|
|
|
SkDebugf("\n<div id=\"%s\">\n", tests[index].str);
|
2013-04-08 11:50:46 +00:00
|
|
|
#endif
|
2014-04-14 17:08:59 +00:00
|
|
|
(*tests[index].fun)(reporter, tests[index].str);
|
|
|
|
if (tests[index].fun == stopTest) {
|
|
|
|
return;
|
|
|
|
}
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
|
|
|
index = reverse ? count - 1 : 0;
|
|
|
|
size_t last = reverse ? 0 : count - 1;
|
2015-03-26 14:52:43 +00:00
|
|
|
bool foundSkip = !skipTest;
|
2013-04-08 11:50:46 +00:00
|
|
|
do {
|
2015-03-26 14:52:43 +00:00
|
|
|
if (tests[index].fun == skipTest) {
|
|
|
|
foundSkip = true;
|
|
|
|
}
|
|
|
|
if (foundSkip && tests[index].fun != firstTest) {
|
2013-05-07 18:51:31 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
2015-03-26 14:52:43 +00:00
|
|
|
SkDebugf("\n<div id=\"%s\">\n", tests[index].str);
|
2013-04-08 11:50:46 +00:00
|
|
|
#endif
|
2016-08-31 21:36:29 +00:00
|
|
|
(*tests[index].fun)(reporter, tests[index].str);
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
2015-04-23 16:13:37 +00:00
|
|
|
if (tests[index].fun == stopTest || index == last) {
|
2014-04-14 17:08:59 +00:00
|
|
|
break;
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|
2015-04-23 16:13:37 +00:00
|
|
|
index += reverse ? -1 : 1;
|
|
|
|
} while (true);
|
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
SkDebugf(
|
|
|
|
"\n"
|
|
|
|
"</div>\n"
|
|
|
|
"\n"
|
|
|
|
"<script type=\"text/javascript\">\n"
|
|
|
|
"\n"
|
|
|
|
"var testDivs = [\n"
|
|
|
|
);
|
|
|
|
index = reverse ? count - 1 : 0;
|
|
|
|
last = reverse ? 0 : count - 1;
|
|
|
|
foundSkip = !skipTest;
|
|
|
|
do {
|
|
|
|
if (tests[index].fun == skipTest) {
|
|
|
|
foundSkip = true;
|
|
|
|
}
|
|
|
|
if (foundSkip && tests[index].fun != firstTest) {
|
|
|
|
SkDebugf(" %s,\n", tests[index].str);
|
|
|
|
}
|
|
|
|
if (tests[index].fun == stopTest || index == last) {
|
2013-04-08 11:50:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
index += reverse ? -1 : 1;
|
|
|
|
} while (true);
|
2015-04-23 16:13:37 +00:00
|
|
|
#endif
|
2013-04-08 11:50:46 +00:00
|
|
|
}
|