Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
7fbf3f9
Add WeChat mini program support for PAGX viewer.
jinwuwu001 Feb 24, 2026
6d1a835
Update tgfx to 1e9d0b986f8dcdd1fe9c710c72d2ea26cb9a3296.
jinwuwu001 Feb 24, 2026
a901b05
Enable OBJC and OBJCXX languages explicitly on Apple platform.
jinwuwu001 Feb 26, 2026
1c93fcf
Remove unnecessary useScale and firstFrame options from View.init in …
jinwuwu001 Feb 28, 2026
424ec9c
Merge origin main branch
jinwuwu001 Mar 10, 2026
235e449
Add three-step PAGX loading with external image support for WeChat Mi…
jinwuwu001 Mar 10, 2026
017c143
Fix wechat build by updating include paths and adding HarfBuzz and Sh…
jinwuwu001 Mar 10, 2026
bb53e10
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Mar 11, 2026
7fb4d10
Add canvas background color support from PAGX document attributes.
jinwuwu001 Mar 11, 2026
3ec5e02
Read canvas background from backGround layer customData instead of PA…
jinwuwu001 Mar 11, 2026
8d63ce5
Extract color parsing utilities from PAGXView into StringParser.h.
jinwuwu001 Mar 11, 2026
3f61282
Align ParseHexColor with PAGXImporter adding RGB shorthand and hex va…
jinwuwu001 Mar 11, 2026
7546f4b
Update background layer node name and skip color parsing when invisible.
jinwuwu001 Mar 12, 2026
77d9540
Replace std::stof with std::strtof to avoid potential exception crash.
jinwuwu001 Mar 12, 2026
16ee5b2
Add setBoundsOrigin and getContentTransform APIs for comment overlay …
jinwuwu001 Mar 12, 2026
1389d62
Replace getContentTransform with boundsOriginX and boundsOriginY gett…
jinwuwu001 Mar 12, 2026
1c91af9
Use WXS render-thread positioning for comment overlays to eliminate s…
jinwuwu001 Mar 12, 2026
4a2e15c
Fix WXS comment positioning by binding change:prop to each pin node.
jinwuwu001 Mar 12, 2026
d9b3ff9
Add getContentTransform API and comment overlay coordinate conversion…
jinwuwu001 Mar 13, 2026
e243471
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Mar 13, 2026
4841f92
update comment-bindding-guide.md
jinwuwu001 Mar 13, 2026
f3a0d24
Remove boundsOriginX and boundsOriginY getter APIs from PAGXView.
jinwuwu001 Mar 16, 2026
6be1b4d
Pre-register resource IDs in parseResources to resolve cross-referenc…
jinwuwu001 Mar 18, 2026
d2cd031
Add unit tests for PAGX resource cross-reference resolution.
jinwuwu001 Mar 18, 2026
662f29e
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Mar 19, 2026
ce7f5a1
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Mar 20, 2026
2935fc2
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Mar 27, 2026
a5792f8
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Mar 30, 2026
9e36964
Add ImagePattern matrix resolver and fix wechat build for PAGX SVG su…
jinwuwu001 Mar 30, 2026
19c00b3
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 9, 2026
57fe96b
Add image caching and downsampling to reduce WASM memory usage in WeC…
jinwuwu001 Apr 7, 2026
b7ae9fc
Disable scaling below 1:1 and scrollRect clipping for first frame opt…
jinwuwu001 Apr 13, 2026
a7192d5
Add performance logging for PAGX parsing and rendering pipeline.
jinwuwu001 Apr 13, 2026
d1d563d
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 14, 2026
ba94458
merge origin main branch
jinwuwu001 Apr 14, 2026
78312a6
Adapt pagx/wechat to new TextLayout and LayerBuilder API changes.
jinwuwu001 Apr 14, 2026
635cfdb
Disable scrollRect clipping for first frame optimization.
jinwuwu001 Apr 14, 2026
f0358e7
Add image caching and downsampling to reduce WASM memory usage.
jinwuwu001 Apr 14, 2026
2d89bd5
Add performance logging for PAGX parsing pipeline.
jinwuwu001 Apr 14, 2026
827f997
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 16, 2026
506ba6e
delete debug log
jinwuwu001 Apr 16, 2026
e7ceacc
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 20, 2026
3b68fb2
Add PAGXView.getNodePosition API and wechat image-decode POC page and…
jinwuwu001 Apr 21, 2026
54202f3
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 22, 2026
f1e52d4
Log per-stage draw timings when a frame exceeds the slow frame thresh…
richardshan0614 Apr 23, 2026
acfe24d
Enable mipmaps for PAGX images and tune WASM cache to eliminate pan-z…
richardshan0614 Apr 24, 2026
b2c4798
Decode PAGX images through the WeChat host decoder instead of wasm-si…
richardshan0614 Apr 27, 2026
091c0a8
Add npm package.json
jinwuwu001 Apr 28, 2026
46f4ef3
Update script
jinwuwu001 Apr 28, 2026
3d29019
Publish pagx-viewer-miniprogram
jinwuwu001 Apr 28, 2026
cf765a5
Publish 1.6.0
jinwuwu001 Apr 29, 2026
edc9e8e
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 Apr 29, 2026
9920edc
Fix misaligned image pattern matrix after progressive image upgrade b…
richardshan0614 Apr 29, 2026
7ef7bfa
Add English and Chinese build readme for pagx wechat module.
jinwuwu001 Apr 29, 2026
aa9b2dd
Add scripts
jinwuwu001 Apr 30, 2026
7889917
Fix ImagePattern TILE tile period regression when progressive image l…
richardshan0614 Apr 30, 2026
ed78af6
Upgrade tgfx to preserve live GPU cache entries across brief referenc…
richardshan0614 May 1, 2026
a287a32
Merge remote-tracking branch 'origin/feature/billyjin_pagx_new' into …
richardshan0614 May 1, 2026
0208532
Upgrade tgfx to extend per-frame diagnostic counters and GPU cache pr…
richardshan0614 May 1, 2026
d6b2696
Update tgfx to cap dirty tiles per frame for smoother zoom and pan.
richardshan0614 May 2, 2026
f6a36a4
Disable tile throttling during zoom-in so texture-invalidation no lon…
richardshan0614 May 3, 2026
58a8067
Composite cached and fit snapshots during WeChat PAGX pan/zoom to avo…
fengdyli May 3, 2026
607ade7
Add a compile-time switch to silence draw-path telemetry logs in ship…
richardshan0614 May 3, 2026
7e67ba8
Force OffscreenCanvas GPU flush in decodeImageFromPath so iOS WeChat …
richardshan0614 May 7, 2026
86d7356
Cap iOS WeChat GPU cache at 512MB to avoid the mini-program being ter…
richardshan0614 May 7, 2026
065da0a
Raise iOS WeChat GPU cache from 512MB to 768MB to reduce pan/zoom evi…
richardshan0614 May 7, 2026
633f6ea
Bump tgfx to a8c07e4b which simplifies tile throttle and free-tile ha…
richardshan0614 May 7, 2026
8b4b2af
Lower iOS WeChat GPU cache from 768MB back to 512MB after 768MB still…
richardshan0614 May 7, 2026
f1c2d38
Capture an HD offscreen fit snapshot for super-wide PAGX, drop the ca…
fengdyli May 8, 2026
a18f53e
Add compile switches to skip layer effects and snapshot fast path for…
richardshan0614 May 9, 2026
279dd35
Remove PAGX_ENABLE_SNAPSHOT_FAST_PATH switch and restore the fast pat…
richardshan0614 May 9, 2026
02316c1
Bring the cached overlay back: capture the surface on gesture start a…
fengdyli May 9, 2026
15b58d9
Merge remote-tracking branch 'origin/feature/billyjin_pagx_new' into …
richardshan0614 May 9, 2026
7e0619b
Cache TextBlob across identical Text nodes to cut wasm heap by 80% wh…
richardshan0614 May 11, 2026
8da10ee
Drop the cached overlay snapshot pipeline and rely only on the HD fit…
fengdyli May 11, 2026
808028b
Flush + submit immediately after capturing the fit snapshot so the de…
fengdyli May 11, 2026
25d749a
Add memory probes for image memory profiling.
richardshan0614 May 12, 2026
d1a81b3
Manage GL textures inside PAGXView to stabilize backend-texture memor…
richardshan0614 May 14, 2026
02c4cab
Drop per-path full LRU evict log to avoid console flooding under tigh…
richardshan0614 May 14, 2026
10ac25d
Cache typefaces by Font node so large PAGX documents no longer rebuil…
richardshan0614 May 18, 2026
41bfb54
Untrack local-only copy-to-cocraft helper script and ignore it going …
richardshan0614 May 20, 2026
f989ef4
Remove tracked copy-to-cocraft helper that was never meant to be in t…
richardshan0614 May 20, 2026
11e80c6
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 May 25, 2026
20c2cb2
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 May 27, 2026
e3af104
Add WeChat miniprogram viewport gesture APIs.
fengdyli May 27, 2026
db986a8
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 May 27, 2026
d763307
Harden pagx-check XML parser for quoted attrs entities and doctype.
jinwuwu001 May 28, 2026
cca9390
Document platform-specific score thresholds for pagx-check usage.
jinwuwu001 May 28, 2026
b052fe4
Sync pagx-check doc comments with actual tier baseline and risk paths.
jinwuwu001 May 28, 2026
8c304b3
Add setSnapshotEnabled API to disable fit snapshot for fresh per-fram…
jinwuwu001 May 28, 2026
615a4ea
Merge branch 'main' of github.com:Tencent/libpag
jinwuwu001 May 28, 2026
c5e85c5
Release pagx miniprogram v1.9.1 with explicit View and CheckPagx typi…
jinwuwu001 May 29, 2026
137da56
Merge main branch
jinwuwu001 Jun 1, 2026
26d4bff
Publish pagx-viewer
jinwuwu001 Jun 1, 2026
0126786
Upgrade tgfx
richardshan0614 Jun 2, 2026
8b20159
Merge origin
richardshan0614 Jun 2, 2026
aea2988
Refine PAGX progressive image upgrade with original-size aware matric…
jinwuwu001 Jun 4, 2026
2755220
Update tgfx to fix fallback tile crack issue in display list rendering.
richardshan0614 Jun 4, 2026
f61990e
Merge remote-tracking branch 'origin/feature/billyjin_pagx_new' into …
richardshan0614 Jun 4, 2026
86a805c
feat: refine CheckPagx risk scoring
fengdyli Jun 4, 2026
9418813
fix: avoid over-penalizing image metadata risk
fengdyli Jun 4, 2026
97796f4
Publish pagx-viewer
jinwuwu001 Jun 4, 2026
bf2b500
Fix iOS P3 color shift by properly setting drawingBufferColorSpace to…
richardshan0614 Jun 5, 2026
296eae5
Revert "Fix iOS P3 color shift by properly setting drawingBufferColor…
richardshan0614 Jun 5, 2026
0294088
Update tgfx commit to fix sNaN quieting in vertex color packing.
richardshan0614 Jun 5, 2026
d001cb3
Merge remote-tracking branch 'origin/feature/billyjin_pagx_new' into …
richardshan0614 Jun 5, 2026
51c8246
Fix WASM heap out-of-bounds in attachNativeImage by receiving filePat…
jinwuwu001 Jun 8, 2026
59c9256
Publish pagxviewer
jinwuwu001 Jun 8, 2026
997fba4
Adapt WeChat system-info APIs for base-library version differences.
jinwuwu001 Jun 9, 2026
1bbdf42
Delete debug log
jinwuwu001 Jun 9, 2026
514fb1d
Merge branch 'main' into feature/billyjin_pagx_new_tmp
jinwuwu001 Jun 10, 2026
2d2bd79
Fix build errors after merging main into feature branch.
jinwuwu001 Jun 10, 2026
7d8b9be
Update copy-files.js
jinwuwu001 Jun 10, 2026
22c36d5
Merge branch 'feature/billyjin_pagx_new_tmp' into feature/billyjin_pa…
jinwuwu001 Jun 10, 2026
8704937
Clean up WeChat demo and update documentation.
jinwuwu001 Jun 10, 2026
75f2914
Publish pagxviewer
jinwuwu001 Jun 12, 2026
794164c
Merge origin main
jinwuwu001 Jun 12, 2026
f74a713
Update tgfx version
jinwuwu001 Jun 12, 2026
e12bfb3
Refactor PAGXView logging and add NO_LOG build option.
jinwuwu001 Jun 12, 2026
52d44f8
Fix code review issues: remove debug paths, fix comments, and simplif…
jinwuwu001 Jun 12, 2026
2b40aa5
Fix code review issues in pagx/wechat module.
jinwuwu001 Jun 12, 2026
8d33fdb
Clean up pagx core by removing dead XML counters and replacing lambda…
jinwuwu001 Jun 12, 2026
f334d6f
Refactor wechat native code to drop dead snapshot state make probe pe…
jinwuwu001 Jun 12, 2026
0aa9917
Fix wechat build scripts ESM and POSIX issues texture and canvas rele…
jinwuwu001 Jun 12, 2026
672f57f
Fix wechat view init to release RenderCanvas on partial init failure …
jinwuwu001 Jun 15, 2026
6b65930
Harden wechat build scripts with copy error handling missing marker w…
jinwuwu001 Jun 15, 2026
c33e50a
Consolidate PAGXDocument image-field setters add cstring include and …
jinwuwu001 Jun 15, 2026
9274774
Guard wechat view init autoRender and gesture updateSize dedupe risk …
jinwuwu001 Jun 15, 2026
c9d21c2
Fix buildWithMap dropping the runtime binding so top-level layer anim…
jinwuwu001 Jun 15, 2026
838f107
Fall back to node image proportional stretch when STRETCH paint trans…
jinwuwu001 Jun 15, 2026
e1d7196
Update miniprogram README install example version to match 1.9.5 head…
jinwuwu001 Jun 15, 2026
8521ada
Standardize doc canvas type to webgl to match the shipped wx demo.
jinwuwu001 Jun 15, 2026
01902c5
Consolidate default background color to the shared DefaultBackgroundC…
jinwuwu001 Jun 15, 2026
07e1550
Remove unused XML DOM parser performance counters and their getters.
jinwuwu001 Jun 15, 2026
ab08404
Reset premultiply flag and free texture on createBackendTexture error…
jinwuwu001 Jun 15, 2026
c32346c
Guard standard-source texImage2D path so a throw cannot leak texture …
jinwuwu001 Jun 15, 2026
ac203d9
Remove dead private resetSize method from PAGXView with no call site.
jinwuwu001 Jun 15, 2026
be356ed
Gate draw per-stage timing probes behind DRAW_LOG_ENABLED to strip th…
jinwuwu001 Jun 15, 2026
7b99e15
Subtract the replaced same-path entry in the thumbnail budget project…
jinwuwu001 Jun 15, 2026
4257dd5
Skip stroke with unloaded ImagePattern instead of painting opaque bla…
jinwuwu001 Jun 15, 2026
c23189e
Extract shared Uint8Array copy helper for the tgfx and pagx Data conv…
jinwuwu001 Jun 15, 2026
b304a08
Remove unused content/dpr params from gesture manager and update call…
jinwuwu001 Jun 15, 2026
4923532
Extract recordDecodedImage helper for shared image-decode accounting …
jinwuwu001 Jun 15, 2026
baf6030
Bail out of draw idle short-circuit when image uploads are pending.
jinwuwu001 Jun 15, 2026
86c7268
Fix attachNativeImage doc to reference the actual decodeImageFromPath…
jinwuwu001 Jun 15, 2026
056cb55
Remove unused wx import and declaration from babel polyfill module.
jinwuwu001 Jun 15, 2026
4493671
Fix stale npm script names in WeChat README zh_CN to match package.js…
jinwuwu001 Jun 15, 2026
c30be57
Skip fitSnapshot blit fast path when image uploads are pending.
jinwuwu001 Jun 15, 2026
8bdf086
Mark babel polyfill as a module so ambient globalThis declaration sta…
jinwuwu001 Jun 15, 2026
33e1e63
Delete debug log
jinwuwu001 Jun 15, 2026
3dc2719
Track hand-written demo performance-monitor so the viewer builds on a…
jinwuwu001 Jun 15, 2026
66cd3b7
Move PAGX document size and custom data parsing to parsePAGX so conte…
jinwuwu001 Jun 15, 2026
5550539
Translate Chinese comments to English in pagx wechat tracked source f…
jinwuwu001 Jun 15, 2026
cef3867
Publish pagxviewer
jinwuwu001 Jun 16, 2026
9c62443
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 16, 2026
acda7a1
Accept updated PAGX test baselines for mipmapped image rendering.
jinwuwu001 Jun 16, 2026
a29ca42
Merge main branch
jinwuwu001 Jun 16, 2026
5d4d176
Use emscripten val for file path params in JS-facing PAGXView APIs.
jinwuwu001 Jun 17, 2026
36938a0
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 17, 2026
c6b0b05
Update screenshot baseline for SwiftShader compatibility.
jinwuwu001 Jun 17, 2026
2cd8922
Remove deprecated loadFileDataAsNativeImage and upgradeImageFromNativ…
jinwuwu001 Jun 18, 2026
187263f
Address PR review comments: cache invalidation, const-ref returns, me…
jinwuwu001 Jun 18, 2026
dcd56a5
Extract pagx-check into standalone module independent of WASM renderer.
jinwuwu001 Jun 18, 2026
7837689
Merge pagx-viewer-miniprogram into pagx/wechat and rename its README …
jinwuwu001 Jun 18, 2026
505b940
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 18, 2026
a2a55e5
Add pagx-check.js to copy-files and abort on missing source files.
jinwuwu001 Jun 18, 2026
3764c35
Document why emsdk 3.1.20 is a hard constraint for WeChat Mini Program.
jinwuwu001 Jun 18, 2026
6be67a4
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 22, 2026
d4f988e
Fix review comments on Image.h thumbnail annotation, API return docs,…
jinwuwu001 Jun 22, 2026
b92c17a
Merge branch 'feature/billyjin_pagx_new' of github.com:Tencent/libpag…
jinwuwu001 Jun 22, 2026
3545838
Remove docs directory from tracking and add it to gitignore.
jinwuwu001 Jun 22, 2026
82cd75d
Refactor image resource management into ImageResourceProvider interface.
jinwuwu001 Jun 23, 2026
2ef0d01
Change imageResourceProvider() to return raw pointer instead of share…
jinwuwu001 Jun 23, 2026
943d9f5
Pass document to RefreshLayerInPlace and BuildLayerInto to fix null d…
jinwuwu001 Jun 23, 2026
f235f21
Merge origin main
jinwuwu001 Jun 23, 2026
bc9019e
accept baseline
jinwuwu001 Jun 23, 2026
bb0e8e2
Exclude woff2-dependent and SVG/HTML export sources from wechat wasm …
jinwuwu001 Jun 23, 2026
d5e0715
accept baseline
jinwuwu001 Jun 23, 2026
9f3251a
Suppress warnings for third-party rttr library to fix QT viewer build.
jinwuwu001 Jun 23, 2026
481de45
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 24, 2026
2e02f15
Move imageResourceProvider() and findLayersByImageFilePath() from pub…
jinwuwu001 Jun 24, 2026
6af3717
Remove imageResourceProvider() getter entirely, access member directl…
jinwuwu001 Jun 24, 2026
f36a0a6
Replace LayerBuilder friend with LayerBuilderContext friend to elimin…
jinwuwu001 Jun 24, 2026
3fce77c
Merge branch 'feature/billyjin_pagx_new' of github.com:Tencent/libpag…
jinwuwu001 Jun 24, 2026
d1d0381
Merge branch 'main' into feature/billyjin_pagx_new
jinwuwu001 Jun 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ cli/npm/package-lock.json
# PAGX verify artifacts
*.layout.xml

# Local-only helper scripts (not part of the project)
pagx/wechat/script/copy-to-cocraft.js
65 changes: 65 additions & 0 deletions include/pagx/ImageResourceProvider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tencent is pleased to support the open source community by making libpag available.
//
// Copyright (C) 2026 Tencent. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// unless required by applicable law or agreed to in writing, software distributed under the
// license is distributed on an "as is" basis, without warranties or conditions of any kind,
// either express or implied. see the license for the specific language governing permissions
// and limitations under the license.
//
/////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include <memory>
#include <string>

namespace tgfx {
class Image;
}

namespace pagx {

/**
* Provides pre-decoded image resources to the rendering pipeline. Platform-specific implementations
* can manage their own caching, eviction, and progressive loading strategies without coupling
* decoded image state to the document model layer.
*
* The renderer queries this provider during layer building. When resolveImage() returns non-null,
* the renderer uses that image directly and skips all codec-based decoding paths (embedded data,
* data URI, file path). When it returns nullptr, the renderer falls back to the standard decoding
* chain.
*
* Thread safety: the provider is accessed only on the render thread (inside draw()/flush()), so
* implementations do not need internal synchronization unless they share state with other threads.
*/
class ImageResourceProvider {
public:
virtual ~ImageResourceProvider() = default;

/**
* Resolves a pre-decoded image for the given external file path. The implementation decides
* which quality level to return (full, thumbnail, or nullptr for fallback).
* @param filePath the external file path as declared in the PAGX document's Image node.
* @return A tgfx::Image ready for rendering, or nullptr to signal the renderer should decode
* from embedded data / file path.
*/
virtual std::shared_ptr<tgfx::Image> resolveImage(const std::string& filePath) = 0;

/**
* Returns true if the provider currently holds any decoded image (full or thumbnail) for the
* given path. Used by getExternalFilePaths() to exclude paths that already have a decoded
* counterpart, preventing redundant network fetches.
* @param filePath the external file path to check.
*/
virtual bool hasImage(const std::string& filePath) const = 0;
};

} // namespace pagx
31 changes: 30 additions & 1 deletion include/pagx/PAGXDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <unordered_set>
#include <vector>
#include "pagx/FontConfig.h"
#include "pagx/ImageResourceProvider.h"
#include "pagx/nodes/Animation.h"
#include "pagx/nodes/Layer.h"
#include "pagx/nodes/Node.h"
Expand All @@ -33,6 +34,8 @@ namespace pagx {

class LayoutContext;
class PAGScene;
class Image;
class ImagePattern;

/**
* PAGXDocument is the root container for a PAGX document.
Expand Down Expand Up @@ -126,7 +129,9 @@ class PAGXDocument : public Node {

/**
* Returns a list of external file paths referenced by Image nodes or external composition layers
* that have no embedded data. Data URIs (paths starting with "data:") are excluded.
* that have no embedded data. Data URIs (paths starting with "data:") are excluded. Image nodes
* for which the current ImageResourceProvider already holds a decoded counterpart are also
* excluded so the same resource is not fetched twice.
*/
std::vector<std::string> getExternalFilePaths() const;

Expand All @@ -143,6 +148,17 @@ class PAGXDocument : public Node {
*/
bool loadFileData(const std::string& filePath, std::shared_ptr<Data> data);

/**
* Sets the image resource provider used by the rendering pipeline to resolve pre-decoded images.
* When set, getExternalFilePaths() consults the provider to exclude paths that already have a
* decoded counterpart. The renderer queries the provider during layer building via
* resolveImage().
*
* Passing nullptr removes the provider; the renderer will use only embedded data / file paths.
* @param provider the platform-specific image resource provider, or nullptr to remove.
*/
void setImageResourceProvider(std::shared_ptr<ImageResourceProvider> provider);

/**
* Executes auto layout on the document, positioning layers according to their layout
* constraints. Must be called before rendering or font embedding. Re-running layout on an
Expand Down Expand Up @@ -234,6 +250,9 @@ class PAGXDocument : public Node {

private:
PAGXDocument() = default;

const std::vector<const Layer*>& findLayersByImageFilePath(const std::string& imageFilePath);

// Recursive layout worker. visited holds the documents on the current ancestor path so an
// externalDoc cycle built directly through the API (bypassing loadFileData's own chain guard)
// is detected and stops the recursion instead of overflowing the stack.
Expand All @@ -247,6 +266,7 @@ class PAGXDocument : public Node {
void registerLiveScene(const std::shared_ptr<PAGScene>& scene);
void unregisterLiveScene(PAGScene* scene);

std::shared_ptr<ImageResourceProvider> _imageResourceProvider = nullptr;
FontConfig fontConfig;
bool layoutApplied = false;
std::unordered_map<std::string, Node*> nodeMap = {};
Expand All @@ -257,11 +277,20 @@ class PAGXDocument : public Node {
// does not keep PAGScene alive; expired entries are pruned during notifyChange.
std::vector<std::weak_ptr<PAGScene>> liveScenes = {};

// Lazily built index of Image node filePath -> pagx Layer list, used by
// findLayersByImageFilePath(). Built on first query; invalidated by notifyChange() since edits
// may alter the tree topology or Image node filePath values. Also freed when the document is
// destroyed (on the next parsePAGX() call).
std::unordered_map<std::string, std::vector<const Layer*>> layersByImageFilePath = {};
bool layersByImageFilePathBuilt = false;

friend class PAGXImporter;
friend class PAGXExporter;
friend class TextLayoutContext;
friend class PAGScene;
friend class PAGComposition;
friend class LayerBuilderContext;
friend class LayerBuilderSession;
};

} // namespace pagx
5 changes: 3 additions & 2 deletions include/pagx/nodes/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ namespace pagx {

/**
* Image represents an image resource that can be referenced by other nodes. The image source can
* be a file path, a URL, or a base64-encoded data URI.
* be a file path, a URL, or a base64-encoded data URI. Platform-specific decoded images are
* managed externally via ImageResourceProvider, not stored on this node.
*/
class Image : public Node {
public:
/**
* Image binary data (decoded from base64).
* Image binary data (decoded from base64 or loaded via loadFileData).
*/
std::shared_ptr<Data> data = nullptr;

Expand Down
15 changes: 15 additions & 0 deletions pagx/wechat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build outputs
wasm-mt/
wasm/
dist/

# Build cache
script/build-pagx-viewer/
script/wasm-mt/
script/.build.lock
.*.md5
package-lock.json
ts/wasm
types/
lib/
docs/
Loading
Loading