2013-07-08 17:17:02 +00:00
|
|
|
#include "PathOpsExtendedTest.h"
|
|
|
|
#include "PathOpsThreadedCommon.h"
|
2013-05-08 07:01:40 +00:00
|
|
|
#include "SkBitmap.h"
|
2013-10-02 14:49:34 +00:00
|
|
|
#include "SkColor.h"
|
2013-05-08 07:01:40 +00:00
|
|
|
#include "SkDevice.h"
|
|
|
|
#include "SkCanvas.h"
|
2013-06-04 17:59:42 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2013-05-08 07:01:40 +00:00
|
|
|
#include "SkImageEncoder.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkString.h"
|
2013-07-08 17:17:02 +00:00
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_WIN
|
2013-10-02 14:49:34 +00:00
|
|
|
#define PATH_SLASH "\\"
|
|
|
|
#define IN_DIR "D:" PATH_SLASH "skp"
|
|
|
|
#define OUT_DIR "D:" PATH_SLASH
|
2013-07-08 17:17:02 +00:00
|
|
|
#else
|
2013-10-02 14:49:34 +00:00
|
|
|
#define PATH_SLASH "/"
|
|
|
|
#if 1
|
|
|
|
#define IN_DIR "/usr/local/google/home/caryclark/new10k" PATH_SLASH
|
|
|
|
#define OUT_DIR "/usr/local/google/home/caryclark/out10k" PATH_SLASH
|
|
|
|
#else
|
|
|
|
#define IN_DIR "/usr/local/google/home/caryclark/6-18-13" PATH_SLASH
|
|
|
|
#define OUT_DIR "/usr/local/google/home/caryclark" PATH_SLASH
|
|
|
|
#endif
|
2013-07-08 17:17:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static const char pictDir[] = IN_DIR ;
|
|
|
|
static const char outSkpClipDir[] = OUT_DIR "skpClip";
|
|
|
|
static const char outOldClipDir[] = OUT_DIR "oldClip";
|
2013-05-08 07:01:40 +00:00
|
|
|
|
2013-10-02 14:49:34 +00:00
|
|
|
static SkString make_filepath(const char* dir, const SkString& name) {
|
|
|
|
SkString path(dir);
|
2013-05-08 07:01:40 +00:00
|
|
|
size_t len = strlen(dir);
|
2013-07-08 17:17:02 +00:00
|
|
|
if (len > 0 && dir[len - 1] != PATH_SLASH[0]) {
|
2013-10-02 14:49:34 +00:00
|
|
|
path.append(PATH_SLASH);
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
2013-10-02 14:49:34 +00:00
|
|
|
path.append(name);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
static SkString make_png_name(const SkString& filename) {
|
|
|
|
SkString pngName = SkString(filename);
|
|
|
|
pngName.remove(pngName.size() - 3, 3);
|
|
|
|
pngName.append("png");
|
|
|
|
return pngName;
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 17:17:02 +00:00
|
|
|
static void testOne(const SkString& filename) {
|
2013-10-02 14:49:34 +00:00
|
|
|
if (filename == SkString("http___migracioncolombia_gov_co.skp")
|
|
|
|
|| filename == SkString("http___miuki_info.skp")
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
#if DEBUG_SHOW_TEST_NAME
|
|
|
|
SkString testName(filename);
|
|
|
|
const char http[] = "http";
|
|
|
|
if (testName.startsWith(http)) {
|
|
|
|
testName.remove(0, sizeof(http) - 1);
|
|
|
|
}
|
|
|
|
while (testName.startsWith("_")) {
|
|
|
|
testName.remove(0, 1);
|
|
|
|
}
|
|
|
|
const char dotSkp[] = ".skp";
|
|
|
|
if (testName.endsWith(dotSkp)) {
|
|
|
|
size_t len = testName.size();
|
|
|
|
testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1);
|
|
|
|
}
|
|
|
|
testName.prepend("skp");
|
|
|
|
testName.append("1");
|
|
|
|
strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGTH);
|
|
|
|
#endif
|
2013-10-02 14:49:34 +00:00
|
|
|
SkString path = make_filepath(pictDir, filename);
|
2013-07-08 17:17:02 +00:00
|
|
|
SkFILEStream stream(path.c_str());
|
|
|
|
if (!stream.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-23 15:27:41 +00:00
|
|
|
SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
|
|
|
|
if (!pic) {
|
2013-07-08 17:17:02 +00:00
|
|
|
SkDebugf("unable to decode %s\n", filename.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int width = pic->width();
|
|
|
|
int height = pic->height();
|
2013-10-02 14:49:34 +00:00
|
|
|
|
2013-07-08 17:17:02 +00:00
|
|
|
SkBitmap bitmap;
|
2013-10-02 14:49:34 +00:00
|
|
|
int scale = 1;
|
|
|
|
do {
|
|
|
|
bitmap.setConfig(SkBitmap::kARGB_8888_Config, (width + scale - 1) / scale,
|
|
|
|
(height + scale - 1) / scale);
|
|
|
|
bool success = bitmap.allocPixels();
|
|
|
|
bitmap.eraseColor(SK_ColorWHITE);
|
|
|
|
if (success) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SkDebugf("-%d-", scale);
|
|
|
|
} while ((scale *= 2) < 32);
|
|
|
|
if (scale >= 32) {
|
|
|
|
SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", filename.c_str(),
|
|
|
|
width, height);
|
2013-07-08 17:17:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
SkCanvas canvas(bitmap);
|
2013-10-02 14:49:34 +00:00
|
|
|
canvas.scale(1.0f / scale, 1.0f / scale);
|
|
|
|
SkString pngName = make_png_name(filename);
|
2013-07-08 17:17:02 +00:00
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
bool useOp = i ? true : false;
|
|
|
|
canvas.setAllowSimplifyClip(useOp);
|
|
|
|
pic->draw(&canvas);
|
2013-10-02 14:49:34 +00:00
|
|
|
SkString outFile = make_filepath(useOp ? outSkpClipDir : outOldClipDir, pngName);
|
|
|
|
if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type,
|
|
|
|
100)) {
|
|
|
|
SkDebugf("unable to encode %s (width=%d height=%d)\n", pngName.c_str(),
|
|
|
|
bitmap.width(), bitmap.height());
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
}
|
|
|
|
SkDELETE(pic);
|
|
|
|
}
|
|
|
|
|
2013-10-02 14:49:34 +00:00
|
|
|
const char* tryFixed[] = {
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t tryFixedCount = sizeof(tryFixed) / sizeof(tryFixed[0]);
|
|
|
|
|
|
|
|
const char* skipOver[] = {
|
|
|
|
"http___carpetplanet_ru.skp", // cubic/cubic intersect
|
|
|
|
"http___carrot_is.skp", // bridgeOp() SkASSERT(unsortable || !current->done());
|
|
|
|
|
|
|
|
/*!*/"http___dotsrc_org.skp", // asserts in png decode
|
|
|
|
"http___frauen_magazin_com.skp", // bridgeOp() SkASSERT(unsortable || !current->done());
|
|
|
|
"http___i_gino_com.skp", // unexpected cubic/quad coincidence
|
|
|
|
// {61, 857, 61, 789.06897, 116.068977, 734, 184, 734}
|
|
|
|
// {184, 734, 133.051727, 734, 97.0258636, 770.025879}
|
|
|
|
"http___ilkoora_com.skp", // assert wind sum != min32 from markDoneBinary / findNextOp #28k
|
|
|
|
/*!*/"http___migracioncolombia_gov_co.skp", // crashes on picture decode
|
|
|
|
"http___mm4everfriends_com.skp", // bumpSpan/addTCoincident (from calcPartialCoincidentWinding)
|
|
|
|
"http___mtrk_uz.skp", // checkEnds() assert #36.3k
|
|
|
|
"http___pchappy_com_au.skp", // bridgeOp() assert unsortable || ! empty #37.2k
|
|
|
|
"http___sciality_com.skp", // bridgeOp() SkASSERT(unsortable || !current->done()); #32.4k
|
|
|
|
/*!*/"http___sozialticker_com.skp", // asserts in png decode
|
|
|
|
"http___sudoestenegocios_com.skp", // assert fT < 1 in addTCoincident
|
|
|
|
"http___thesuburbanite_com.skp", // bridgeOp() SkASSERT(unsortable || !current->done());
|
|
|
|
|
|
|
|
"http___fluentin3months_com.skp", // calcCommonCoincidentWinding from calcPartialCoincidentWinding #38.3k
|
|
|
|
"http___teachersbadi_blogspot_in.skp", // calcCommonCoincidentWinding from calcPartialCoincidentWinding #53.4k
|
|
|
|
"http___wsms_ru.skp", // assert wind sum != min32 from markDoneBinary / findNextOp #49.5k
|
|
|
|
"http___voycer_de.skp", // calcCommonCoincidentWinding from calcPartialCoincidentWinding #47k
|
|
|
|
"http___77hz_jp.skp", // addTCancel from calcCoincidentWinding #47.1k
|
|
|
|
|
|
|
|
"http___hostloco_com.skp", // t < 0 AddIntersectsT
|
|
|
|
/*!*/"http___oggicronaca_it.skp", // asserts in png decode
|
|
|
|
"http___sergeychunkevich_com.skp", // t < 0 AddIntersectsT
|
|
|
|
"http___tracksflow_com.skp", // assert otherEnd >= 0 from nextChase
|
|
|
|
"http___autobutler_dk.skp", // t < 0 AddIntersectsT
|
|
|
|
"http___onlinecollege_org.skp", // bridgeOp() assert unsortable || ! empty #100.1k
|
|
|
|
"http___national_com_au.skp", // bridgeOp() assert unsortable || ! empty #110.2k
|
|
|
|
/*!*/"http___anitadongre_com.skp", // exceptionally large width and height
|
|
|
|
"http___rentacheat_com.skp", // bridgeOp() assert unsortable || ! empty #110.8k
|
|
|
|
/*!*/"http___gruesse_de.skp", // asserts in png decode
|
|
|
|
/*!*/"http___crn_in.png", // width=1250047
|
|
|
|
"http___breakmystyle_com.skp", // assert qPt == lPt in quad intersection
|
|
|
|
"http___naoxrane_ru.skp", // assert t4+...t0 == 0 in quartic roots #128.3k
|
|
|
|
"http___tcmevents_org.skp", // assert in addTCoincident (from calcPartialCoincidentWinding) #143.3k
|
|
|
|
/*!*/"http___listbuildingcashsecrets_com.skp", // asserts in png decode #152.7k
|
|
|
|
/*!*/"http___skyscraperpage_com.skp", // asserts in png decode #155.5k
|
|
|
|
"http___mlk_com.skp", // bridgeOp() assert unsortable || ! empty #158.7k
|
|
|
|
"http___sd_graphic_net.skp", // bridgeOp() assert unsortable || ! empty #163.3k
|
|
|
|
"http___kopepasah_com.skp", // checkEnds() assert #188.2k
|
|
|
|
/*!*/"http___darkreloaded_com.skp", // asserts in png decode #188.4k
|
|
|
|
"http___redbullskatearcade_es.skp", // bridgeOp() assert unsortable || ! empty #192.5k
|
|
|
|
"http___partainasdemo250_org.skp", // bridgeOp() assert unsortable || ! empty #200.2k
|
|
|
|
|
|
|
|
// these failures are from the new 10k set
|
|
|
|
"http___www_freerepublic_com_.skp", // assert in opangle <
|
|
|
|
"http___www_lavoixdunord_fr_.skp", // bridgeOp() assert unsortable || ! empty
|
|
|
|
"http___www_booking_com_.skp", // bridgeOp() assert unsortable || ! empty
|
|
|
|
"http___www_fj_p_com_.skp", // markWinding assert from findChaseOp
|
|
|
|
"http___www_leadpages_net_.skp", // assert in opangle <
|
|
|
|
"http___www_despegar_com_mx_.skp", // bridgeOp() assert unsortable || ! empty
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t skipOverCount = sizeof(skipOver) / sizeof(skipOver[0]);
|
2013-07-08 17:17:02 +00:00
|
|
|
|
2013-05-08 07:01:40 +00:00
|
|
|
static void PathOpsSkpClipTest(skiatest::Reporter* reporter) {
|
|
|
|
SkOSFile::Iter iter(pictDir, "skp");
|
|
|
|
SkString filename;
|
2013-07-08 17:17:02 +00:00
|
|
|
int testCount = 0;
|
2013-05-08 07:01:40 +00:00
|
|
|
while (iter.next(&filename)) {
|
2013-10-02 14:49:34 +00:00
|
|
|
SkString pngName = make_png_name(filename);
|
|
|
|
SkString oldPng = make_filepath(outOldClipDir, pngName);
|
|
|
|
SkString newPng = make_filepath(outSkpClipDir, pngName);
|
|
|
|
if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) {
|
|
|
|
reporter->bumpTestCount();
|
2013-05-08 07:01:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-10-02 14:49:34 +00:00
|
|
|
for (size_t index = 0; index < skipOverCount; ++index) {
|
|
|
|
if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) == 0) {
|
|
|
|
reporter->bumpTestCount();
|
|
|
|
goto skipOver;
|
|
|
|
}
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
testOne(filename);
|
|
|
|
if (reporter->verbose()) {
|
|
|
|
SkDebugf(".");
|
|
|
|
if (++testCount % 100 == 0) {
|
2013-10-02 14:49:34 +00:00
|
|
|
SkDebugf("%d\n", testCount);
|
2013-07-08 17:17:02 +00:00
|
|
|
}
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
2013-10-02 14:49:34 +00:00
|
|
|
skipOver:
|
2013-07-08 17:17:02 +00:00
|
|
|
reporter->bumpTestCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 14:49:34 +00:00
|
|
|
static void bumpCount(skiatest::Reporter* reporter, bool skipping) {
|
|
|
|
if (reporter->verbose()) {
|
|
|
|
static int threadTestCount;
|
|
|
|
if (!skipping) {
|
2013-07-08 17:17:02 +00:00
|
|
|
SkDebugf(".");
|
2013-06-04 17:59:42 +00:00
|
|
|
}
|
2013-10-02 14:49:34 +00:00
|
|
|
sk_atomic_inc(&threadTestCount);
|
|
|
|
if (!skipping && threadTestCount % 100 == 0) {
|
|
|
|
SkDebugf("%d\n", threadTestCount);
|
|
|
|
}
|
|
|
|
if (skipping && threadTestCount % 10000 == 0) {
|
|
|
|
SkDebugf("%d\n", threadTestCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testSkpClipMain(PathOpsThreadState* data) {
|
|
|
|
SkString str(data->fSerialNo);
|
|
|
|
testOne(str);
|
|
|
|
bumpCount(data->fReporter, false);
|
|
|
|
data->fReporter->bumpTestCount();
|
2013-07-08 17:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) {
|
|
|
|
int threadCount = initializeTests(reporter, "skpClipThreadedTest");
|
|
|
|
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
|
|
|
|
SkOSFile::Iter iter(pictDir, "skp");
|
|
|
|
SkString filename;
|
|
|
|
while (iter.next(&filename)) {
|
2013-10-02 14:49:34 +00:00
|
|
|
SkString pngName = make_png_name(filename);
|
|
|
|
SkString oldPng = make_filepath(outOldClipDir, pngName);
|
|
|
|
SkString newPng = make_filepath(outSkpClipDir, pngName);
|
|
|
|
if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) {
|
|
|
|
bumpCount(reporter, true);
|
2013-07-08 17:17:02 +00:00
|
|
|
continue;
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
2013-10-02 14:49:34 +00:00
|
|
|
for (size_t index = 0; index < skipOverCount; ++index) {
|
|
|
|
if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) == 0) {
|
|
|
|
bumpCount(reporter, true);
|
|
|
|
goto skipOver;
|
|
|
|
}
|
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
*testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable,
|
|
|
|
(&testSkpClipMain, filename.c_str(), &testRunner));
|
2013-10-02 14:49:34 +00:00
|
|
|
skipOver:
|
|
|
|
;
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
2013-07-08 17:17:02 +00:00
|
|
|
testRunner.render();
|
|
|
|
}
|
|
|
|
|
2013-10-02 14:49:34 +00:00
|
|
|
static void PathOpsSkpClipFixedTest(skiatest::Reporter* reporter) {
|
|
|
|
for (size_t index = 0; index < tryFixedCount; ) {
|
|
|
|
SkString filename(tryFixed[index]);
|
|
|
|
testOne(filename);
|
|
|
|
++index;
|
|
|
|
if (reporter->verbose()) {
|
|
|
|
SkDebugf(".");
|
|
|
|
if (index % 100 == 0) {
|
|
|
|
SkDebugf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reporter->bumpTestCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-15 13:29:13 +00:00
|
|
|
static void PathOpsSkpClipOneOffTest(skiatest::Reporter* reporter) {
|
2013-10-02 14:49:34 +00:00
|
|
|
SkString filename("http___78_cn_.skp");
|
2013-07-08 17:17:02 +00:00
|
|
|
testOne(filename);
|
2013-05-08 07:01:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "TestClassDef.h"
|
|
|
|
DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest)
|
2013-07-08 17:17:02 +00:00
|
|
|
|
2013-10-02 14:49:34 +00:00
|
|
|
DEFINE_TESTCLASS_SHORT(PathOpsSkpClipFixedTest)
|
|
|
|
|
2013-07-15 13:29:13 +00:00
|
|
|
DEFINE_TESTCLASS_SHORT(PathOpsSkpClipOneOffTest)
|
2013-07-08 17:17:02 +00:00
|
|
|
|
|
|
|
DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest)
|