-
Notifications
You must be signed in to change notification settings - Fork 32
optimize the update loop #695
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,14 @@ export enum CoreNodeRenderState { | |
| InViewport = 8, | ||
| } | ||
|
|
||
| const NO_CLIPPING_RECT: RectWithValid = { | ||
| x: 0, | ||
| y: 0, | ||
| width: 0, | ||
| height: 0, | ||
| valid: false, | ||
| }; | ||
|
|
||
| const CoreNodeRenderStateMap: Map<CoreNodeRenderState, string> = new Map(); | ||
| CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init'); | ||
| CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds'); | ||
|
|
@@ -1038,10 +1046,6 @@ export class CoreNode extends EventEmitter { | |
| * @param delta | ||
| */ | ||
| update(delta: number, parentClippingRect: RectWithValid): void { | ||
| if (this.updateType === UpdateType.None) { | ||
| return; | ||
| } | ||
|
|
||
| const props = this.props; | ||
| const parent = props.parent; | ||
| const parentHasRenderTexture = this.parentHasRenderTexture; | ||
|
|
@@ -1052,6 +1056,9 @@ export class CoreNode extends EventEmitter { | |
| let updateType = this.updateType; | ||
| let childUpdateType = this.childUpdateType; | ||
| let updateParent = false; | ||
| // reset update type | ||
| this.updateType = 0; | ||
| this.childUpdateType = 0; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset happens at beginning of loop rather than end |
||
|
|
||
| if (updateType & UpdateType.Local) { | ||
| this.updateLocalTransform(); | ||
|
|
@@ -1212,6 +1219,7 @@ export class CoreNode extends EventEmitter { | |
|
|
||
| if (this.renderState === CoreNodeRenderState.OutOfBounds) { | ||
| updateType &= ~UpdateType.RenderBounds; // remove render bounds update | ||
| this.updateType = updateType; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just needed to be set back. Before this |
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -1229,26 +1237,23 @@ export class CoreNode extends EventEmitter { | |
| } | ||
|
|
||
| if (updateType & UpdateType.Children && this.children.length > 0) { | ||
| let childClippingRect = this.clippingRect; | ||
|
|
||
| if (this.rtt === true) { | ||
| childClippingRect = NO_CLIPPING_RECT; | ||
| } | ||
|
Comment on lines
+1240
to
+1244
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this check outside the for loop as its for the parent and not each child |
||
|
|
||
| for (let i = 0, length = this.children.length; i < length; i++) { | ||
| const child = this.children[i] as CoreNode; | ||
|
|
||
| child.setUpdateType(childUpdateType); | ||
| if (childUpdateType !== 0) { | ||
| child.setUpdateType(childUpdateType); | ||
| } | ||
|
Comment on lines
+1249
to
+1251
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip updating all children nodes and parent nodes if we're just resetting anyhow. |
||
|
|
||
| if (child.updateType === 0) { | ||
| continue; | ||
| } | ||
|
|
||
| let childClippingRect = this.clippingRect; | ||
| if (this.rtt === true) { | ||
| childClippingRect = { | ||
| x: 0, | ||
| y: 0, | ||
| width: 0, | ||
| height: 0, | ||
| valid: false, | ||
| }; | ||
| } | ||
|
|
||
| child.update(delta, childClippingRect); | ||
| } | ||
| } | ||
|
|
@@ -1283,10 +1288,6 @@ export class CoreNode extends EventEmitter { | |
| this.notifyChildrenRTTOfUpdate(renderState); | ||
| } | ||
| } | ||
|
|
||
| // reset update type | ||
| this.updateType = 0; | ||
| this.childUpdateType = 0; | ||
| } | ||
|
|
||
| private findParentRTTNode(): CoreNode | null { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed as the child for loop checks this.