1aeca6fd0e
* feat: GPU shared texture offscreen rendering * docs: clarify texture infos that passed by the paint event. * feat: make gpu osr spec test optional * fix: osr image compare * fix: remove duplicate test * fix: update patch file * fix: code review * feat: expose more metadata * feat: use better switch design * feat: add warning when user forget to release the texture. * fix: typo * chore: update patch * fix: update patch * fix: update patch description * fix: update docs * fix: apply suggestions from code review Co-authored-by: Charles Kerr <charles@charleskerr.com> * fix: apply suggested fixes --------- Co-authored-by: Charles Kerr <charles@charleskerr.com>
33 lines
No EOL
1.8 KiB
C++
33 lines
No EOL
1.8 KiB
C++
#define NAPI_CREATE_STRING(str) \
|
|
[&]() { \
|
|
napi_value value; \
|
|
napi_create_string_utf8(env, str, NAPI_AUTO_LENGTH, &value); \
|
|
return value; \
|
|
}()
|
|
|
|
#define NAPI_GET_PROPERTY_VALUE(obj, field) \
|
|
[&]() { \
|
|
napi_value value; \
|
|
napi_get_property(env, obj, NAPI_CREATE_STRING(field), &value); \
|
|
return value; \
|
|
}()
|
|
|
|
#define NAPI_GET_PROPERTY_VALUE_STRING(obj, field) \
|
|
[&]() { \
|
|
auto val = NAPI_GET_PROPERTY_VALUE(obj, field); \
|
|
size_t size; \
|
|
napi_get_value_string_utf8(env, val, nullptr, 0, &size); \
|
|
char* buffer = new char[size + 1]; \
|
|
napi_get_value_string_utf8(env, val, buffer, size + 1, &size); \
|
|
return std::string(buffer); \
|
|
}()
|
|
|
|
#define NAPI_GET_PROPERTY_VALUE_BUFFER(obj, field) \
|
|
[&]() { \
|
|
auto val = NAPI_GET_PROPERTY_VALUE(obj, field); \
|
|
size_t size; \
|
|
napi_create_buffer(env, val, nullptr, 0, &size); \
|
|
char* buffer = new char[size + 1]; \
|
|
napi_get_value_string_utf8(env, val, buffer, size + 1, &size); \
|
|
return std::string(buffer); \
|
|
}() |