Repository navigation
feat(harmonyos): tint canvas images - #2016
Merged
Merged
Conversation
houko
force-pushed
the
feat/harmony-image-tint-2003
branch
from
November 22, 2026 14:29
d8719ab to
be4ec2a
Compare
Restores the HarmonyOS part taken out of #1200: canvasOp carries the tint for tinted DrawImage ops, and the ArkTS canvas multiplies the PixelMap's bytes by it in an offscreen context, keeping the last tinted image.
…ase them The one-entry cache missed on every paint with two tinted images or one image in two tints, and never released the PixelMap it replaced. The canvas now keys tinted copies by source image and tint, releases a copy two paints in a row did not draw, and releases the rest when it disappears. The docs, roadmap and changelog now say HarmonyOS tints only images from bytes or the app's resources, and the shared tint pixel test skips its pixel-buffer and offscreen cases there.
Built with cmd/nsgo/harmony/host/build.sh, the OpenHarmony 7.0 public SDK (26.0.0.38) and hvigor 6.26.20.
houko
force-pushed
the
feat/harmony-image-tint-2003
branch
from
November 23, 2026 00:09
be4ec2a to
a769d4d
Compare
houko
marked this pull request as ready for review
November 23, 2026 00:10
This was referenced Nov 23, 2026
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.
Refs #2003, #1111
What
This restores the HarmonyOS half of canvas image tinting that was taken out of #1200. It is the patch from #2003, plus the host rebuild the patch was waiting for.
canvasOpcarriestintfor tintedDrawImageops. A zero (transparent black) tint is still sent.CanvasViewdraws the PixelMap into anOffscreenCanvasRenderingContext2D, multiplies each RGBA byte by the tint over 255 and draws the result. Tinted copies are kept per source image and tint, so several tinted images or tints in one drawing each hit their own copy. A copy that two paints in a row did not draw is released withPixelMap.release()(not right after drawing, since the Canvas may still read the last paint's), and the rest are released inaboutToDisappear. A tint that changes every frame, such as one bound toArgColor, still costs a JS pass over the image's pixels per change. Only images from bytes or the app's resources are tinted, since the HarmonyOS canvas does not draw pixel buffers or offscreen images yet.docs/architecture/canvas.mdandskills/nsgo/references/components.mdnow say HarmonyOS tints images from bytes or the app's resources but is not yet checked on a device. The roadmap row's criterion is the shared pixel test'sencodedcase, with a status clause and harmonyos: tint canvas images and rebuild the committed host #2003 linked. The changelog fragment uses(#2003 by @houko), and feat(canvas): add per-draw image tinting #1200's fragment drops "except HarmonyOS" so one release does not say both.cmd/nsgo/harmony/host/build.sh, using the OpenHarmony 7.0 public SDK (26.0.0.38) and hvigor 6.26.20 (see HarmonyOS: make the committed host rebuildable (toolchain recipe, or rebuild it in CI) #2015). The ArkTS compiles against API 26.Tests
TestCanvasImagesCarryTheirTint(js/wasm): tinted, zero-tint and untinted image ops.TestCanvasImageTintnow skips itspixelsandoffscreencases on HarmonyOS, which does not draw those sources yet.cmd/nsgo/harmony: 21 passed, includingTestCommittedHostMatchesTemplates.go tool nsgo check -target harmonyos: vetted.Still open on #2003
TestCanvasImageTint(encoded) has not run on a HarmonyOS emulator or device, and the tint cache's release timing and memory use have not been observed on one.Screenshots
None. Not captured on a HarmonyOS device.