| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
| 10 #include "SkTestScalerContext.h" | 10 #include "SkTestScalerContext.h" |
| 11 #include "SkThread.h" | 11 #include "SkThread.h" |
| 12 #include "SkUtils.h" | 12 #include "SkUtils.h" |
| 13 #include "sk_tool_utils.h" | 13 #include "sk_tool_utils.h" |
| 14 | 14 |
| 15 namespace sk_tool_utils { | 15 namespace sk_tool_utils { |
| 16 | 16 |
| 17 #include "test_font_data.cpp" | 17 #include "test_font_data.cpp" |
| 18 | 18 |
| 19 static void release_portable_typefaces() { | 19 static void release_portable_typefaces() { |
| 20 // We'll clean this up in our own tests, but disable for clients. | 20 // We'll clean this up in our own tests, but disable for clients. |
| 21 // Chrome seems to have funky multi-process things going on in unit tests th
at | 21 // Chrome seems to have funky multi-process things going on in unit tests th
at |
| 22 // makes this unsafe to delete when the main process atexit()s. | 22 // makes this unsafe to delete when the main process atexit()s. |
| 23 // SkLazyPtr does the same sort of thing. | 23 // SkLazyPtr does the same sort of thing. |
| 24 #if SK_DEVELOPER | 24 #if SK_DEVELOPER |
| 25 for (unsigned index = 0; index < gTestFontsCount; ++index) { | 25 for (int index = 0; index < gTestFontsCount; ++index) { |
| 26 SkTestFontData& fontData = gTestFonts[index]; | 26 SkTestFontData& fontData = gTestFonts[index]; |
| 27 SkSafeUnref(fontData.fFontCache); | 27 SkSafeUnref(fontData.fFontCache); |
| 28 } | 28 } |
| 29 #endif | 29 #endif |
| 30 } | 30 } |
| 31 | 31 |
| 32 SK_DECLARE_STATIC_MUTEX(gTestFontMutex); | 32 SK_DECLARE_STATIC_MUTEX(gTestFontMutex); |
| 33 | 33 |
| 34 SkTypeface* create_font(const char* name, SkTypeface::Style style) { | 34 SkTypeface* create_font(const char* name, SkTypeface::Style style) { |
| 35 SkTestFontData* fontData = NULL; | 35 SkTestFontData* fontData = NULL; |
| 36 const SubFont* sub; | 36 const SubFont* sub; |
| 37 if (name) { | 37 if (name) { |
| 38 for (unsigned index = 0; index < gSubFontsCount; ++index) { | 38 for (int index = 0; index < gSubFontsCount; ++index) { |
| 39 sub = &gSubFonts[index]; | 39 sub = &gSubFonts[index]; |
| 40 if (!strcmp(name, sub->fName) && sub->fStyle == style) { | 40 if (!strcmp(name, sub->fName) && sub->fStyle == style) { |
| 41 fontData = &sub->fFont; | 41 fontData = &sub->fFont; |
| 42 break; | 42 break; |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 if (!fontData) { | 45 if (!fontData) { |
| 46 SkDebugf("missing %s %d\n", name, style); | 46 SkDebugf("missing %s %d\n", name, style); |
| 47 return SkTypeface::CreateFromName(name, style); | 47 return SkTypeface::CreateFromName(name, style); |
| 48 } | 48 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 atexit(release_portable_typefaces); | 63 atexit(release_portable_typefaces); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 return SkNEW_ARGS(SkTestTypeface, (font, style)); | 66 return SkNEW_ARGS(SkTestTypeface, (font, style)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 SkTypeface* resource_font(const char* name, SkTypeface::Style style) { | 70 SkTypeface* resource_font(const char* name, SkTypeface::Style style) { |
| 71 const char* file = NULL; | 71 const char* file = NULL; |
| 72 if (name) { | 72 if (name) { |
| 73 for (unsigned index = 0; index < gSubFontsCount; ++index) { | 73 for (int index = 0; index < gSubFontsCount; ++index) { |
| 74 const SubFont& sub = gSubFonts[index]; | 74 const SubFont& sub = gSubFonts[index]; |
| 75 if (!strcmp(name, sub.fName) && sub.fStyle == style) { | 75 if (!strcmp(name, sub.fName) && sub.fStyle == style) { |
| 76 file = sub.fFile; | 76 file = sub.fFile; |
| 77 break; | 77 break; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 if (!file) { | 80 if (!file) { |
| 81 return SkTypeface::CreateFromName(name, style); | 81 return SkTypeface::CreateFromName(name, style); |
| 82 } | 82 } |
| 83 } else { | 83 } else { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 break; | 169 break; |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 fprintf(out, ";\n"); | 172 fprintf(out, ";\n"); |
| 173 } | 173 } |
| 174 fclose(out); | 174 fclose(out); |
| 175 } | 175 } |
| 176 #endif | 176 #endif |
| 177 | 177 |
| 178 } | 178 } |
| OLD | NEW |