19e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com/* 29e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Copyright 2012 Google Inc. 39e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * 49e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be 59e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * found in the LICENSE file. 69e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com */ 7d88e0894d0156f4d427b812fec69bfba3eec7a8dcaryclark@google.com#include "ShapeOps.h" 878e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com#include "SkBitmap.h" 903f970652e07c6832cae41fa374cb68ca80d472ccaryclark@google.com#include "SkStream.h" 1078e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com#include <pthread.h> 11cd4421df5012b75c792c6c8bf2c5ee0410921c15caryclark@google.com 1259823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.comstruct State4; 13198e054b33051a6cd5f606ccbc8d539cefc5631fcaryclark@google.com 14198e054b33051a6cd5f606ccbc8d539cefc5631fcaryclark@google.com//extern int comparePaths(const SkPath& one, const SkPath& two); 15be584d782020fe0d413a9ab4e9a57a13b1ac1032reed@google.comextern int comparePaths(const SkPath& one, const SkPath& two, SkBitmap& bitmap); 16cd4421df5012b75c792c6c8bf2c5ee0410921c15caryclark@google.comextern void comparePathsTiny(const SkPath& one, const SkPath& two); 17752b60e633a349c5b9f7bcc6a28b8064fc77bb41caryclark@google.comextern bool drawAsciiPaths(const SkPath& one, const SkPath& two, 182e7f4c810dc717383df42d27bdba862514ab6d51caryclark@google.com bool drawPaths); 19d4c8e1e035bc2edb6caf2c9eac71ef918e60b80bcaryclark@google.comextern void showOp(const ShapeOp op); 20d4c8e1e035bc2edb6caf2c9eac71ef918e60b80bcaryclark@google.comextern void showPath(const SkPath& path, const char* str); 21d4c8e1e035bc2edb6caf2c9eac71ef918e60b80bcaryclark@google.comextern void showPath(const SkPath& path); 22d4c8e1e035bc2edb6caf2c9eac71ef918e60b80bcaryclark@google.comextern void showPathData(const SkPath& path); 23198e054b33051a6cd5f606ccbc8d539cefc5631fcaryclark@google.comextern bool testSimplify(const SkPath& path, bool fill, SkPath& out, 24be584d782020fe0d413a9ab4e9a57a13b1ac1032reed@google.com SkBitmap& bitmap); 2524bec79d6f3d71ff97b50db72461a3892bd4f6b5caryclark@google.comextern bool testSimplifyx(SkPath& path, bool useXor, SkPath& out, 2659823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.com State4& state, const char* pathStr); 278dcf114db9762c02d217beba6e29dffa4e92d298caryclark@google.comextern bool testSimplifyx(const SkPath& path); 2831143cf37fa38dc98f71c71e518ecc21c83b5e27caryclark@google.comextern bool testShapeOp(const SkPath& a, const SkPath& b, const ShapeOp ); 2978e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com 3078e17130f396d8b2157116c2504e357192f87ed1caryclark@google.comstruct State4 { 3178e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com State4(); 322ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com static pthread_mutex_t addQueue; 332ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com static pthread_cond_t checkQueue; 342ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com pthread_cond_t initialized; 352ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com static State4* queue; 362ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com pthread_t threadID; 372ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com int index; 382ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com bool done; 392ddff9388694263c7be9347de7eb768cd0847997caryclark@google.com bool last; 4078e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com int a; 4178e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com int b; 4278e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com int c; 4359823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.com int d; // sometimes 1 if abc_is_a_triangle 4427c449af06cd1d05db441593d08b84f3530fba52caryclark@google.com int testsRun; 4547580694fbe974a065caf7c39c3d2075708c2018caryclark@google.com char filename[256]; 46d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com 4778e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com SkBitmap bitmap; 4878e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com}; 4978e17130f396d8b2157116c2504e357192f87ed1caryclark@google.com 5078e17130f396d8b2157116c2504e357192f87ed1caryclark@google.comvoid createThread(State4* statePtr, void* (*test)(void* )); 5159823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.comint dispatchTest4(void* (*testFun)(void* ), int a, int b, int c, int d); 5259823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.comvoid initializeTests(const char* testName, size_t testNameSize); 5324bec79d6f3d71ff97b50db72461a3892bd4f6b5caryclark@google.comvoid outputProgress(const State4& state, const char* pathStr, SkPath::FillType ); 54b1c42bbdcff20257b30d155fe014d3e04233de45caryclark@google.comvoid outputProgress(const State4& state, const char* pathStr, ShapeOp op); 55b1c42bbdcff20257b30d155fe014d3e04233de45caryclark@google.comvoid outputToStream(const State4& state, const char* pathStr, const char* pathPrefix, 56b1c42bbdcff20257b30d155fe014d3e04233de45caryclark@google.com const char* nameSuffix, 57b1c42bbdcff20257b30d155fe014d3e04233de45caryclark@google.com const char* testFunction, SkWStream& outFile); 5859823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.combool runNextTestSet(State4& state); 5959823f7f3ba43c7c6bc1fa8c600b093ecb4236aacaryclark@google.comint waitForCompletion(); 60