diff options
author | Mike Klein <mtklein@chromium.org> | 2017-11-07 08:14:52 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-07 13:40:08 +0000 |
commit | 361dde006f1090fd55eff995b2c3f19e4254ff4f (patch) | |
tree | ad1e7c49e13ca75843b3c3e22796114297beec44 /tools | |
parent | 74f623d1617e0ccf3eddf37aeecabd0ac72369fd (diff) |
add DM::FontMgr to ok
The bots will still use DM, but the multiprocess architecture of ok
makes it easier to isolate and debug crashes, assertions, and unit
test failures.
Usage:
$ ninja -C out ok
$ out/ok test portable_fonts
...
935 ok, 4 failed, 5 crashed
...
Change-Id: I6bbd0ffc02d19bb5907c71eaebe30ac3646a80a6
Reviewed-on: https://skia-review.googlesource.com/68201
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ok_vias.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/tools/ok_vias.cpp b/tools/ok_vias.cpp index 815b159a01..162522346f 100644 --- a/tools/ok_vias.cpp +++ b/tools/ok_vias.cpp @@ -5,6 +5,7 @@ * found in the LICENSE file. */ +#include "../dm/DMFontMgr.h" #include "ProcStats.h" #include "SkColorFilter.h" #include "SkEventTracingPriv.h" @@ -266,7 +267,6 @@ struct Memory : Dst { }; static Register memory{"memory", "print process maximum memory usage", Memory::Create}; -static SkOnce init_tracing_once; struct Trace : Dst { std::unique_ptr<Dst> target; std::string trace_mode; @@ -279,7 +279,8 @@ struct Trace : Dst { } Status draw(Src* src) override { - init_tracing_once([&] { initializeEventTracingForTools(trace_mode.c_str()); }); + static SkOnce once; + once([&] { initializeEventTracingForTools(trace_mode.c_str()); }); return target->draw(src); } @@ -287,6 +288,35 @@ struct Trace : Dst { return target->image(); } }; -static Register trace {"trace", - "enable tracing in mode=atrace, mode=debugf, or mode=trace.json", - Trace::Create}; +static Register trace{"trace", + "enable tracing in mode=atrace, mode=debugf, or mode=trace.json", + Trace::Create}; + +extern sk_sp<SkFontMgr> (*gSkFontMgr_DefaultFactory)(); + +struct PortableFonts : Dst { + std::unique_ptr<Dst> target; + + static std::unique_ptr<Dst> Create(Options options, std::unique_ptr<Dst> dst) { + PortableFonts via; + via.target = std::move(dst); + return move_unique(via); + } + + Status draw(Src* src) override { + static SkOnce once; + once([]{ + gSkFontMgr_DefaultFactory = []() -> sk_sp<SkFontMgr> { + return sk_make_sp<DM::FontMgr>(); + }; + }); + return target->draw(src); + } + + sk_sp<SkImage> image() override { + return target->image(); + } +}; +static Register portable_fonts{"portable_fonts", + "use DM::FontMgr to make fonts more portable", + PortableFonts::Create}; |