0039874105
In this CL, I forked compile.sh and created a new gm_bindings.cpp. I also moved viewer.html into wasm_tools and created a gmtests.html for testing out the bindings locally. Right now there is only one gm file compiled in. I plan in a followup CL to have some way to generate the list of cpp files that need to be compiled in from gms.gni. I was unable to get it to work with simply linking the lib_gm.gni, probably due to the same issue with Registry that csmartdalton@ ran into when adding viewer.html and the associated bindings. Suggested reviewing order: - gmtests.html to get a sense of how the test flow works. - gm_bindings.cpp to make sure I setup the contexts/GMs correctly. - compile_gm.sh to see how the gms are compiled in. - The remaining files in any order. When I tested this locally, the bleed_downscale digest was exactly the same (pixel for pixel, byte for byte) as a known digest in Gold, so I'm fairly confident in how things work. Change-Id: I2babef848ca60f7db74e4adf27b8952a66bdeee1 Bug: skia:10812 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322956 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Kevin Lubick <kjlubick@google.com>
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// When this file is loaded in, the high level object is "Module";
|
|
var WasmGMTests = Module;
|
|
WasmGMTests.onRuntimeInitialized = function() {
|
|
|
|
WasmGMTests.GetWebGLContext = function(canvas, webGLVersion) {
|
|
if (!canvas) {
|
|
throw 'null canvas passed into makeWebGLContext';
|
|
}
|
|
if (webGLVersion !== 1 && webGLVersion !== 2 ) {
|
|
throw 'invalid webGLVersion';
|
|
}
|
|
var contextAttributes = {
|
|
'alpha': 1,
|
|
'depth': 0, // can be 0 because off-screen.
|
|
'stencil': 0, // can be 0 because off-screen.
|
|
'antialias': 0,
|
|
'premultipliedAlpha': 1,
|
|
'preserveDrawingBuffer': 0,
|
|
'preferLowPowerToHighPerformance': 0,
|
|
'failIfMajorPerformanceCaveat': 0,
|
|
'enableExtensionsByDefault': 1,
|
|
'explicitSwapControl': 0,
|
|
'renderViaOffscreenBackBuffer': 0,
|
|
'majorVersion': webGLVersion,
|
|
};
|
|
|
|
// Creates a WebGL context and sets it to be the current context.
|
|
// These functions are defined in emscripten's library_webgl.js
|
|
var handle = GL.createContext(canvas, contextAttributes);
|
|
if (!handle) {
|
|
return 0;
|
|
}
|
|
GL.makeContextCurrent(handle);
|
|
return handle;
|
|
};
|
|
|
|
}
|