openmobilemaps / maps-core

The lightweight and modern Map SDK for Android and iOS
https://openmobilemaps.io
Mozilla Public License 2.0
163 stars 17 forks source link

Java bindings for offscreen map rendering #652

Open matzf opened 4 weeks ago

matzf commented 4 weeks ago

Add a java library to use the OpenGL-variant of the openmobilemaps in a non-android Java environment. For now, this only explicitly supports offscreen rendering via OSMesa. Currently, this can be built and run only on Linux on amd64. Supporting other platforms should be doable but will require further tweaks (notably using an explicit define to enable the GL entrypoints instead of ifdef __linux__).

Also add a minimal standalone test application that can be run on Linux without any platform specific bindings (can anyone guess what the demo polygon layer in there represents? :wink:). This has been valuable to me for diagnostics and debugging purposes. This could also be the starting point to a more generic (offscreen) map rendering regression-test tool that can be run e.g. during PRs.

-- Note: github publish workflow might still require some tweaking due the naming of the organization secrets.

Summary by CodeRabbit

coderabbitai[bot] commented 4 weeks ago

Walkthrough

This pull request introduces multiple new files and modifications primarily focused on enhancing the build and rendering capabilities of a JVM project utilizing OpenGL and OSMesa. Key additions include two GitHub Actions workflows for building and deploying Maven projects, new CMake configurations for shared libraries, and several utility classes for managing OpenGL textures and offscreen rendering. Additionally, various enhancements to error handling, logging, and vector operations are implemented, alongside comprehensive documentation and test files to ensure functionality and maintainability.

Changes

File Path Change Summary
.github/workflows/jvm_build.yml New workflow for Maven build on push events.
.github/workflows/jvm_package_deploy.yml New workflow for Maven package deployment on tag pushes.
.gitignore Updated to include new patterns for ignored files related to clangd and build artifacts.
CMakeLists.txt Introduced for configuring the mapscore project, creating a static library with OpenGL support.
android/src/main/cpp/graphics/OpenGlHelper.h Added inline function glCheckError_ for OpenGL error checking and logging.
android/src/main/cpp/graphics/shader/ColorShaderOpenGl.cpp Added error checking after shader operations using glCheckError().
djinni/map/loader/loader.djinni Added methods for asynchronous texture and data loading with a typo in one method name.
jvm/CMakeLists.txt New CMake configuration for building shared library mapscore_jni.
jvm/pom.xml New Maven POM file for the maps-core project with dependencies and build plugins.
jvm/readme.md Documentation for Java library supporting offscreen rendering using OpenGL.
jvm/src/main/cpp/jni/GlTextureHelper.cpp Introduced OpenGL texture management functions for JNI.
jvm/src/main/cpp/jni/OSMesa.cpp Functions for managing OSMesa context in JNI.
jvm/src/main/java/io/openmobilemaps/mapscore/MapsCore.java Class for initializing native libraries based on OS and architecture.
jvm/src/main/java/io/openmobilemaps/mapscore/graphics/util/GlTextureHelper.java Utility class for OpenGL texture operations.
jvm/src/main/java/io/openmobilemaps/mapscore/map/loader/FontJsonManifestReader.java Class for reading font manifest JSON files.
jvm/src/main/java/io/openmobilemaps/mapscore/map/loader/HttpDataLoader.java Implements HTTP/HTTPS data loading functionality.
jvm/src/main/java/io/openmobilemaps/mapscore/map/loader/LocalDataLoader.java Loads local resources via file and jar URLs.
jvm/src/main/java/io/openmobilemaps/mapscore/map/util/MapTileRenderer.java Class for offscreen tile rendering in the OpenMobileMaps framework.
jvm/src/main/java/io/openmobilemaps/mapscore/map/util/OffscreenMapRenderer.java Class for managing offscreen rendering of maps using OpenGL.
jvm/src/main/java/io/openmobilemaps/mapscore/map/util/Tiled2dMapVectorLayerBuilder.java Builder for Tiled2dMapVectorLayer with customizable options.
jvm/src/test/java/io/openmobilemaps/mapscore/OffscreenMapRendererTest.java Unit tests for the OffscreenMapRenderer class.
shared/public/Logger.h Removed color logging directive, keeping log level unchanged.
shared/public/Tiled2dMapSourceImpl.h Enhanced tile visibility and loading method implementations.
shared/public/Vec2DHelper.h New utility functions for 2D vector operations.
standalone/CMakeLists.txt New CMake configuration for a standalone project.
standalone/main.cpp Implementation for rendering using the OSMesa library.
standalone/readme.md Documentation for the standalone test application.

Poem

🐰 In the meadow where code does bloom,
New workflows sprout, dispelling the gloom.
With textures and shaders, we dance and play,
Offscreen rendering brightens the day!
So hop with joy, let the changes unfold,
A tale of progress, in stories retold! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.