Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: dm/DM.cpp

Issue 1163283002: update portable fonts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update font creation code Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gm/aaxfermodes.cpp » ('j') | include/core/SkTypeface.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "DMJsonWriter.h" 9 #include "DMJsonWriter.h"
10 #include "DMSrcSink.h" 10 #include "DMSrcSink.h"
11 #include "DMSrcSinkAndroid.h" 11 #include "DMSrcSinkAndroid.h"
12 #include "OverwriteLine.h" 12 #include "OverwriteLine.h"
13 #include "ProcStats.h" 13 #include "ProcStats.h"
14 #include "SkBBHFactory.h" 14 #include "SkBBHFactory.h"
15 #include "SkChecksum.h" 15 #include "SkChecksum.h"
16 #include "SkCommonFlags.h" 16 #include "SkCommonFlags.h"
17 #include "SkFontMgr.h"
17 #include "SkForceLinking.h" 18 #include "SkForceLinking.h"
18 #include "SkGraphics.h" 19 #include "SkGraphics.h"
19 #include "SkInstCnt.h" 20 #include "SkInstCnt.h"
20 #include "SkMD5.h" 21 #include "SkMD5.h"
21 #include "SkOSFile.h" 22 #include "SkOSFile.h"
22 #include "SkTHash.h" 23 #include "SkTHash.h"
23 #include "SkTaskGroup.h" 24 #include "SkTaskGroup.h"
24 #include "SkThreadUtils.h" 25 #include "SkThreadUtils.h"
25 #include "Test.h" 26 #include "Test.h"
26 #include "Timer.h" 27 #include "Timer.h"
28 #include "sk_tool_utils.h"
27 29
28 DEFINE_string(src, "tests gm skp image", "Source types to test."); 30 DEFINE_string(src, "tests gm skp image", "Source types to test.");
29 DEFINE_bool(nameByHash, false, 31 DEFINE_bool(nameByHash, false,
30 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " 32 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
31 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>. png"); 33 "to FLAGS_writePath[0]/<config>/<sourceType>/<sourceOptions>/<name>. png");
32 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); 34 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
33 DEFINE_string(matrix, "1 0 0 1", 35 DEFINE_string(matrix, "1 0 0 1",
34 "2x2 scale+skew matrix to apply or upright when using " 36 "2x2 scale+skew matrix to apply or upright when using "
35 "'matrix' or 'upright' in config."); 37 "'matrix' or 'upright' in config.");
36 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); 38 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 702 }
701 } 703 }
702 SkDebugf("\nCurrently running:%s\n", running.c_str()); 704 SkDebugf("\nCurrently running:%s\n", running.c_str());
703 } 705 }
704 } 706 }
705 }; 707 };
706 static SkThread* intentionallyLeaked = new SkThread(Loop::forever); 708 static SkThread* intentionallyLeaked = new SkThread(Loop::forever);
707 intentionallyLeaked->start(); 709 intentionallyLeaked->start();
708 } 710 }
709 711
712 #define PORTABLE_FONT_PREFIX "Toy Liberation "
713
714 static SkTypeface* CreateFromName(const char familyName[], SkTypeface::Style sty le) {
mtklein 2015/06/09 14:39:48 create_from_name?
caryclark 2015/06/09 16:37:21 Done.
715 if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX)
716 && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FO NT_PREFIX) - 1)) {
717 return sk_tool_utils::create_portable_typeface_always(familyName, st yle);
718 }
719 if (NULL == familyName) {
720 return SkTypeface::RefDefault(style);
721 }
722 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
723 return fm->legacyCreateTypeface(familyName, style);
724 }
725
726 #undef PORTABLE_FONT_PREFIX
727
728 void SetupPortableTypeface() {
729 SkTypeface::AddCreateDelegate(&CreateFromName);
mtklein 2015/06/09 14:39:48 Perhaps we could inline this into main.
caryclark 2015/06/09 16:37:21 Done.
730 }
731
710 int dm_main(); 732 int dm_main();
711 int dm_main() { 733 int dm_main() {
712 SetupCrashHandler(); 734 SetupCrashHandler();
713 SkAutoGraphics ag; 735 SkAutoGraphics ag;
714 SkTaskGroup::Enabler enabled(FLAGS_threads); 736 SkTaskGroup::Enabler enabled(FLAGS_threads);
715 if (FLAGS_leaks) { 737 if (FLAGS_leaks) {
716 SkInstCountPrintLeaksOnExit(); 738 SkInstCountPrintLeaksOnExit();
717 } 739 }
740 SetupPortableTypeface();
718 741
719 start_keepalive(); 742 start_keepalive();
720 743
721 gather_gold(); 744 gather_gold();
722 gather_uninteresting_hashes(); 745 gather_uninteresting_hashes();
723 746
724 gather_srcs(); 747 gather_srcs();
725 gather_sinks(); 748 gather_sinks();
726 gather_tests(); 749 gather_tests();
727 750
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 } 796 }
774 return 0; 797 return 0;
775 } 798 }
776 799
777 #if !defined(SK_BUILD_FOR_IOS) 800 #if !defined(SK_BUILD_FOR_IOS)
778 int main(int argc, char** argv) { 801 int main(int argc, char** argv) {
779 SkCommandLineFlags::Parse(argc, argv); 802 SkCommandLineFlags::Parse(argc, argv);
780 return dm_main(); 803 return dm_main();
781 } 804 }
782 #endif 805 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/aaxfermodes.cpp » ('j') | include/core/SkTypeface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698