166089e4ec4f1702caf2154780471417872862148caryclark@google.com/* 266089e4ec4f1702caf2154780471417872862148caryclark@google.com * Copyright 2012 Google Inc. 366089e4ec4f1702caf2154780471417872862148caryclark@google.com * 466089e4ec4f1702caf2154780471417872862148caryclark@google.com * Use of this source code is governed by a BSD-style license that can be 566089e4ec4f1702caf2154780471417872862148caryclark@google.com * found in the LICENSE file. 666089e4ec4f1702caf2154780471417872862148caryclark@google.com */ 766089e4ec4f1702caf2154780471417872862148caryclark@google.com#ifndef PathOpsThreadedCommon_DEFINED 866089e4ec4f1702caf2154780471417872862148caryclark@google.com#define PathOpsThreadedCommon_DEFINED 966089e4ec4f1702caf2154780471417872862148caryclark@google.com 107eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com#include "SkGraphics.h" 1166089e4ec4f1702caf2154780471417872862148caryclark@google.com#include "SkTDArray.h" 1266089e4ec4f1702caf2154780471417872862148caryclark@google.com 1366089e4ec4f1702caf2154780471417872862148caryclark@google.com#define PATH_STR_SIZE 512 1466089e4ec4f1702caf2154780471417872862148caryclark@google.com 1566089e4ec4f1702caf2154780471417872862148caryclark@google.comclass PathOpsThreadedRunnable; 16e942bc329aadbdf6f7f67e35faab52536b964ed9caryclark@google.com 17e942bc329aadbdf6f7f67e35faab52536b964ed9caryclark@google.comnamespace skiatest { 18e942bc329aadbdf6f7f67e35faab52536b964ed9caryclark@google.comclass Reporter; 19e942bc329aadbdf6f7f67e35faab52536b964ed9caryclark@google.com} 2066089e4ec4f1702caf2154780471417872862148caryclark@google.com 2166089e4ec4f1702caf2154780471417872862148caryclark@google.comstruct PathOpsThreadState { 2266089e4ec4f1702caf2154780471417872862148caryclark@google.com unsigned char fA; 2366089e4ec4f1702caf2154780471417872862148caryclark@google.com unsigned char fB; 2466089e4ec4f1702caf2154780471417872862148caryclark@google.com unsigned char fC; 2566089e4ec4f1702caf2154780471417872862148caryclark@google.com unsigned char fD; 2666089e4ec4f1702caf2154780471417872862148caryclark@google.com char* fPathStr; 270361032c0b53401030a720bc8b4930c3ec59f19ecaryclark@google.com const char* fKey; 287eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com char fSerialNo[256]; 2966089e4ec4f1702caf2154780471417872862148caryclark@google.com skiatest::Reporter* fReporter; 3066089e4ec4f1702caf2154780471417872862148caryclark@google.com SkBitmap* fBitmap; 3166089e4ec4f1702caf2154780471417872862148caryclark@google.com}; 3266089e4ec4f1702caf2154780471417872862148caryclark@google.com 3366089e4ec4f1702caf2154780471417872862148caryclark@google.comclass PathOpsThreadedTestRunner { 3466089e4ec4f1702caf2154780471417872862148caryclark@google.compublic: 35406654be7a930b484159f5bca107d3b11d8a9edemtklein PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {} 3666089e4ec4f1702caf2154780471417872862148caryclark@google.com 3766089e4ec4f1702caf2154780471417872862148caryclark@google.com ~PathOpsThreadedTestRunner(); 3866089e4ec4f1702caf2154780471417872862148caryclark@google.com 3966089e4ec4f1702caf2154780471417872862148caryclark@google.com void render(); 4066089e4ec4f1702caf2154780471417872862148caryclark@google.com 4166089e4ec4f1702caf2154780471417872862148caryclark@google.compublic: 4266089e4ec4f1702caf2154780471417872862148caryclark@google.com SkTDArray<PathOpsThreadedRunnable*> fRunnables; 4366089e4ec4f1702caf2154780471417872862148caryclark@google.com skiatest::Reporter* fReporter; 4466089e4ec4f1702caf2154780471417872862148caryclark@google.com}; 4566089e4ec4f1702caf2154780471417872862148caryclark@google.com 46048494c1e236c4db9d18952de83d2602c1abc7c3mtkleinclass PathOpsThreadedRunnable { 4766089e4ec4f1702caf2154780471417872862148caryclark@google.compublic: 4866089e4ec4f1702caf2154780471417872862148caryclark@google.com PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int a, int b, int c, int d, 4966089e4ec4f1702caf2154780471417872862148caryclark@google.com PathOpsThreadedTestRunner* runner) { 5066089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fA = a; 5166089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fB = b; 5266089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fC = c; 5366089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fD = d; 5466089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fReporter = runner->fReporter; 5566089e4ec4f1702caf2154780471417872862148caryclark@google.com fTestFun = testFun; 5666089e4ec4f1702caf2154780471417872862148caryclark@google.com } 5766089e4ec4f1702caf2154780471417872862148caryclark@google.com 5807e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), const char* str, 5907e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com PathOpsThreadedTestRunner* runner) { 6007e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1); 6107e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com strcpy(fState.fSerialNo, str); 6207e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com fState.fReporter = runner->fReporter; 6307e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com fTestFun = testFun; 6407e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com } 6507e97fccd2d85076cd22ef411b0773ab92a18abecaryclark@google.com 66a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com PathOpsThreadedRunnable(void (*testFun)(PathOpsThreadState*), int dirNo, const char* str, 67a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com PathOpsThreadedTestRunner* runner) { 68a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com SkASSERT(strlen(str) < sizeof(fState.fSerialNo) - 1); 69a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com fState.fA = dirNo; 70a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com strcpy(fState.fSerialNo, str); 71a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com fState.fReporter = runner->fReporter; 72a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com fTestFun = testFun; 73a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com } 74a2bbc6e19d5332e81784e582c290cc060f40c4c7caryclark@google.com 75048494c1e236c4db9d18952de83d2602c1abc7c3mtklein void operator()() { 7666089e4ec4f1702caf2154780471417872862148caryclark@google.com SkBitmap bitmap; 7766089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fBitmap = &bitmap; 7866089e4ec4f1702caf2154780471417872862148caryclark@google.com char pathStr[PATH_STR_SIZE]; 7966089e4ec4f1702caf2154780471417872862148caryclark@google.com fState.fPathStr = pathStr; 807eaa53d8f7e48fd17d02b5e3bd91f90e9c1899efcaryclark@google.com SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); 8166089e4ec4f1702caf2154780471417872862148caryclark@google.com (*fTestFun)(&fState); 8266089e4ec4f1702caf2154780471417872862148caryclark@google.com } 8366089e4ec4f1702caf2154780471417872862148caryclark@google.com 8466089e4ec4f1702caf2154780471417872862148caryclark@google.comprivate: 8566089e4ec4f1702caf2154780471417872862148caryclark@google.com PathOpsThreadState fState; 8666089e4ec4f1702caf2154780471417872862148caryclark@google.com void (*fTestFun)(PathOpsThreadState*); 8766089e4ec4f1702caf2154780471417872862148caryclark@google.com}; 8866089e4ec4f1702caf2154780471417872862148caryclark@google.com 8966089e4ec4f1702caf2154780471417872862148caryclark@google.com#endif 90