-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from callstack/feat/native-build
[wip] base setup for basis universal
- Loading branch information
Showing
97 changed files
with
53,664 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "externals/basis_universal"] | ||
path = externals/basis_universal | ||
url = https://github.com/BinomialLLC/basis_universal.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@rules_apple//apple:apple.bzl", "apple_static_xcframework") | ||
|
||
apple_static_xcframework( | ||
name = "rn_basis_universal", | ||
deps = ["@basis_universal"], | ||
ios = { | ||
"simulator": ["x86_64", "arm64"], | ||
"device": ["arm64"] | ||
}, | ||
minimum_os_versions = { | ||
"ios": "11.0" | ||
} | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,91 @@ | ||
#include "react-native-basis-universal.h" | ||
|
||
using namespace basist; | ||
using namespace basisu; | ||
|
||
namespace facebook::react { | ||
|
||
class BasisEncoder : public jsi::NativeState { | ||
public: | ||
basis_compressor_params m_params; | ||
}; | ||
|
||
std::shared_ptr<BasisEncoder> tryGetBasisEncoder(jsi::Runtime& rt, jsi::Object& basisEncoderObj) { | ||
if (!basisEncoderObj.hasNativeState(rt)) { | ||
return nullptr; | ||
} | ||
|
||
auto encoder = std::dynamic_pointer_cast<BasisEncoder>(basisEncoderObj.getNativeState(rt)); | ||
return encoder; | ||
} | ||
|
||
ReactNativeBasisUniversal::ReactNativeBasisUniversal(std::shared_ptr<CallInvoker> jsInvoker) | ||
: NativeBasisUniversalCxxSpecJSI(jsInvoker), _callInvoker(jsInvoker) {} | ||
|
||
double ReactNativeBasisUniversal::multiply(jsi::Runtime &rt, double a, double b) { | ||
return a * b; | ||
void ReactNativeBasisUniversal::initializeBasis(jsi::Runtime &rt) | ||
{ | ||
if (basis_initialized_flag) { | ||
return; | ||
} | ||
|
||
#if BASISU_SUPPORT_ENCODING | ||
basisu_encoder_init(); | ||
#endif | ||
|
||
basisu_transcoder_init(); | ||
|
||
basis_initialized_flag = true; | ||
} | ||
|
||
jsi::Object ReactNativeBasisUniversal::createBasisHandle(jsi::Runtime &rt) { | ||
jsi::Object basisObject{rt}; | ||
basisObject.setNativeState(rt, std::make_shared<BasisEncoder>()); | ||
return basisObject; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setDebug(jsi::Runtime &rt, jsi::Object handle, bool flag) { | ||
auto encoder = tryGetBasisEncoder(rt, handle); | ||
encoder->m_params.m_debug = flag; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setCreateKTX2File(jsi::Runtime &rt, jsi::Object handle, bool flag) { | ||
auto encoder = tryGetBasisEncoder(rt, handle); | ||
encoder->m_params.m_create_ktx2_file = flag; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setComputeStats(jsi::Runtime &rt, jsi::Object handle, bool flag) { | ||
auto encoder = tryGetBasisEncoder(rt, handle); | ||
encoder->m_params.m_compute_stats = flag; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setUASTC(jsi::Runtime &rt, jsi::Object handle, bool flag) { | ||
auto encoder = tryGetBasisEncoder(rt, handle); | ||
encoder->m_params.m_uastc = flag; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setKTX2UASTCSupercompression(jsi::Runtime &rt, jsi::Object handle, bool flag) { | ||
auto encoder = tryGetBasisEncoder(rt, handle); | ||
encoder->m_params.m_ktx2_uastc_supercompression = flag ? basist::KTX2_SS_ZSTANDARD : basist::KTX2_SS_NONE;; | ||
} | ||
|
||
void ReactNativeBasisUniversal::setQualityLevel(jsi::Runtime &rt, jsi::Object handle, int qualityLevel) { | ||
|
||
} | ||
|
||
void ReactNativeBasisUniversal::setSliceSourceImage(jsi::Runtime &rt, jsi::Object handle, int sliceIndex, jsi::Object imageArray, int width, int height, bool isPng) { | ||
if (imageArray.isArrayBuffer(rt)) { | ||
throw jsi::JSError(rt, "Image Array needs to be ArrayBuffer"); | ||
} | ||
auto arrayBuffer = imageArray.getArrayBuffer(rt); | ||
auto data = arrayBuffer.data(rt); | ||
} | ||
|
||
void ReactNativeBasisUniversal::setPackUASTCFlags(jsi::Runtime &rt, jsi::Object handle, int flags) { | ||
|
||
} | ||
|
||
void ReactNativeBasisUniversal::setCompressionLevel(jsi::Runtime &rt, jsi::Object handle, int level) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>AvailableLibraries</key> | ||
<array> | ||
<dict> | ||
<key>LibraryIdentifier</key> | ||
<string>ios-arm64</string> | ||
<key>LibraryPath</key> | ||
<string>rn_basis_universal.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>arm64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>ios</string> | ||
</dict> | ||
<dict> | ||
<key>LibraryIdentifier</key> | ||
<string>ios-arm64_x86_64-simulator</string> | ||
<key>LibraryPath</key> | ||
<string>rn_basis_universal.framework</string> | ||
<key>SupportedArchitectures</key> | ||
<array> | ||
<string>arm64</string> | ||
<string>x86_64</string> | ||
</array> | ||
<key>SupportedPlatform</key> | ||
<string>ios</string> | ||
<key>SupportedPlatformVariant</key> | ||
<string>simulator</string> | ||
</dict> | ||
</array> | ||
<key>CFBundlePackageType</key> | ||
<string>XFWK</string> | ||
<key>XCFrameworkFormatVersion</key> | ||
<string>1.0</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.