Stub a benchmarking tool, not working yet

This commit is contained in:
Patrick Walton 2017-09-11 11:22:19 -07:00
parent bd3536d058
commit 068e2bd99e
6 changed files with 89 additions and 1 deletions

View File

@ -27,7 +27,7 @@
.pf-toolbar-button {
pointer-events: auto;
}
.pf-toolbar-button:not(:hover) {
.pf-toolbar-button.btn-outline-secondary:not(:hover) {
background: rgba(255, 255, 255, 0.75);
}
#pf-file-select {

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Benchmark &mdash; Pathfinder</title>
<meta charset="utf-8">
{{>partials/header.html}}
<script type="text/javascript" src="/js/pathfinder/benchmark.js"></script>
</head>
<body>
{{>partials/navbar.html isTool=true}}
<div class="fixed-bottom mb-3 d-flex justify-content-end align-items-end pf-pointer-events-none">
<div id="pf-toolbar">
<button id="pf-run-benchmark-button" type="button"
class="btn btn-primary pf-toolbar-button">
Run Benchmark
</button>
</div>
</div>
</body>
</html>

View File

@ -18,6 +18,7 @@
<a class="nav-link dropdown-toggle" id="pf-tools-menu" data-toggle="dropdown"
ref="/" aria-haspopup="true" aria-expanded="false">Tools</a>
<div class="dropdown-menu" aria-labelledby="pf-tools-menu">
<a class="dropdown-item" href="/tools/benchmark">Benchmark</a>
<a class="dropdown-item" href="/tools/mesh-debugger">Mesh Debugger</a>
</div>
</li>

View File

@ -0,0 +1,59 @@
// pathfinder/client/src/benchmark.ts
//
// Copyright © 2017 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
import * as opentype from "opentype.js";
import {AppController} from "./app-controller";
import {PathfinderMeshData} from "./meshes";
import {BUILTIN_FONT_URI, GlyphStorage, PathfinderGlyph, TextFrame, TextRun} from "./text";
import {assert, unwrapNull} from "./utils";
const STRING: string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const FONT: string = 'nimbus-sans';
class BenchmarkAppController extends AppController {
start() {
super.start();
const runBenchmarkButton = unwrapNull(document.getElementById('pf-run-benchmark-button'));
runBenchmarkButton.addEventListener('click', () => this.runBenchmark(), false);
this.loadInitialFile();
}
protected fileLoaded(): void {
const font = opentype.parse(this.fileData);
assert(font.isSupported(), "The font type is unsupported!");
const createGlyph = (glyph: opentype.Glyph) => new BenchmarkGlyph(glyph);
const textRun = new TextRun<BenchmarkGlyph>(STRING, [0, 0], font, createGlyph);
const textFrame = new TextFrame([textRun]);
this.glyphStorage = new GlyphStorage(this.fileData, [textFrame], createGlyph, font);
this.glyphStorage.partition().then(meshes => {
this.meshes = meshes;
// TODO(pcwalton)
// this.renderer.attachMeshes();
})
}
private runBenchmark(): void {
// TODO(pcwalton)
}
protected readonly defaultFile: string = FONT;
protected readonly builtinFileURI: string = BUILTIN_FONT_URI;
private glyphStorage: GlyphStorage<BenchmarkGlyph>;
private meshes: PathfinderMeshData;
}
class BenchmarkGlyph extends PathfinderGlyph {}

View File

@ -8,6 +8,7 @@ module.exports = {
'3d-demo': "./src/3d-demo.ts",
'svg-demo': "./src/svg-demo.ts",
'text-demo': "./src/text-demo.ts",
'benchmark': "./src/benchmark.ts",
'mesh-debugger': "./src/mesh-debugger.ts",
},
module: {

View File

@ -43,6 +43,7 @@ static STATIC_INDEX_PATH: &'static str = "../client/index.html";
static STATIC_TEXT_DEMO_PATH: &'static str = "../client/text-demo.html";
static STATIC_SVG_DEMO_PATH: &'static str = "../client/svg-demo.html";
static STATIC_3D_DEMO_PATH: &'static str = "../client/3d-demo.html";
static STATIC_TOOLS_BENCHMARK_PATH: &'static str = "../client/benchmark.html";
static STATIC_TOOLS_MESH_DEBUGGER_PATH: &'static str = "../client/mesh-debugger.html";
static STATIC_DOC_API_PATH: &'static str = "../../font-renderer/target/doc";
static STATIC_CSS_BOOTSTRAP_PATH: &'static str = "../client/node_modules/bootstrap/dist/css";
@ -539,6 +540,10 @@ fn static_demo_svg() -> io::Result<NamedFile> {
fn static_demo_3d() -> io::Result<NamedFile> {
NamedFile::open(STATIC_3D_DEMO_PATH)
}
#[get("/tools/benchmark")]
fn static_tools_benchmark() -> io::Result<NamedFile> {
NamedFile::open(STATIC_TOOLS_BENCHMARK_PATH)
}
#[get("/tools/mesh-debugger")]
fn static_tools_mesh_debugger() -> io::Result<NamedFile> {
NamedFile::open(STATIC_TOOLS_MESH_DEBUGGER_PATH)
@ -634,6 +639,7 @@ fn main() {
static_demo_text,
static_demo_svg,
static_demo_3d,
static_tools_benchmark,
static_tools_mesh_debugger,
static_doc_api_index,
static_doc_api,