-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
160 additions
and
205 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,28 @@ | ||
--- | ||
title: Caching | ||
description: Explanation of the criteria for generating drawing caches in Beutl | ||
title: Cache | ||
description: Explanation of render cache generation in Beutl | ||
--- | ||
|
||
## Cache | ||
Consider the following nodes: | ||
Consider the following nodes. | ||
``` | ||
1. Drawing Node | ||
1. Render Node | ||
2. └ Transform Node | ||
3. └ Effect Node | ||
4. └ Shape Node | ||
3. └ Effect Node (Drop Shadow, with animation) | ||
4. └ Effect Node (Outline) | ||
5. └ Shape Node | ||
``` | ||
Within the Effect Node: | ||
``` | ||
3-1. Border | ||
3-2. DropShadow (with animation) | ||
``` | ||
The Transform Node and Shape Node do not have animation. | ||
|
||
In conclusion, in this example, after a few frames are drawn, Beutl caches up to 3-1 within the Effect Node. | ||
The reasoning behind this is explained below. | ||
|
||
## Determining Cache Eligibility | ||
Beutl determines that caching is possible if the state remains the same for three or more frames. | ||
|
||
There are two methods for counting frames: | ||
1. Automatic Counting | ||
This method requires that the node remains unchanged, but it is very simple. | ||
The frame count increments during rendering, and resets to zero if the node changes. | ||
If the count reaches 3 or more, the node is deemed **cacheable**. | ||
|
||
2. Manual Counting | ||
This method applies to nodes implementing `ISupportRenderCache`. | ||
These nodes report how much remained the same compared to the previous frame. | ||
If the minimum value of the similarity over the last three frames is 1 or more, the node is deemed **cache-boundary eligible**. | ||
If all three frames are the same, the node is deemed **cacheable**. | ||
``` | ||
-> Frames | ||
1 2 3 4 | ||
3-1. ■ ■ ■ ■ | ||
3-2. ○ ● ○ ● | ||
``` | ||
In this case, the second frame and beyond would report `1/2`. | ||
|
||
After the fourth frame is rendered, the node is deemed **cache-boundary eligible**. | ||
> [!NOTE] | ||
> **Nodes that are ancestors of a cache-boundary node cannot be cached.** | ||
If a node is deemed **cache-boundary eligible** or **cacheable** and all its child nodes are **cacheable**, the drawing content of that node is cached. | ||
Transform Node and Shape Node have no animation. | ||
|
||
### Manual Control with ISupportRenderCache | ||
In conclusion, | ||
In this example, after a few frames are rendered, | ||
Beutl will cache up to the 4th effect node. | ||
Below is an explanation of why this happens. | ||
|
||
Nodes implementing `ISupportRenderCache` can manually control whether to cache, the process of saving the cache, and rendering using the cache. | ||
## Determining Cacheability | ||
If the same state persists for 3 or more frames, it is considered cacheable. | ||
During node rendering, a count is maintained, and if the node changes, the count is reset to zero. | ||
When this count reaches 3 or more, it is considered **cacheable**. | ||
|
||
This implementation allows partial caching of multiple effects, and is used within the Effect Node. | ||
If a node is **cacheable** and all its child elements are **cacheable**, | ||
the rendering content of that node is cached. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.