-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(🖼️): minor refactoring in platform context (#2795)
- Loading branch information
1 parent
cc15a30
commit 52f2e44
Showing
8 changed files
with
113 additions
and
74 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
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,53 @@ | ||
#pragma once | ||
|
||
#include <jsi/jsi.h> | ||
|
||
#include "RNSkPlatformContext.h" | ||
|
||
namespace jsi = facebook::jsi; | ||
namespace react = facebook::react; | ||
|
||
namespace RNSkia { | ||
|
||
namespace JsiTextureInfo { | ||
|
||
inline jsi::Value toValue(jsi::Runtime &runtime, const TextureInfo &texInfo) { | ||
jsi::Object textureInfo(runtime); | ||
textureInfo.setProperty( | ||
runtime, "mtlTexture", | ||
jsi::BigInt::fromUint64(runtime, | ||
reinterpret_cast<uint64_t>(texInfo.mtlTexture))); | ||
textureInfo.setProperty(runtime, "glTarget", | ||
static_cast<int>(texInfo.glTarget)); | ||
textureInfo.setProperty(runtime, "glID", static_cast<int>(texInfo.glID)); | ||
textureInfo.setProperty(runtime, "glFormat", | ||
static_cast<int>(texInfo.glFormat)); | ||
textureInfo.setProperty(runtime, "glProtected", | ||
static_cast<int>(texInfo.glProtected)); | ||
return textureInfo; | ||
} | ||
|
||
inline TextureInfo fromValue(jsi::Runtime &runtime, const jsi::Value &value) { | ||
auto object = value.getObject(runtime); | ||
TextureInfo texInfo; | ||
if (object.hasProperty(runtime, "mtlTexture")) { | ||
texInfo.mtlTexture = | ||
reinterpret_cast<const void *>(object.getProperty(runtime, "mtlTexture") | ||
.asBigInt(runtime) | ||
.asUint64(runtime)); | ||
} | ||
if (object.hasProperty(runtime, "glID")) { | ||
texInfo.glTarget = static_cast<unsigned int>( | ||
object.getProperty(runtime, "glTarget").asNumber()); | ||
texInfo.glID = static_cast<unsigned int>( | ||
object.getProperty(runtime, "glID").asNumber()); | ||
texInfo.glFormat = static_cast<unsigned int>( | ||
object.getProperty(runtime, "glFormat").asNumber()); | ||
texInfo.glProtected = | ||
object.getProperty(runtime, "glProtected").asNumber() != 0; | ||
} | ||
return texInfo; | ||
} | ||
|
||
} // namespace JsiTextureInfo | ||
} // namespace RNSkia |
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