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

Method notifyScroll

valdi/src/valdi/android/NativeBridge.cpp:1262–1345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1260 } else {
1261 auto runtime = runtimeWrapper->getSharedRuntime();
1262 runtimeWrapper->getRuntime().getMainThreadManager().dispatch(
1263 nullptr, [runnableRef = std::move(runnableRef), runtime = std::move(runtime)]() {
1264 auto batch = runtime->getMainThreadManager().scopedBatch();
1265 (*runnableRef)();
1266 });
1267 }
1268}
1269
1270enum ScrollEventType {
1271 ScrollEventTypeOnScroll = 1,
1272 ScrollEventTypeOnScrollEnd = 2,
1273 ScrollEventTypeOnDragStart = 3,
1274 ScrollEventTypeOnDragEnding = 4,
1275};
1276
1277static jlong convertPointToPackedPixels(const Valdi::Point& point, float pointScale) {
1278 return Valdi::pointsToPackedPixels(point.x, point.y, pointScale);
1279}
1280
1281jlong ValdiAndroid::NativeBridge::notifyScroll( // NOLINT
1282 fbjni::alias_ref<fbjni::JClass> /* clazz */, // NOLINT
1283 jlong runtimeHandle,
1284 jlong viewNodeHandle,
1285 jint eventType,
1286 jint pixelDirectionDependentContentOffsetX,
1287 jint pixelDirectionDependentContentOffsetY,
1288 jint pixelDirectionDependentUnclampedContentOffsetX,
1289 jint pixelDirectionDependentUnclampedContentOffsetY,
1290 jfloat pixelDirectionDependentInvertedVelocityX,
1291 jfloat pixelDirectionDependentInvertedVelocityY) {
1292 auto* runtimeWrapper = getRuntimeWrapper(runtimeHandle);
1293 auto viewNode = getViewNode(viewNodeHandle);
1294 jlong out = std::numeric_limits<jlong>::min();
1295
1296 if (runtimeWrapper == nullptr || viewNode == nullptr) {
1297 return out;
1298 }
1299
1300 auto* viewNodeTree = viewNode->getViewNodeTree();
1301
1302 if (viewNodeTree == nullptr) {
1303 // TODO: is this a valid state?
1304 return 0;
1305 }
1306
1307 // Point conversions only need the point scale, not tree state; keep them out of the
1308 // critical section.
1309 auto pointScale = runtimeWrapper->getPointScale();
1310
1311 auto pointDirectionDependentContentOffset =
1312 Valdi::Point::fromPixels(static_cast<int32_t>(pixelDirectionDependentContentOffsetX),
1313 static_cast<int32_t>(pixelDirectionDependentContentOffsetY),
1314 pointScale);
1315
1316 auto pointDirectionDependentUnclampedContentOffset =
1317 Valdi::Point::fromPixels(static_cast<int32_t>(pixelDirectionDependentUnclampedContentOffsetX),
1318 static_cast<int32_t>(pixelDirectionDependentUnclampedContentOffsetY),
1319 pointScale);

Callers

nothing calls this directly

Calls 15

getRuntimeWrapperFunction · 0.85
getViewNodeFunction · 0.85
minFunction · 0.85
pixelsToPointsFunction · 0.85
getViewNodeTreeMethod · 0.80
withLockMethod · 0.80
valueMethod · 0.65
PointClass · 0.50
getPointScaleMethod · 0.45
onScrollMethod · 0.45
onScrollEndMethod · 0.45

Tested by

no test coverage detected