#include #include using namespace v8; static Isolate *isolate; extern "C" { void texsynth_inpaint(int w, int h, void *output_ptr, void *image_ptr, void *mask_ptr, bool tiling); } namespace { void krom_texsynth_inpaint(const FunctionCallbackInfo &args) { HandleScope scope(args.GetIsolate()); int32_t w = args[0]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value(); int32_t h = args[1]->ToInt32(isolate->GetCurrentContext()).ToLocalChecked()->Value(); Local bufferOut = Local::Cast(args[2]); std::shared_ptr contentOut = bufferOut->GetBackingStore(); Local bufferImage = Local::Cast(args[3]); std::shared_ptr contentImage = bufferImage->GetBackingStore(); Local bufferMask = Local::Cast(args[4]); std::shared_ptr contentMask = bufferMask->GetBackingStore(); bool tiling = args[5]->ToBoolean(isolate)->Value(); texsynth_inpaint(w, h, contentOut->Data(), contentImage->Data(), contentMask->Data(), tiling); } } #define SET_FUNCTION(object, name, fn)\ object->Set(String::NewFromUtf8(isolate, name).ToLocalChecked(),\ FunctionTemplate::New(isolate, fn, Local(), Local(), 0,\ v8::ConstructorBehavior::kThrow, v8::SideEffectType::kHasNoSideEffect, nullptr)) void plugin_embed(Isolate *_isolate, Local global) { isolate = _isolate; Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); Local krom_texsynth = ObjectTemplate::New(isolate); SET_FUNCTION(krom_texsynth, "inpaint", krom_texsynth_inpaint); global->Set(String::NewFromUtf8(isolate, "Krom_texsynth").ToLocalChecked(), krom_texsynth); }