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>
This commit is contained in:
Mike Klein 2017-11-07 08:14:52 -05:00 committed by Skia Commit-Bot
parent 74f623d161
commit 361dde006f
2 changed files with 36 additions and 5 deletions

View File

@ -1363,6 +1363,7 @@ if (skia_enable_tools) {
test_app("ok") {
sources = [
"dm/DMFontMgr.cpp",
"tools/ok.cpp",
"tools/ok_dsts.cpp",
"tools/ok_engines.cpp",

View File

@ -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};