MCPcopy Create free account
hub / github.com/Snapchat/Valdi / setVisibleViewport

Method setVisibleViewport

valdi/src/valdi/android/NativeBridge.cpp:1149–1176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1147}
1148
1149void ValdiAndroid::NativeBridge::setVisibleViewport( // NOLINT
1150 fbjni::alias_ref<fbjni::JClass> /* clazz */, // NOLINT
1151 jlong runtimeHandle,
1152 jlong contextHandle,
1153 jint x,
1154 jint y,
1155 jint width,
1156 jint height,
1157 jboolean shouldUnset) {
1158 auto viewNodeTree = getViewNodeTree(contextHandle);
1159 auto* runtimeWrapper = getRuntimeWrapper(runtimeHandle);
1160
1161 if (viewNodeTree == nullptr || runtimeWrapper == nullptr) {
1162 return;
1163 }
1164
1165 if (static_cast<bool>(shouldUnset)) {
1166 viewNodeTree->setViewport(std::nullopt);
1167 } else {
1168 auto pointScale = runtimeWrapper->getPointScale();
1169 auto xFloat = static_cast<float>(x) / pointScale;
1170 auto yFloat = static_cast<float>(y) / pointScale;
1171 auto widthFloat = static_cast<float>(width) / pointScale;
1172 auto heightFloat = static_cast<float>(height) / pointScale;
1173
1174 viewNodeTree->setViewport({Valdi::Frame(xFloat, yFloat, widthFloat, heightFloat)});
1175 }
1176}
1177
1178void ValdiAndroid::NativeBridge::callOnJsThread( // NOLINT
1179 fbjni::alias_ref<fbjni::JClass> /* clazz */, // NOLINT

Callers

nothing calls this directly

Calls 5

getViewNodeTreeFunction · 0.85
getRuntimeWrapperFunction · 0.85
setViewportMethod · 0.80
FrameClass · 0.50
getPointScaleMethod · 0.45

Tested by

no test coverage detected