blob: 59fb92d5b6f2005c70f058cfba2bf35466490bd3 [file] [log] [blame]
caryclark@google.com818b0cc2013-04-08 11:50:46 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef PathOpsExtendedTest_DEFINED
8#define PathOpsExtendedTest_DEFINED
9
10#include "Test.h"
11#include "SkPathOpsTypes.h"
12#include "SkBitmap.h"
13#include "SkPath.h"
14#include "SkStream.h"
15
16#ifdef SK_BUILD_FOR_WIN
17#define HARD_CODE_PTHREAD 0
18#else
19#define HARD_CODE_PTHREAD 1
20#endif
21
22#if HARD_CODE_PTHREAD
23#include <pthread.h>
24#else
25#include "SkThread.h"
26#include "../../src/utils/SkThreadUtils.h"
27#endif
28
29#if HARD_CODE_PTHREAD
30typedef void* (*ThreadFunction)(void*);
31#define THREAD_TYPE void*
32#define THREAD_RETURN return NULL;
33#else
34typedef void (*ThreadFunction)(void*);
35#define THREAD_TYPE void
36#define THREAD_RETURN
37#endif
38
39struct State4;
40
41struct TestDesc {
42 void (*fun)(skiatest::Reporter*);
43 const char* str;
44};
45
46extern bool gShowTestProgress;
47extern bool gAllowExtendedTest;
48
49//extern int comparePaths(const SkPath& one, const SkPath& two);
50extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap);
51extern bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths);
52extern void showOp(const SkPathOp op);
53extern void showPath(const SkPath& path, const char* str);
54extern void showPath(const SkPath& path);
55extern void showPathData(const SkPath& path);
56extern bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
57 const SkPathOp );
58extern bool testSimplify(SkPath& path, bool useXor, SkPath& out,
59 State4& state, const char* pathStr);
60extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path);
61
62struct State4 {
63 State4();
64#if HARD_CODE_PTHREAD
65 static pthread_mutex_t addQueue;
66 static pthread_cond_t checkQueue;
67 pthread_cond_t initialized;
68 pthread_t threadID;
69#else
70 SkThread* thread;
71#endif
72 static State4* queue;
73 int index;
74 bool done;
75 bool last;
76 int a;
77 int b;
78 int c;
79 int d; // sometimes 1 if abc_is_a_triangle
80 int testsRun;
81 char filename[256];
82 skiatest::Reporter* reporter;
83 SkBitmap bitmap;
84 mutable SkDynamicMemoryWStream ramStream;
85};
86
87void createThread(State4* statePtr, void* (*test)(void* ));
88int dispatchTest4(ThreadFunction testFun, int a, int b, int c, int d);
89void initializeTests(skiatest::Reporter* reporter, const char* testName, size_t testNameSize);
90void outputProgress(const State4& state, const char* pathStr, SkPath::FillType );
91void outputProgress(const State4& state, const char* pathStr, SkPathOp op);
92void outputToStream(const State4& state, const char* pathStr, const char* pathPrefix,
93 const char* nameSuffix,
94 const char* testFunction, SkWStream& outFile);
95bool runNextTestSet(State4& state);
96int waitForCompletion();
97
98void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
99 void (*firstTest)(skiatest::Reporter* ),
100 void (*stopTest)(skiatest::Reporter* ), bool reverse);
101
102#endif