More work on the integration test

This commit is contained in:
Patrick Walton 2017-11-13 17:23:03 -08:00
parent 9dda148b38
commit 2578298198
3 changed files with 38 additions and 3 deletions

View File

@ -28,7 +28,7 @@
</div> </div>
</form> </form>
</div> </div>
<canvas id="pf-reference-pane" class="pf-draggable pf-pane col" width="300" <canvas id="pf-reference-canvas" class="pf-draggable pf-pane col" width="300"
height="400"> height="400">
</canvas> </canvas>
<canvas id="pf-canvas" class="pf-draggable pf-pane col" width="300" <canvas id="pf-canvas" class="pf-draggable pf-pane col" width="300"

View File

@ -36,6 +36,8 @@ const ANTIALIASING_STRATEGIES: AntialiasingStrategyTable = {
const STRING: string = "A"; const STRING: string = "A";
const RENDER_REFERENCE_URI: string = "/render-reference";
interface AntialiasingStrategyTable { interface AntialiasingStrategyTable {
none: typeof NoAAStrategy; none: typeof NoAAStrategy;
ssaa: typeof SSAAStrategy; ssaa: typeof SSAAStrategy;
@ -53,9 +55,14 @@ class IntegrationTestAppController extends DemoAppController<IntegrationTestView
private baseMeshes: PathfinderMeshData; private baseMeshes: PathfinderMeshData;
private expandedMeshes: ExpandedMeshData; private expandedMeshes: ExpandedMeshData;
private referenceCanvas: HTMLCanvasElement;
start(): void { start(): void {
super.start(); super.start();
this.referenceCanvas = unwrapNull(document.getElementById('pf-reference-canvas')) as
HTMLCanvasElement;
this.loadInitialFile(this.builtinFileURI); this.loadInitialFile(this.builtinFileURI);
} }
@ -89,6 +96,32 @@ class IntegrationTestAppController extends DemoAppController<IntegrationTestView
view.attachMeshes([expandedMeshes.meshes]); view.attachMeshes([expandedMeshes.meshes]);
}); });
}); });
this.loadInitialReference();
}
private loadInitialReference(): void {
const request = {
face: {
Builtin: unwrapNull(this.font).builtinFontName,
},
fontIndex: 0,
glyph: this.glyphStore.glyphIDs[0],
pointSize: 32.0,
};
window.fetch(RENDER_REFERENCE_URI, {
body: JSON.stringify(request),
headers: {'Content-Type': 'application/json'} as any,
method: 'POST',
}).then(response => response.blob()).then(blob => {
const imgElement = document.createElement('img');
imgElement.src = URL.createObjectURL(blob);
imgElement.addEventListener('load', () => {
const context = unwrapNull(this.referenceCanvas.getContext('2d'));
context.drawImage(imgElement, 0, 0);
}, false);
});
} }
} }
@ -226,7 +259,9 @@ class IntegrationTestRenderer extends Renderer {
aaLevel: number, aaLevel: number,
subpixelAA: SubpixelAAType): subpixelAA: SubpixelAAType):
AntialiasingStrategy { AntialiasingStrategy {
return new (ANTIALIASING_STRATEGIES[aaType])(aaLevel, subpixelAA); // FIXME(pcwalton)
// return new (ANTIALIASING_STRATEGIES[aaType])(aaLevel, subpixelAA);
return new ANTIALIASING_STRATEGIES.xcaa(aaLevel, 'medium');
} }
protected compositeIfNecessary(): void {} protected compositeIfNecessary(): void {}

View File

@ -256,7 +256,7 @@ export class GlyphStore {
let time = 0; let time = 0;
return window.fetch(PARTITION_FONT_ENDPOINT_URI, { return window.fetch(PARTITION_FONT_ENDPOINT_URI, {
body: JSON.stringify(request), body: JSON.stringify(request),
headers: {'Content-Type': 'application/json'}, headers: {'Content-Type': 'application/json'} as any,
method: 'POST', method: 'POST',
}).then(response => { }).then(response => {
time = parseServerTiming(response.headers); time = parseServerTiming(response.headers);