caryclark@google.com | 818b0cc | 2013-04-08 11:50:46 +0000 | [diff] [blame^] | 1 | /* |
| 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 |
| 30 | typedef void* (*ThreadFunction)(void*); |
| 31 | #define THREAD_TYPE void* |
| 32 | #define THREAD_RETURN return NULL; |
| 33 | #else |
| 34 | typedef void (*ThreadFunction)(void*); |
| 35 | #define THREAD_TYPE void |
| 36 | #define THREAD_RETURN |
| 37 | #endif |
| 38 | |
| 39 | struct State4; |
| 40 | |
| 41 | struct TestDesc { |
| 42 | void (*fun)(skiatest::Reporter*); |
| 43 | const char* str; |
| 44 | }; |
| 45 | |
| 46 | extern bool gShowTestProgress; |
| 47 | extern bool gAllowExtendedTest; |
| 48 | |
| 49 | //extern int comparePaths(const SkPath& one, const SkPath& two); |
| 50 | extern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap); |
| 51 | extern bool drawAsciiPaths(const SkPath& one, const SkPath& two, bool drawPaths); |
| 52 | extern void showOp(const SkPathOp op); |
| 53 | extern void showPath(const SkPath& path, const char* str); |
| 54 | extern void showPath(const SkPath& path); |
| 55 | extern void showPathData(const SkPath& path); |
| 56 | extern bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, |
| 57 | const SkPathOp ); |
| 58 | extern bool testSimplify(SkPath& path, bool useXor, SkPath& out, |
| 59 | State4& state, const char* pathStr); |
| 60 | extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path); |
| 61 | |
| 62 | struct 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 | |
| 87 | void createThread(State4* statePtr, void* (*test)(void* )); |
| 88 | int dispatchTest4(ThreadFunction testFun, int a, int b, int c, int d); |
| 89 | void initializeTests(skiatest::Reporter* reporter, const char* testName, size_t testNameSize); |
| 90 | void outputProgress(const State4& state, const char* pathStr, SkPath::FillType ); |
| 91 | void outputProgress(const State4& state, const char* pathStr, SkPathOp op); |
| 92 | void outputToStream(const State4& state, const char* pathStr, const char* pathPrefix, |
| 93 | const char* nameSuffix, |
| 94 | const char* testFunction, SkWStream& outFile); |
| 95 | bool runNextTestSet(State4& state); |
| 96 | int waitForCompletion(); |
| 97 | |
| 98 | void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, |
| 99 | void (*firstTest)(skiatest::Reporter* ), |
| 100 | void (*stopTest)(skiatest::Reporter* ), bool reverse); |
| 101 | |
| 102 | #endif |