Commit 1da66b06 authored by Nikolay Igotti's avatar Nikolay Igotti

Simple wrapper for one function.

parent 81ed0544
......@@ -556,7 +556,6 @@ val skikoJvmRuntimeJar by project.tasks.registering(Jar::class) {
project.tasks.register<Jar>("skikoJsJar") {
// We produce jar that contains .js of wrapper/bindings and .wasm with Skia + bindings.
from(kotlin.js().compilations["main"].output.allOutputs)
from(project.tasks.named("wasmCompile").get().outputs)
from(project.tasks.named("jsJar").get().outputs)
archiveBaseName.set("skiko-wasm")
......
#include "GrBackendSurface.h"
#include <emscripten.h>
typedef int32_t jint;
typedef int64_t jlong;
static void deleteBackendRenderTarget(GrBackendRenderTarget* rt) {
delete rt;
}
EMSCRIPTEN_KEEPALIVE
extern "C" long BackendRenderTarget_nGetFinalizer() {
return static_cast<jlong>(reinterpret_cast<uintptr_t>(&deleteBackendRenderTarget));
}
EMSCRIPTEN_KEEPALIVE
extern "C" long BackendRenderTarget_nMakeGL
(jint width, jint height, jint sampleCnt, jint stencilBits, jint fbId, jint fbFormat) {
GrGLFramebufferInfo glInfo = { static_cast<unsigned int>(fbId), static_cast<unsigned int>(fbFormat) };
GrBackendRenderTarget* instance = new GrBackendRenderTarget(width, height, sampleCnt, stencilBits, glInfo);
return reinterpret_cast<jlong>(instance);
}
EMSCRIPTEN_KEEPALIVE
extern "C" long BackendRenderTarget_nMakeMetal
(jint width, jint height, jlong texturePtr) {
#ifdef SK_METAL
GrMTLHandle texture = reinterpret_cast<GrMTLHandle>(static_cast<uintptr_t>(texturePtr));
GrMtlTextureInfo fbInfo;
fbInfo.fTexture.retain(texture);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(width, height, fbInfo);
return reinterpret_cast<jlong>(instance);
#else
return 0;
#endif
}
#ifdef SK_DIRECT3D
#include "d3d/GrD3DTypes.h"
#endif
EMSCRIPTEN_KEEPALIVE
extern "C" jlong BackendRenderTarget_MakeDirect3D
(jint width, jint height, jlong texturePtr, jint format, jint sampleCnt, jint levelCnt) {
#ifdef SK_DIRECT3D
GrD3DTextureResourceInfo texResInfo = {};
ID3D12Resource* resource = reinterpret_cast<ID3D12Resource*>(static_cast<uintptr_t>(texturePtr));
texResInfo.fResource.retain(resource);
texResInfo.fResourceState = D3D12_RESOURCE_STATE_COMMON;
texResInfo.fFormat = static_cast<DXGI_FORMAT>(format);
texResInfo.fSampleCount = static_cast<uint32_t>(sampleCnt);
texResInfo.fLevelCount = static_cast<uint32_t>(levelCnt);
GrBackendRenderTarget* instance = new GrBackendRenderTarget(width, height, texResInfo);
return reinterpret_cast<jlong>(instance);
#else
return 0;
#endif
}
\ No newline at end of file
#include "GrBackendSurface.h"
#include "GrDirectContext.h"
#include <emscripten.h>
void* init_surface() {
EMSCRIPTEN_KEEPALIVE
extern "C" void* init_surface() {
return nullptr;
}
......
#include <iostream>
#include <jni.h>
#include <stdint.h>
#include "GrBackendSurface.h"
typedef jint int32_t;
typedef jlong int64_t;
static void deleteBackendRenderTarget(GrBackendRenderTarget* rt) {
delete rt;
}
......@@ -29,14 +32,13 @@ extern "C" jlong BackendRenderTarget_nMakeMetal
return 0;
#endif
}
#endif
#ifdef SK_DIRECT3D
#include "d3d/GrD3DTypes.h"
#endif
extern "C" jlong BackendRenderTarget_MakeDirect3D
(jint width, jint height, jlong texturePtr, jint format, jint sampleCnt, jint levelCnt) {#ifdef SK_DIRECT3D
(jint width, jint height, jlong texturePtr, jint format, jint sampleCnt, jint levelCnt) {
#ifdef SK_DIRECT3D
GrD3DTextureResourceInfo texResInfo = {};
ID3D12Resource* resource = reinterpret_cast<ID3D12Resource*>(static_cast<uintptr_t>(texturePtr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment