Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Branch #482

Merged
merged 68 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
bc48d6d
feature: Implement Texture Throttling
wouterlucas Dec 4, 2024
34a5e6d
feat: Add priority uploads and add default texture
wouterlucas Dec 5, 2024
456b3db
fix: Remove microTask for loading ctx Textures as it creates a race c…
wouterlucas Dec 5, 2024
802feb4
refactor: Enhance texture state management
wouterlucas Dec 9, 2024
13c3435
feat: Add stress test for rendering various texture types and colors
wouterlucas Dec 9, 2024
1cb85e8
fix: Implement rerender method to request rendering from the stage
wouterlucas Dec 9, 2024
c4cc963
fix: RTT texture should load immediately
wouterlucas Dec 9, 2024
8932338
fix: Origin error when using Image() constructor
wouterlucas Dec 10, 2024
749aa71
refactor: Replace loadTexture with createTexture for improved texture…
wouterlucas Dec 10, 2024
bfb4b84
fix: new Image texture on Canvas
pecoram Dec 11, 2024
381296a
fix: condition
pecoram Dec 11, 2024
9653518
fix: new Image texture on Canvas (#470)
wouterlucas Dec 11, 2024
cb661fd
Update src/core/textures/ImageTexture.ts
wouterlucas Dec 11, 2024
7b9353f
fix: Origin error when using Image() constructor (#469)
wouterlucas Dec 11, 2024
a38f216
feat: add optional external canvas for rendering
wouterlucas Dec 11, 2024
e3ce162
Merge branch 'main' into feat/texture-throttling
wouterlucas Dec 11, 2024
c8b614c
Merge branch 'main' into feat/texture-throttling
wouterlucas Dec 11, 2024
c2f0119
fix: Fix canvas default texture handling
wouterlucas Dec 11, 2024
0aed451
feat: Introduce textureProcessingLimit flag to control texture batchi…
wouterlucas Dec 11, 2024
2a32846
chore: Remove leftover init to image worker
wouterlucas Dec 11, 2024
25dcbfb
fix: Fix caching, cleanup old comments, fix factory test
wouterlucas Dec 11, 2024
3b54f9f
fix: safari 9 HTMLImageElement check
pecoram Dec 12, 2024
fe25630
fix: parentheses
pecoram Dec 12, 2024
92370a4
fix: typo
pecoram Dec 12, 2024
04771d9
fix: added HTMLImageElement existence check
pecoram Dec 12, 2024
83f8c91
refactor: added tdata variable
pecoram Dec 12, 2024
0205760
fix: Update overlayText event handling to filter by type
wouterlucas Dec 12, 2024
1fe5520
chore: Fix RTT with TT
wouterlucas Dec 13, 2024
5c0d6c2
fix: safari9 canvas IndexSizeError
pecoram Dec 13, 2024
6e4ff84
fix: Ignore loaded events for 1x1 textures
wouterlucas Dec 13, 2024
93e5473
fix: Subtexture parent load and add test
wouterlucas Dec 13, 2024
c676746
fix: SubTexture caching & loading, duplicate textures, image error ha…
wouterlucas Dec 15, 2024
b90b724
fix: safari 9 HTMLImageElement check (#473)
wouterlucas Dec 16, 2024
6f8e057
2.9.0-beta2
wouterlucas Dec 16, 2024
32ea148
fix: Set core ctx state for parent texture if ctxTexture is defined
wouterlucas Dec 16, 2024
8158f2e
fix: Simplify condition for setting default texture in CoreNode
wouterlucas Dec 16, 2024
aea2768
fix: Avoid object assigning ctxTexture that just lives on the this
wouterlucas Dec 16, 2024
cfe035e
feat: add optional external canvas for rendering (#471)
wouterlucas Dec 17, 2024
e60bda3
fix: Refactor CoreTextNode and CanvasTextRenderer for improved textur…
wouterlucas Dec 17, 2024
4673e90
fix: Implement priority queue when CoreTextreManager is still initial…
wouterlucas Dec 17, 2024
18014a6
test: Add automation tests for various ways of font rendering
wouterlucas Dec 17, 2024
a4f29cc
fix: Update premultiplyAlpha handling in WebGlCoreCtxTexture and rela…
wouterlucas Dec 17, 2024
895e76c
fix: Update parent reference in text-mixed test example
wouterlucas Dec 17, 2024
b2d5dbb
Revert "fix: Refactor CoreTextNode and CanvasTextRenderer for improve…
wouterlucas Dec 17, 2024
87554db
fix: Refactor createImageWorker to utilize options for createImageBit…
wouterlucas Dec 18, 2024
fac109e
chore: update CI snapshots
wouterlucas Dec 18, 2024
5e9334f
Merge branch 'main' into feat/texture-throttling
wouterlucas Dec 18, 2024
048b2b2
chore: cleanup
wouterlucas Dec 18, 2024
e0cd04c
refactor: WebGlCoreCtxTexture to support RGB format if texture has no…
wouterlucas Dec 18, 2024
4af99df
feat: add textureProcessingLimit parameter to examples
wouterlucas Dec 18, 2024
7a0fafb
fix: Support for color texture in Canvas renderer, align with latest …
wouterlucas Dec 18, 2024
c58eda3
Introduce Texture Throttling (#472)
wouterlucas Dec 19, 2024
bd2186d
2.9.0-beta3
wouterlucas Dec 19, 2024
8edc3f2
fix: radialGradient cache key was using linearGradient
chiefcll Dec 30, 2024
2d61487
refactor: Improve render texture loading with throttling
wouterlucas Jan 7, 2025
27bf944
refactor: Update texture state management and rendering logic in Core…
wouterlucas Jan 7, 2025
e31f190
fix: Set source state to 'freed' when texture data is cleared
wouterlucas Jan 7, 2025
422d51e
🎨 Refactor CoreNode Renderability Logic 🚀 (#476)
wouterlucas Jan 8, 2025
6174898
fix: radialGradient cache key was using linearGradient (#474)
wouterlucas Jan 8, 2025
c01a534
refactor: Simplify renderability checks
wouterlucas Jan 9, 2025
1bdb75e
chore: cleanup leftover comment
wouterlucas Jan 9, 2025
a168da4
chore: remove no longer needed If check
wouterlucas Jan 10, 2025
ad55881
Refactor isRenderable detection (#479)
wouterlucas Jan 10, 2025
97a92f7
fix: added missing check for shader existence
pecoram Jan 10, 2025
e97e717
fix: added missing check for shader existence (#480)
wouterlucas Jan 10, 2025
dc46121
fix: prevent cleanup of SDF Font Face textures for now
wouterlucas Jan 10, 2025
9ed53da
fix: prevent cleanup of SDF Font Face textures for now (#481)
wouterlucas Jan 10, 2025
d914169
2.9.0-beta4
wouterlucas Jan 10, 2025
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
188 changes: 146 additions & 42 deletions src/core/CoreNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,55 +17,73 @@
* limitations under the License.
*/

import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { CoreNode, type CoreNodeProps, UpdateType } from './CoreNode.js';
import { Stage } from './Stage.js';
import { mock } from 'vitest-mock-extended';
import { type TextureOptions } from './CoreTextureManager.js';
import { type BaseShaderController } from '../main-api/ShaderController';
import { createBound } from './lib/utils.js';
import { ImageTexture } from './textures/ImageTexture.js';

describe('set color()', () => {
const defaultProps: CoreNodeProps = {
alpha: 0,
autosize: false,
clipping: false,
color: 0,
colorBl: 0,
colorBottom: 0,
colorBr: 0,
colorLeft: 0,
colorRight: 0,
colorTl: 0,
colorTop: 0,
colorTr: 0,
height: 0,
mount: 0,
mountX: 0,
mountY: 0,
parent: null,
pivot: 0,
pivotX: 0,
pivotY: 0,
rotation: 0,
rtt: false,
scale: 0,
scaleX: 0,
scaleY: 0,
shader: mock<BaseShaderController>(),
src: '',
texture: null,
textureOptions: {} as TextureOptions,
width: 0,
x: 0,
y: 0,
zIndex: 0,
zIndexLocked: 0,
preventCleanup: false,
strictBounds: false,
};
const defaultProps: CoreNodeProps = {
alpha: 0,
autosize: false,
clipping: false,
color: 0,
colorBl: 0,
colorBottom: 0,
colorBr: 0,
colorLeft: 0,
colorRight: 0,
colorTl: 0,
colorTop: 0,
colorTr: 0,
height: 0,
mount: 0,
mountX: 0,
mountY: 0,
parent: null,
pivot: 0,
pivotX: 0,
pivotY: 0,
rotation: 0,
rtt: false,
scale: 0,
scaleX: 0,
scaleY: 0,
shader: mock<BaseShaderController>(),
src: '',
texture: null,
textureOptions: {} as TextureOptions,
width: 0,
x: 0,
y: 0,
zIndex: 0,
zIndexLocked: 0,
preventCleanup: false,
strictBounds: false,
};

const clippingRect = {
x: 0,
y: 0,
width: 200,
height: 200,
valid: false,
};

const stage = mock<Stage>({
strictBound: createBound(0, 0, 200, 200),
preloadBound: createBound(0, 0, 200, 200),
defaultTexture: {
state: 'loaded',
},
});

describe('set color()', () => {
it('should set all color subcomponents.', () => {
const node = new CoreNode(mock<Stage>(), defaultProps);
const node = new CoreNode(stage, defaultProps);
node.colorBl = 0x99aabbff;
node.colorBr = 0xaabbccff;
node.colorTl = 0xbbcceeff;
Expand All @@ -85,11 +103,97 @@ describe('set color()', () => {
});

it('should set update type.', () => {
const node = new CoreNode(mock<Stage>(), defaultProps);
const node = new CoreNode(stage, defaultProps);
node.updateType = 0;

node.color = 0xffffffff;

expect(node.updateType).toBe(UpdateType.PremultipliedColors);
});
});

describe('isRenderable checks', () => {
it('should return false if node is not renderable', () => {
const node = new CoreNode(stage, defaultProps);
expect(node.isRenderable).toBe(false);
});

it('visible node that is a color texture', () => {
const node = new CoreNode(stage, defaultProps);
node.alpha = 1;
node.x = 0;
node.y = 0;
node.width = 100;
node.height = 100;
node.color = 0xffffffff;

node.update(0, clippingRect);
expect(node.isRenderable).toBe(true);
});

it('visible node that is a texture', () => {
const node = new CoreNode(stage, defaultProps);
node.alpha = 1;
node.x = 0;
node.y = 0;
node.width = 100;
node.height = 100;
node.texture = mock<ImageTexture>({
state: 'initial',
});

node.update(0, clippingRect);
expect(node.isRenderable).toBe(false);

node.texture.state = 'loaded';
node.setUpdateType(UpdateType.IsRenderable);
node.update(1, clippingRect);

expect(node.isRenderable).toBe(true);
});

it('a node with a texture with alpha 0 should not be renderable', () => {
const node = new CoreNode(stage, defaultProps);
node.alpha = 0;
node.x = 0;
node.y = 0;
node.width = 100;
node.height = 100;
node.texture = mock<ImageTexture>({
state: 'loaded',
});

node.update(0, clippingRect);
expect(node.isRenderable).toBe(false);
});

it('a node with a texture that is OutOfBounds should not be renderable', () => {
const node = new CoreNode(stage, defaultProps);
node.alpha = 1;
node.x = 300;
node.y = 300;
node.width = 100;
node.height = 100;
node.texture = mock<ImageTexture>({
state: 'loaded',
});

node.update(0, clippingRect);
expect(node.isRenderable).toBe(false);
});

it('a node with a freed texture should not be renderable', () => {
const node = new CoreNode(stage, defaultProps);
node.alpha = 1;
node.x = 0;
node.y = 0;
node.width = 100;
node.height = 100;
node.texture = mock<ImageTexture>({
state: 'freed',
});

node.update(0, clippingRect);
expect(node.isRenderable).toBe(false);
});
});
Loading
Loading