OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 // #include "OverwriteLine.h" | 9 // #include "OverwriteLine.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkColor.h" | 13 #include "SkColor.h" |
14 #include "SkColorPriv.h" | 14 #include "SkColorPriv.h" |
15 #include "SkCommandLineFlags.h" | 15 #include "SkCommandLineFlags.h" |
16 #include "SkDevice.h" | 16 #include "SkDevice.h" |
17 #include "SkForceLinking.h" | 17 #include "SkForceLinking.h" |
18 #include "SkGraphics.h" | 18 #include "SkGraphics.h" |
19 #include "SkImageDecoder.h" | 19 #include "SkImageDecoder.h" |
20 #include "SkImageEncoder.h" | 20 #include "SkImageEncoder.h" |
21 #include "SkOSFile.h" | 21 #include "SkOSFile.h" |
22 #include "SkPathOpsDebug.h" | 22 #include "SkPathOpsDebug.h" |
23 #include "SkPicture.h" | 23 #include "SkPicture.h" |
24 #include "SkRTConf.h" | 24 #include "SkRTConf.h" |
25 #include "SkRunnable.h" | |
26 #include "SkTSort.h" | 25 #include "SkTSort.h" |
27 #include "SkStream.h" | 26 #include "SkStream.h" |
28 #include "SkString.h" | 27 #include "SkString.h" |
29 #include "SkTArray.h" | 28 #include "SkTArray.h" |
30 #include "SkTDArray.h" | 29 #include "SkTDArray.h" |
31 #include "SkTaskGroup.h" | 30 #include "SkTaskGroup.h" |
32 #include "SkTemplates.h" | 31 #include "SkTemplates.h" |
33 #include "SkTime.h" | 32 #include "SkTime.h" |
34 | 33 |
35 #include <stdlib.h> | 34 #include <stdlib.h> |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 SkTDArray<SortByTime> fSlowest; | 252 SkTDArray<SortByTime> fSlowest; |
254 TestResult fResult; | 253 TestResult fResult; |
255 }; | 254 }; |
256 | 255 |
257 struct TestRunner { | 256 struct TestRunner { |
258 ~TestRunner(); | 257 ~TestRunner(); |
259 void render(); | 258 void render(); |
260 SkTDArray<class TestRunnable*> fRunnables; | 259 SkTDArray<class TestRunnable*> fRunnables; |
261 }; | 260 }; |
262 | 261 |
263 class TestRunnable : public SkRunnable { | 262 class TestRunnable { |
264 public: | 263 public: |
265 void run() override { | 264 void operator()() { |
266 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); | 265 SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); |
267 (*fTestFun)(&fState); | 266 (*fTestFun)(&fState); |
268 } | 267 } |
269 | 268 |
270 TestState fState; | 269 TestState fState; |
271 void (*fTestFun)(TestState*); | 270 void (*fTestFun)(TestState*); |
272 }; | 271 }; |
273 | 272 |
274 | 273 |
275 class TestRunnableDir : public TestRunnable { | 274 class TestRunnableDir : public TestRunnable { |
(...skipping 22 matching lines...) Expand all Loading... |
298 } | 297 } |
299 }; | 298 }; |
300 | 299 |
301 TestRunner::~TestRunner() { | 300 TestRunner::~TestRunner() { |
302 for (int index = 0; index < fRunnables.count(); index++) { | 301 for (int index = 0; index < fRunnables.count(); index++) { |
303 delete fRunnables[index]; | 302 delete fRunnables[index]; |
304 } | 303 } |
305 } | 304 } |
306 | 305 |
307 void TestRunner::render() { | 306 void TestRunner::render() { |
308 // TODO: this doesn't really need to use SkRunnables any more. | |
309 // We can just write the code to run in the for-loop directly. | |
310 SkTaskGroup().batch(fRunnables.count(), [&](int i) { | 307 SkTaskGroup().batch(fRunnables.count(), [&](int i) { |
311 fRunnables[i]->run(); | 308 (*fRunnables[i])(); |
312 }); | 309 }); |
313 } | 310 } |
314 | 311 |
315 //////////////////////////////////////////////// | 312 //////////////////////////////////////////////// |
316 | 313 |
317 | 314 |
318 static int similarBits(const SkBitmap& gr, const SkBitmap& sk) { | 315 static int similarBits(const SkBitmap& gr, const SkBitmap& sk) { |
319 const int kRowCount = 3; | 316 const int kRowCount = 3; |
320 const int kThreshold = 3; | 317 const int kThreshold = 3; |
321 int width = SkTMin(gr.width(), sk.width()); | 318 int width = SkTMin(gr.width(), sk.width()); |
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 } | 1100 } |
1104 } | 1101 } |
1105 return 0; | 1102 return 0; |
1106 } | 1103 } |
1107 | 1104 |
1108 #if !defined(SK_BUILD_FOR_IOS) | 1105 #if !defined(SK_BUILD_FOR_IOS) |
1109 int main(int argc, char * const argv[]) { | 1106 int main(int argc, char * const argv[]) { |
1110 return tool_main(argc, (char**) argv); | 1107 return tool_main(argc, (char**) argv); |
1111 } | 1108 } |
1112 #endif | 1109 #endif |
OLD | NEW |