Giter Site home page Giter Site logo

openacg-group / cocoa Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 1.0 12.23 MB

A general-purposed 2D rendering framework & visual novel engine.

Home Page: https://openacg-group.github.io

License: GNU General Public License v3.0

CMake 1.14% Python 1.65% C++ 74.94% Shell 0.20% C 12.93% TypeScript 9.06% JavaScript 0.08%
2d-graphics rendering-engine skia v8-javascript-engine visual-novel visual-novel-framework wayland wayland-client

cocoa's People

Contributors

wait1210day avatar

Stargazers

 avatar  avatar

Forkers

linecode

cocoa's Issues

[typescript] Implement RasterPipeline, an image processing API

Plan to implement RasterPipeline, which is an image processing API based on native Skia API, and optionally integrate OpenCV WASM. This API allows users to generate and process images by creating a DAG (Directed Acyclic Graph) pipeline. Each node in the DAG could process or generate images, and they are connected together so that a node can take another node's output as its input. This is very similar to AVFilterDAG class in utau module, which process video or audio frames by a DAG constructed by ffmpeg's DSL (AVFilterDAG.MakeFromDSL()). But RasterPipeline is for static images, which means it is simplified and does not consider some complex things in multimedia processing, like frame timing. And RasterPipeline is designed for glamor module, supporting Skia APIs instead of VideoFrame or AudioFrame API in utau module.

Development of RasterPipeline is in progress.

Integrate CanvasKit and paint with it

Track the process of CanvasKit integration.

  • Fix the bug that glyphs cache causes serious memory pressure when deserializing an SkPicture containing fonts from CanvasKit.
  • Fix the bug that the memory usage still increases slowly for an unknown reason.
  • Improve the performance of large image deserialization (although uploading the image to TextureManager and rendering it by TextureLayer can avoid this problem, we still need to improve the performance of direct image drawing as much as possible).

CanvasKit is deprecated and Skia native APIs are available

WebAssembly-based JavaScript module CanvasKit is removed from the project. Instead, Skia native APIs are now available for less overhead while painting.

CanvasKit has been the painting interface for JavaScript in Cocoa for a long time. However, for many reasons, we have to remove it from the repository. Users can still compile a canvaskit.wasm by themselves and import it as a common WebAssembly module to use it. Here are the most important reasons why we deprecate it:

  • Integration Glamor has many native classes exported from native Skia library, such as CkImage, CkPicture, CkBitmap and so on, while CanvasKit also has its corresponding classes SkImage, SkPicture, and SkBitmap. Users must do many things to convert between those data types. For example, when you try to write a simple music player by Cocoa, you need to use Utau module to extract and decode the cover image from mp3 file. Utau decoder gives you a VideoBuffer object, which can be converted to Glamor's CkImage object. Supposing that you want to preprocess it using CanvasKit (e.g. apply a Gaussian blur filter), then you must firstly convert the CkImage object to CanvasKit's SkImage object before preprocessing it. The preprocessed image should be rendered on the window, which means you need to convert the preprocessed image back to Glamor's CkImage object. That is quite painful and complex.
  • Performance As WASM modules need to be compiled at runtime, applications that use CanvasKit module spend more time starting up. What's worse, as the example shown above, converting between Glamor data types and CanvasKit data types causes pixels copying. Meanwhile, SkPicture objects generated by SkPictureRecorder also must be converted to Glamor's CkPicture before adding it to the Glamor's layer tree. Converting between them is implemented by serializing and deserializing the picture object. If the picture object contains typefaces or large images, the conversion is an expensive operation. We have implmented a complicated mechanism to reduce the overhead for typefaces (#3), but for large images, it is a quite difficult problem.
  • Cache Skia caches many rendering objects like shaders, blenders, image filters, etc., but creating CkPicture from deserializing breaks the cache mechanism.

Now with the native Skia APIs, object conversions are not needed anymore, and pixels copying can be reduced to the minimal value. For the music player example shown above, pixels will be copyed N time(s) before it is submitted to Blender or landed on a certain surface:

  • N=0 if the decoded frame is already in BGRA format;
  • N=1 if the decoded frame is in YUV format or other formats.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.