Skip to content

Commit

Permalink
Merge pull request #4 from nagra-opentv/skiaFastImage
Browse files Browse the repository at this point in the history
Added changes for RNS codgen support
  • Loading branch information
prasanna-jeyam authored Apr 12, 2023
2 parents 344d293 + d3eb233 commit e372149
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 32 deletions.
10 changes: 5 additions & 5 deletions skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ config("LibFastImage_config") {
]
}

rn_cxx_component("fastImage") {
rns_cxx_tp_component("rnfastimage") {

# RS Native module and its dependencies
# Native module and its dependencies
sources = [
"RSFastImageModule.h",
"RSFastImageModule.cpp",
"FastImageViewModule.h",
"FastImageViewModule.cpp",
]

# RNS Fabric Component and its dependencies
# Fabric Component and its dependencies
sources += [
"RSkComponentProviderFastImageView.cpp",
"RSkComponentProviderFastImageView.h",
Expand Down
12 changes: 6 additions & 6 deletions skia/RSFastImageModule.cpp → skia/FastImageViewModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
#include "ReactSkia/utils/RnsLog.h"
#include "ReactSkia/views/common/RSkImageCacheManager.h"

#include "RSFastImageModule.h"
#include "FastImageViewModule.h"

using namespace folly;
namespace facebook {
using namespace react;
namespace xplat {

RSFastImageModule::RSFastImageModule() { }
FastImageViewModule::FastImageViewModule() { }

auto RSFastImageModule::getConstants() -> std::map<std::string, folly::dynamic> {
auto FastImageViewModule::getConstants() -> std::map<std::string, folly::dynamic> {
return {};
}

std::string RSFastImageModule::getName() {
std::string FastImageViewModule::getName() {
return "FastImageView";
}

auto RSFastImageModule::getMethods() -> std::vector<Method> {
auto FastImageViewModule::getMethods() -> std::vector<Method> {
return {
Method(
"preload",
Expand Down Expand Up @@ -58,7 +58,7 @@ auto RSFastImageModule::getMethods() -> std::vector<Method> {
#ifdef __cplusplus
extern "C" {
#endif
RNS_EXPORT_MODULE(RSFastImageModule)
RNS_EXPORT_MODULE(FastImageView)
#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions skia/RSFastImageModule.h → skia/FastImageViewModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ using namespace std;
namespace facebook {
namespace xplat {

class RSFastImageModule : public module::CxxModule {
class FastImageViewModule : public module::CxxModule {
public:
RSFastImageModule();
virtual auto getConstants() -> std::map<std::string, folly::dynamic>;
virtual auto getMethods() -> std::vector<Method>;
std::string getName();
FastImageViewModule();
std::map<std::string, folly::dynamic> getConstants() override;
std::vector<Method> getMethods() override;
std::string getName() override;
};

} // namespace xplat
Expand Down
14 changes: 11 additions & 3 deletions skia/RSkComponentProviderFastImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@
namespace facebook {
namespace react {

RSkComponentProviderFastImage::RSkComponentProviderFastImage() {}
RSkComponentProviderFastImageView::RSkComponentProviderFastImageView() {}

ComponentDescriptorProvider RSkComponentProviderFastImage::GetDescriptorProvider() {
ComponentDescriptorProvider RSkComponentProviderFastImageView::GetDescriptorProvider() {
return concreteComponentDescriptorProvider<FastImageViewComponentDescriptor>();
}

std::shared_ptr<RSkComponent> RSkComponentProviderFastImage::CreateComponent(
std::shared_ptr<RSkComponent> RSkComponentProviderFastImageView::CreateComponent(
const ShadowView &shadowView) {
return std::static_pointer_cast<RSkComponent>(
std::make_shared<RSkComponentFastImage>(shadowView));
}

#ifdef __cplusplus
extern "C" {
#endif
RNS_EXPORT_COMPONENT_PROVIDER(FastImageView)
#ifdef __cplusplus
}
#endif

} // namespace react
} // namespace facebook
15 changes: 2 additions & 13 deletions skia/RSkComponentProviderFastImageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,15 @@
namespace facebook {
namespace react {

class RSkComponentProviderFastImage : public RSkComponentProvider {
class RSkComponentProviderFastImageView : public RSkComponentProvider {
public:
RSkComponentProviderFastImage();
RSkComponentProviderFastImageView();

public:
ComponentDescriptorProvider GetDescriptorProvider() override;
std::shared_ptr<RSkComponent> CreateComponent(
const ShadowView &shadowView) override;
};

#ifdef __cplusplus
extern "C" {
#endif
RNS_USED RSkComponentProvider *RSkComponentProviderFastImageCls() {
return new RSkComponentProviderFastImage();
}

#ifdef __cplusplus
}
#endif

} // namespace react
} // namespace facebook
29 changes: 29 additions & 0 deletions skia/Rsk.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"codegenConfig": {
"name": "rnfastimage",
"version": "8.6.3",
"type": "all",
"skia": {
"codegenNativeComponentNativeProps" : [
"FastImageView"
],
"TurboModuleRegistryGetEnforcingSpec" : [
"FastImageView"
]
}
},
"viewManagerConfig" : {
"FastImageView" : {
"nativePropsConfig" : [
],
"directEventConfig" : [
"FastImageLoadStart",
"FastImageLoadEnd",
"FastImageLoadError",
"FastImageError"
],
"bubblingEventConfig" : [
]
}
}
}

0 comments on commit e372149

Please sign in to comment.