10#include <emscripten.h>
11#include <emscripten/bind.h>
12#include <emscripten/html5.h>
46 JSArray gms = emscripten::val::array();
48 std::unique_ptr<skiagm::GM> gm(fact());
49 SkDebugf(
"gm %s\n", gm->getName().c_str());
50 gms.call<
void>(
"push", std::string(gm->getName().c_str()));
57 std::unique_ptr<skiagm::GM> gm(fact());
58 if (gm->getName().c_str() ==
name) {
71 EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
73 printf(
"failed to make webgl context current %d\n", r);
101 const uint8_t* bytes =
reinterpret_cast<const uint8_t*
>(bPtr);
120 SkDebugf(
"Could not find gm with name %s\n",
name.c_str());
126 auto colorType = SkColorType::kN32_SkColorType;
132 SkDebugf(
"Could not make surface\n");
135 auto canvas =
surface->getCanvas();
137 gm->onceBeforeDraw();
140 auto gpuSetupResult = gm->gpuSetup(canvas, &msg);
148 auto drawResult = gm->draw(canvas, &msg);
160 if (!canvas->readPixels(
bitmap, 0, 0)) {
161 SkDebugf(
"Could not read pixels back\n");
167 std::unique_ptr<HashAndEncode> hashAndEncode = std::make_unique<HashAndEncode>(
bitmap);
170 hashAndEncode->feedHash(&
hash);
172 for (
int i = 0;
i < 16;
i++) {
173 md5.appendf(
"%02x", digest.
data[
i]);
193 typed_memory_view(
data->size(),
data->bytes())
196 result.set(
"png", pngData);
208 tests.call<
void>(
"push", std::string(
test.fName));
230 fResult.set(
"result",
"failed");
248 SkDebugf(
"Could not find test with name %s\n",
name.c_str());
253 result.set(
"result",
"passed");
255 test.modifyGrContextOptions(&grOpts);
259 SkDebugf(
"Graphite test %s not yet supported\n",
name.c_str());
263 result.set(
"result",
"passed");
289 if (filter && !(*filter)(contextType)) {
316 WasmWebGlTestContext() {}
317 ~WasmWebGlTestContext()
override {
323 std::unique_ptr<GLTestContext>
makeNew()
const override {
342 return new WasmWebGlTestContext();
362 class_<GrDirectContext>(
"GrDirectContext")
static SkMD5::Digest md5(const SkBitmap &bm)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SK_API sk_sp< const GrGLInterface > GrGLMakeNativeInterface()
@ kBottomLeft_GrSurfaceOrigin
sk_sp< SkData >(* gResourceFactory)(const char *)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static bool ok(int result)
static uint32_t hash(const SkShaderBase::GradientInfo &v)
#define REPORTER_ASSERT(r, cond,...)
emscripten::val Uint8Array
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
const char * c_str() const
GrDirectContext * directContext() const
TestContext * testContext() const
virtual std::unique_ptr< GLTestContext > makeNew() const
virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const =0
virtual std::function< void()> onPlatformGetAutoContextRestore() const =0
virtual void onPlatformMakeNotCurrent() const =0
virtual void onPlatformMakeCurrent() const =0
EMSCRIPTEN_KEEPALIVE void empty()
Dart_NativeFunction function
static std::unique_ptr< skiagm::GM > getGMWithName(std::string name)
static std::map< std::string, sk_sp< SkData > > gResources
static std::set< std::string > gKnownDigests
static sk_sp< SkData > getResource(const char *name)
static void LoadKnownDigest(std::string md5)
static JSArray ListTests()
static sk_sp< GrDirectContext > MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
TestHarness CurrentTestHarness()
static skiatest::Test getTestWithName(std::string name, bool *ok)
static JSObject RunGM(sk_sp< GrDirectContext > ctx, std::string name)
static JSObject RunTest(std::string name)
static void LoadResource(std::string name, WASMPointerU8 bPtr, size_t len)
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
GLTestContext * CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, GLTestContext *shareContext)
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
@ kMock
Dawn on OpenGL ES.
std::function< std::unique_ptr< skiagm::GM >()> GMFactory
void RunWithGaneshTestContexts(GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)
bool IsMetalContextType(skgpu::ContextType type)
bool IsGLContextType(skgpu::ContextType type)
bool ContextTypeFilterFn(GpuContextType)
bool IsMockContextType(skgpu::ContextType type)
bool IsDirect3DContextType(skgpu::ContextType type)
void GrContextTestFn(Reporter *, const sk_gpu_test::ContextInfo &)
bool IsDawnContextType(skgpu::ContextType type)
bool IsVulkanContextType(skgpu::ContextType type)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
void reportFailed(const skiatest::Failure &failure) override
WasmReporter(std::string name, JSObject result)
SkString toString() const
static Test MakeCPU(const char *name, CPUTestProc proc)
std::shared_ptr< const fml::Mapping > data