reed@google.com | b6a4b73 | 2012-05-21 15:27:23 +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 | |
| 8 | #include "Test.h" |
| 9 | #include "SkGraphics.h" |
| 10 | #include "SkPaint.h" |
| 11 | #include "SkTLS.h" |
| 12 | #include "SkThreadUtils.h" |
| 13 | |
| 14 | static void thread_main(void*) { |
| 15 | SkGraphics::SetTLSFontCacheLimit(1 * 1024 * 1024); |
| 16 | |
| 17 | const char text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| 18 | size_t len = strlen(text); |
| 19 | |
| 20 | SkPaint paint; |
| 21 | |
| 22 | for (int j = 0; j < 10; ++j) { |
| 23 | for (int i = 9; i <= 48; ++i) { |
| 24 | paint.setTextSize(SkIntToScalar(i)); |
| 25 | paint.setAntiAlias(false); |
| 26 | paint.measureText(text, len); |
| 27 | paint.setAntiAlias(true); |
| 28 | paint.measureText(text, len); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | static void test_measuretext(skiatest::Reporter* reporter) { |
| 34 | SkThread* threads[8]; |
| 35 | int N = SK_ARRAY_COUNT(threads); |
| 36 | int i; |
| 37 | |
| 38 | for (i = 0; i < N; ++i) { |
| 39 | threads[i] = new SkThread(thread_main); |
| 40 | } |
| 41 | |
| 42 | for (i = 0; i < N; ++i) { |
| 43 | threads[i]->start(); |
| 44 | } |
| 45 | |
| 46 | for (i = 0; i < N; ++i) { |
| 47 | threads[i]->join(); |
| 48 | } |
| 49 | |
| 50 | for (i = 0; i < N; ++i) { |
| 51 | delete threads[i]; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static void TestTLS(skiatest::Reporter* reporter) { |
| 56 | test_measuretext(reporter); |
| 57 | } |
| 58 | |
| 59 | #include "TestClassDef.h" |
epoger@google.com | f123ba9 | 2012-05-31 13:54:51 +0000 | [diff] [blame] | 60 | // TODO: Disabled for now to work around |
| 61 | // http://code.google.com/p/skia/issues/detail?id=619 |
| 62 | // ('flaky segfault in TLS test on Shuttle_Ubuntu12 buildbots') |
| 63 | // DEFINE_TESTCLASS("TLS", TLSClass, TestTLS) |