|
1 | 1 | # GitHub Copilot Instructions — android-gpuimage-plus |
2 | 2 |
|
3 | | -This repo is a widely-used Android GPU filter library. Prefer **small, safe, backward-compatible** changes. |
| 3 | +Android GPU filter library (C++ & Java). Prefer **small, safe, backward-compatible** changes. |
4 | 4 |
|
5 | | -## Non‑negotiables (stability first) |
| 5 | +## Stability Rules |
6 | 6 |
|
7 | | -- **Do not break compatibility**: avoid changing public Java APIs, JNI method signatures, or filter rule string syntax. |
8 | | -- Prefer **additive** changes (new classes/methods/filters) over refactors. |
9 | | -- Keep FFmpeg/video code **fully optional** (both Java and native side guards). |
| 7 | +- **Never break public API**: `org.wysaid.nativePort.*` Java signatures, JNI method names, and filter rule string syntax are stable contracts. |
| 8 | +- Prefer **additive** changes over refactoring existing code. |
| 9 | +- FFmpeg/video code must remain **fully optional** — guard with `disableVideoModule` (Java/Gradle) / `CGE_USE_VIDEO_MODULE` (C++). |
10 | 10 |
|
11 | | -## Where things live (only what’s non-obvious) |
| 11 | +## Project Layout |
12 | 12 |
|
13 | | -- Java public API / JNI front door: `library/src/main/java/org/wysaid/nativePort/` |
14 | | - - `CGENativeLibrary`, `CGEImageHandler`, `CGEFrameRenderer`, `CGEFrameRecorder` |
15 | | -- Native engine: `library/src/main/jni/cge/` |
16 | | -- JNI bridge (Java ↔ C++): `library/src/main/jni/interface/` |
17 | | -- Extension filters (built as `libCGEExt.so`): `library/src/main/jni/custom/` |
18 | | -- Prebuilt FFmpeg variants: `library/src/main/jni/ffmpeg/` and `ffmpeg-16kb/` |
19 | | -- Demo app (`cgeDemo/`) is for examples; avoid coupling new library APIs to demo-only code. |
| 13 | +| Path | Purpose | |
| 14 | +|------|---------| |
| 15 | +| `library/src/main/java/org/wysaid/nativePort/` | Public Java API (`CGENativeLibrary`, `CGEImageHandler`, etc.) | |
| 16 | +| `library/src/main/jni/cge/` | Core C++ engine | |
| 17 | +| `library/src/main/jni/interface/` | JNI bridge (Java ↔ C++) | |
| 18 | +| `library/src/main/jni/custom/` | Extension filters (`libCGEExt.so`) | |
| 19 | +| `library/src/main/jni/ffmpeg/`, `ffmpeg-16kb/` | Prebuilt FFmpeg variants | |
| 20 | +| `cgeDemo/` | Demo app — don't couple library APIs to demo-only code | |
20 | 21 |
|
21 | | -## Build toggles you must respect |
| 22 | +## Build |
22 | 23 |
|
23 | | -These flags come from `local.properties` (see `settings.gradle`): |
| 24 | +Use `tasks.sh` for all operations (`bash tasks.sh --help`). Key `local.properties` flags: `usingCMakeCompile`, `disableVideoModule`, `enable16kPageSizes`. See `docs/build.md` for details. |
24 | 25 |
|
25 | | -- `usingCMakeCompile`: build native code via CMake; otherwise use prebuilt `.so` in `library/src/main/libs/`. |
26 | | -- `usingCMakeCompileDebug`: toggles Debug vs Release native build. |
27 | | -- `disableVideoModule`: when true, **no FFmpeg / no recording**. |
28 | | -- `enable16kPageSizes`: enables 16KB page-size linking flags and uses `ffmpeg-16kb`. |
29 | | -- `deployArtifacts`: enables maven publishing tasks. |
| 26 | +**Important**: CMake uses `GLOB_RECURSE`; ndk-build (`Android.mk`) lists sources **explicitly** — update both when adding native files. |
30 | 27 |
|
31 | | -Important: CMake uses recursive globs, but **ndk-build (`Android.mk`) lists sources explicitly**. If you add native files that must compile in ndk-build mode, update `Android.mk` accordingly. |
| 28 | +## Code Conventions |
32 | 29 |
|
33 | | -## Native/C++ conventions that matter here |
| 30 | +Language-specific rules live in `.github/instructions/` and are auto-applied by file path — see `cpp.instructions.md`, `java.instructions.md`, `jni-bridge.instructions.md`. |
34 | 31 |
|
35 | | -- Follow `.clang-format` (Allman braces, 4 spaces, no tabs). Keep code in `namespace CGE {}`. |
36 | | -- **No C++ exceptions** (compiled with `-fno-exceptions`). Use return values and log errors. |
37 | | -- Use project logging macros: `CGE_LOG_INFO`, `CGE_LOG_KEEP`, `CGE_LOG_ERROR`. |
38 | | -- Inline shader strings via `CGE_SHADER_STRING_PRECISION_H()` / `CGE_SHADER_STRING_PRECISION_M()`. |
| 32 | +For detailed standards, see `.github/CONTRIBUTING.md`. |
39 | 33 |
|
40 | | -## Java/OpenGL thread rules (project-specific pitfalls) |
| 34 | +## Documentation |
41 | 35 |
|
42 | | -- For `GLSurfaceView`-based classes, do GL operations on the GL thread via `queueEvent(...)`. |
43 | | -- `NativeLibraryLoader` controls native library loading order; don’t unconditionally load FFmpeg when video module is disabled. |
| 36 | +- `docs/build.md` — Full build guide and configuration options |
| 37 | +- `docs/usage.md` — API usage, custom filters, and code samples |
| 38 | +- `.github/RELEASE.md` — Release process and versioning |
| 39 | +- `.github/CONTRIBUTING.md` — Contributing guidelines and code standards |
44 | 40 |
|
45 | | -## Adding a new GPU filter / feature (minimal checklist) |
| 41 | +## Skills |
46 | 42 |
|
47 | | -1. Implement the filter in `library/src/main/jni/custom/` (or `cge/filters/` if it’s core). |
48 | | -2. Initialize shaders/uniforms in `init()`; handle compile/link failures without crashing. |
49 | | -3. Ensure GL resources are released (programs/textures/FBOs) along the existing lifecycle. |
50 | | -4. If the feature is exposed to Java, add/update JNI wrappers under `library/src/main/jni/interface/` and keep signatures stable. |
51 | | -5. If it should be reachable from rule strings, update the parsing/registration in the native engine (don’t change existing syntax). |
52 | | -6. Keep FFmpeg/video-dependent logic behind `disableVideoModule` / `CGE_USE_VIDEO_MODULE` guards. |
| 43 | +- **Submit PR:** Follow `.github/skills/pr-submit/SKILL.md` to create or update pull requests |
| 44 | +- **Review PR:** Follow `.github/skills/pr-review/SKILL.md` to review pull requests |
53 | 45 |
|
54 | | -## Communication & docs |
| 46 | +## Behavior Constraints |
55 | 47 |
|
56 | | -- Use **English** for code comments, commit messages, and PR descriptions. |
57 | | -- Don’t add new “how to build” tutorials here—put long-form docs in `README.md` (this file should stay short). |
| 48 | +- **Validation:** After native code changes, ALWAYS run `bash tasks.sh --enable-cmake --build`. |
| 49 | +- **Commit Policy:** Only commit to feature branches, never force-push to `master`. |
| 50 | +- **Completeness:** Implement fully or request clarification — no TODOs in committed code. |
| 51 | +- **Dual Build:** When adding native files, update both `CMakeLists.txt` and `Android.mk`. |
| 52 | +- **Thread Safety:** Never call OpenGL ES functions outside the GL thread. |
0 commit comments