1 #pragma once 2 3 #include <jsi/jsi.h> 4 #include <stdio.h> 5 #include <memory> 6 #include <vector> 7 #include "NativeReanimatedModule.h" 8 #include "ShareableValue.h" 9 10 using namespace facebook; 11 12 namespace reanimated { 13 14 class MapperRegistry; 15 16 struct ViewDescriptor { 17 int tag; 18 jsi::Value name; 19 }; 20 21 class Mapper : public std::enable_shared_from_this<Mapper> { 22 friend MapperRegistry; 23 24 private: 25 unsigned long id; 26 NativeReanimatedModule *module; 27 std::shared_ptr<jsi::Function> mapper; 28 std::vector<std::shared_ptr<MutableValue>> inputs; 29 std::vector<std::shared_ptr<MutableValue>> outputs; 30 bool dirty = true; 31 std::shared_ptr<jsi::Function> userUpdater; 32 UpdaterFunction *updateProps; 33 int optimalizationLvl = 0; 34 std::shared_ptr<ShareableValue> viewDescriptors; 35 36 public: 37 Mapper( 38 NativeReanimatedModule *module, 39 unsigned long id, 40 std::shared_ptr<jsi::Function> mapper, 41 std::vector<std::shared_ptr<MutableValue>> inputs, 42 std::vector<std::shared_ptr<MutableValue>> outputs); 43 void execute(jsi::Runtime &rt); 44 void enableFastMode( 45 const int optimalizationLvl, 46 const std::shared_ptr<ShareableValue> &updater, 47 const std::shared_ptr<ShareableValue> &jsViewDescriptors); 48 virtual ~Mapper(); 49 }; 50 51 } // namespace reanimated 52