WIP: Native canvas - #319
Open
Hierifer wants to merge 10 commits into
Open
Conversation
…ion fix - iOS: Add baseScale (jsCanvasSize / nativeViewSize) to NativeCanvasView to compensate for DPI mismatch when JS sets canvas.width = cssWidth * dpr then ctx.scale(dpr, dpr). Applied in draw(), renderToImage(), setTransform, and resetTransform. - iOS: Wire up setCanvasProperty in CanvasManager to store JS canvas dimensions on the view. - HarmonyOS: Add pendingFlushes buffer in DMPCanvasManager to queue flush messages that arrive before the Canvas component registers (aboutToAppear). Replay queued flushes on register. - HarmonyOS: Add enhanced diagnostic logging for setCanvasProperty, handleFlush, contextCall scale/transform operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add GL headers and extern "C" to nanovg_gl_utils.h for C/C++ linkage - Include nanovg_gl.h in canvas_renderer.cpp for GLES2 API symbols - Fix nanovg_impl.c to include nanovg.c core implementation directly - Add dimina_canvas2d.h include to js_thread.cpp for dm_canvas_create Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts: # fe/packages/components/src/component/canvas/Canvas.vue # fe/packages/container/package.json # fe/packages/container/src/pages/miniApp/miniApp.js # fe/packages/container/src/pages/miniApp/miniApp.scss # fe/packages/render/src/core/runtime.js # fe/packages/service/src/api/core/ui/canvas/canvas-node.js # fe/packages/service/src/api/core/ui/canvas/index.js # fe/packages/service/src/core/runtime.js # fe/packages/service/src/instance/component/component.js # fe/packages/service/src/instance/page/page.js # harmony/dimina/src/main/cpp/CMakeLists.txt # harmony/dimina/src/main/ets/Bridges/DMPContainerBridgesModule+NavigationBar.ets # harmony/dimina/src/main/ets/DPages/DMPPageTitle.ets # iOS/dimina.xcodeproj/xcshareddata/xcschemes/dimina.xcscheme # iOS/dimina/DiminaKit/Container/DMPChannelProxy.swift # iOS/dimina/DiminaKit/Service/DMPEngine.swift # shared/jsapp/wx92269e3b2f304afc/config.json # shared/jsapp/wx92269e3b2f304afc/wx92269e3b2f304afc.zip # shared/jsapp/wxe5f52902cf4de896/config.json # shared/jsapp/wxe5f52902cf4de896/wxe5f52902cf4de896.zip # shared/jssdk/config.json # shared/jssdk/main.zip
Implement GPU-accelerated Canvas 2D rendering that bypasses the WebView canvas using NanoVG + OpenGL ES 2.0 with FBO off-screen rendering, integrated via HarmonyOS XComponent same-layer rendering. - Shared C library (canvas2d): NanoVG context, EGL surface management, FBO off-screen rendering, JSON op parser, stb_image decode/encode - HarmonyOS bindings: QuickJS thread GL rendering, op queue with deferred swap via rAF, image upload pipeline via TSFN, surface rebind/resize - JS SDK: GLCanvasNode, GLContext2D, NativeImage classes with full Canvas 2D API coverage (fill/stroke, paths, text, transforms, images, gradients, patterns, compositing, shadows) - Touch event forwarding from XComponent to WebView <embed> for bindtouchstart/move/end support with scroll pass-through - Canvas spec document (NATIVE_CANVAS_SPEC.md) - Rename Skia references to GL across all platforms - iOS __GLCanvas stub (available: false, falls back to WebView canvas) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port the native canvas rendering pipeline to iOS using ANGLE (OpenGL ES 2.0 → Metal translation), reusing the shared dimina_canvas2d C library. iOS-specific changes: - DMPEngineCanvas.swift: canvas bindings for JSContext (__GLCanvas with available=true, op buffering, deferred swap, sync ops, image uploads) - NativeCanvasGLView.swift: UIView with CAEAGLLayer for ANGLE rendering - CanvasImageLoader.swift: image download/decode to RGBA for GL upload - dimina-Bridging-Header.h: expose dimina_canvas2d.h C API to Swift - DMPEngine.swift: register canvas bindings, add JS thread accessor - NativeComponentAPI.swift: switch from NativeCanvasView to NativeCanvasGLView Shared canvas2d changes: - egl_surface.h/cpp: unify iOS with Android/Harmony using real ANGLE EGL (eglGetPlatformDisplayEXT with Metal backend) - canvas_renderer.cpp: add iOS system font loading (SF Pro, PingFang CJK) - CMakeLists.txt: add ANGLE_INCLUDE_DIR support for iOS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the scissor-only clip approach with stencil bit 7 partitioning in NanoVG's GL backend. NanoVG fill operations now use stencil bits 0-6, while bit 7 is reserved for the persistent clip mask. This enables clip() with arc(), bezier, and other non-rect paths. Key changes: - Add GLNVG_CLIPFILL command type that writes path interior to stencil bit 7 - Modify glnvg__fill to use 0x7f mask and split fill/clear passes when clipped - Add clip-aware stencil tests to convexFill, stroke, and triangles - Implement nvglSetNextFillAsClip/nvglClearClipStencil public API - restore() flushes frame, clears bit 7, and rebuilds NanoVG state stack - Add clipActive flag to CanvasDrawState, remove old clipRects approach Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dos1in
reviewed
Aug 25, 2026
| ? path.replace(`http://127.0.0.1/${appId}/`, '') | ||
| : path.replace('http://127.0.0.1/', ''); | ||
| ? path.replace(`http://mp.qiandao.com/${appId}/`, '') | ||
| : path.replace('http://mp.qiandao.com/', ''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
canvas 改用 opengl + nanoVG 实现