Skip to content

Commit aec5854

Browse files
dream-approachingzhengjinshou
andauthored
feat: 鸿蒙化空实现 (#2)
Co-authored-by: zhengjinshou <zhengjinshou@huawei.com>
1 parent b07aafc commit aec5854

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+943
-177
lines changed

.gitignore

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
1-
# OSX
2-
#
3-
.DS_Store
41

5-
# Xcode
6-
#
7-
build/
8-
*.pbxuser
9-
!default.pbxuser
10-
*.mode1v3
11-
!default.mode1v3
12-
*.mode2v3
13-
!default.mode2v3
14-
*.perspectivev3
15-
!default.perspectivev3
16-
xcuserdata
17-
*.xccheckout
18-
*.moved-aside
19-
DerivedData
20-
*.hmap
21-
*.ipa
22-
*.xcuserstate
23-
project.xcworkspace
242

253
# node.js
264
#
275
node_modules/
286
npm-debug.log
297

30-
# android
31-
#
32-
android/build/
33-
android/.gradle/
34-
android/.idea/
35-
android/android.iml
36-
android/gradle/
37-
android/gradlew
38-
android/gradlew.bat
39-
android/local.properties
8+
package-lock.json
9+
*.tgz
10+
BuildProfile.ets

README.md

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,13 @@
1-
**This repository hosts the v2 of gl-react. Please also see the v3 at https://github.com/gre/gl-react**
1+
# @react-native-oh-tpl/gl-react-native
22

3-
4-
**[Gitbook documentation](https://github.com/ProjectSeptemberInc/gl-react/tree/master/docs) / [Github](https://github.com/ProjectSeptemberInc/gl-react-native/) / [gl-react](https://github.com/ProjectSeptemberInc/gl-react/)** / [#gl-react on reactiflux](https://discordapp.com/channels/102860784329052160/106102146109325312)
5-
6-
# <img width="32" alt="icon" src="https://cloud.githubusercontent.com/assets/211411/9813786/eacfcc24-5888-11e5-8f9b-5a907a2cbb21.png"> gl-react-native ![](https://img.shields.io/badge/react--native-%200.42.x-05F561.svg) ![](https://img.shields.io/badge/gl--react-%202.2.x-05F561.svg)
7-
8-
OpenGL bindings for React Native to implement complex effects over images and components, in the descriptive VDOM paradigm.
9-
10-
**`gl-react-native` is an implementation of `gl-react` for `react-native`. Please [read the main gl-react README](https://github.com/ProjectSeptemberInc/gl-react/) for more information.**
11-
12-
[![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/docs/simple.gif)](./example)[![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/docs/advancedeffects.gif)](./example)
3+
This project is based on [gl-react-native-v2](https://github.com/gre/gl-react-native-v2)
134

145
## Documentation
156

16-
[**doc**](https://github.com/ProjectSeptemberInc/gl-react/tree/master/docs)
17-
18-
## Installation
19-
20-
```
21-
npm i --save gl-react-native
22-
```
23-
24-
### Configure your React Native Application
25-
26-
**on iOS:**
27-
28-
![](https://github.com/ProjectSeptemberInc/gl-react-native/raw/master/docs/install-steps.png)
29-
30-
or if you use Cocapods:
7+
- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/gl-react-native.md)
318

32-
```ruby
33-
pod 'RNGL', :path => './node_modules/gl-react-native'
34-
```
9+
- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/gl-react-native.md)
3510

36-
**on Android:**
11+
## License
3712

38-
1. `android/settings.gradle`:: Add the following snippet
39-
```gradle
40-
include ':RNGL'
41-
project(':RNGL').projectDir = file('../node_modules/gl-react-native/android')
42-
```
43-
2. `android/app/build.gradle`: Add in dependencies block.
44-
```gradle
45-
compile project(':RNGL')
46-
```
47-
3. in your `MainApplication` (or equivalent) the RNGLPackage needs to be added. Add the import at the top:
48-
```java
49-
import com.projectseptember.RNGL.RNGLPackage;
50-
```
51-
4. In order for React Native to use the package, add it the packages inside of the class extending ReactActivity.
52-
```java
53-
@Override
54-
protected List<ReactPackage> getPackages() {
55-
return Arrays.<ReactPackage>asList(
56-
new MainReactPackage(),
57-
...
58-
new RNGLPackage()
59-
);
60-
}
61-
```
13+
This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/gl-react-native-v2/blob/partner-dev/LICENSE)

harmony/glRN/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules
2+
/oh_modules
3+
/.preview
4+
/build
5+
/.cxx
6+
/.test

harmony/glRN/Index.ets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./src/main/ets/GLRNPackage";
2+
export * from "./src/main/ets/RNCGLCanvasView"

harmony/glRN/build-profile.json5

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"apiType": "stageMode",
3+
"buildOption": {
4+
},
5+
"targets": [
6+
{
7+
"name": "default"
8+
},
9+
{
10+
"name": "ohosTest"
11+
}
12+
]
13+
}

harmony/glRN/hvigorfile.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { harTasks } from '@ohos/hvigor-ohos-plugin';
2+
3+
export default {
4+
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5+
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6+
}

harmony/glRN/oh-package.json5

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "glrn",
3+
"version": "1.0.0",
4+
"description": "Please describe the basic information.",
5+
"main": "Index.ets",
6+
"author": "",
7+
"license": "Apache-2.0",
8+
"dependencies": {}
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
cmake_minimum_required(VERSION 3.13)
3+
set(CMAKE_VERBOSE_MAKEFILE on)
4+
set(rnoh_glRN_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
5+
6+
file(GLOB rnoh_glRN_SRC CONFIGURE_DEPENDS *.cpp)
7+
file(GLOB_RECURSE rnoh_glRN_generated_SRC "${rnoh_glRN_generated_dir}/**/*.cpp")
8+
9+
add_library(rnoh_glRN SHARED ${rnoh_glRN_SRC} ${rnoh_glRN_generated_SRC})
10+
target_include_directories(rnoh_glRN PUBLIC
11+
${CMAKE_CURRENT_SOURCE_DIR}
12+
${rnoh_glRN_generated_dir}
13+
${CMAKE_CURRENT_SOURCE_DIR}/generated/react/render/components/gl_react_native
14+
)
15+
16+
target_link_libraries(rnoh_glRN PUBLIC rnoh)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
3+
#include "RNOH/generated/BaseGlReactNativePackage.h"
4+
5+
namespace rnoh {
6+
7+
class GLRNPackage : public BaseGlReactNativePackage {
8+
using Super = BaseGlReactNativePackage;
9+
10+
public:
11+
GLRNPackage(Package::Context ctx) : Super(ctx) {}
12+
};
13+
} // namespace rnoh
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* This code was generated by "react-native codegen-lib-harmony"
3+
*/
4+
5+
#pragma once
6+
7+
#include <react/renderer/components/gl_react_native/ComponentDescriptors.h>
8+
#include "RNOH/Package.h"
9+
#include "RNOH/ArkTSTurboModule.h"
10+
#include "RNOH/generated/turbo_modules/GLCanvasManager.h"
11+
#include "RNOH/generated/turbo_modules/RNGLContext.h"
12+
#include "RNOH/generated/components/RNCGLCanvasJSIBinder.h"
13+
14+
namespace rnoh {
15+
16+
class BaseGlReactNativePackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
17+
public:
18+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
19+
if (name == "GLCanvasManager") {
20+
return std::make_shared<GLCanvasManager>(ctx, name);
21+
}
22+
if (name == "RNGLContext") {
23+
return std::make_shared<RNGLContext>(ctx, name);
24+
}
25+
return nullptr;
26+
};
27+
};
28+
29+
class BaseGlReactNativePackageEventEmitRequestHandler : public EventEmitRequestHandler {
30+
public:
31+
void handleEvent(Context const &ctx) override {
32+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
33+
if (eventEmitter == nullptr) {
34+
return;
35+
}
36+
37+
std::vector<std::string> supportedEventNames = {
38+
};
39+
if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
40+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
41+
}
42+
}
43+
};
44+
45+
46+
class BaseGlReactNativePackage : public Package {
47+
public:
48+
BaseGlReactNativePackage(Package::Context ctx) : Package(ctx){};
49+
50+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
51+
return std::make_unique<BaseGlReactNativePackageTurboModuleFactoryDelegate>();
52+
}
53+
54+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
55+
return {
56+
facebook::react::concreteComponentDescriptorProvider<facebook::react::RNCGLCanvasComponentDescriptor>(),
57+
};
58+
}
59+
60+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
61+
return {
62+
{"RNCGLCanvas", std::make_shared<RNCGLCanvasJSIBinder>()},
63+
};
64+
};
65+
66+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
67+
return {
68+
std::make_shared<BaseGlReactNativePackageEventEmitRequestHandler>(),
69+
};
70+
}
71+
};
72+
73+
} // namespace rnoh

0 commit comments

Comments
 (0)