• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mobalazs / rotor-framework / 18919729013

29 Oct 2025 07:21PM UTC coverage: 85.379% (-0.1%) from 85.479%
18919729013

push

github

mobalazs
fix: update debug setting in bsconfig to enable debugging

1781 of 2086 relevant lines covered (85.38%)

1.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.83
/src/source/engine/builder/NodePool.bs
1
' ===== NODE POOL =====
2
namespace Rotor.ViewBuilder
3

4
    ' =====================================================================
5
    ' NodePool - Manages reusable pools of SceneGraph nodes to improve performance. Optimized for pooling Group nodes and types extending Group (like Poster), as well as other common nodes (e.g., Rectangle, Label). Includes node reset logic upon release.
6
    ' =====================================================================
7
    class NodePool
8

9
        frameworkInstance as Rotor.Framework
10

11
        config = {
12
            nodePool: [{
13
                    nodeType: "Group",
14
                    amount: 1
15
                }, {
16
                    nodeType: "Rectangle",
17
                    amount: 1
18
                }, {
19
                    nodeType: "Poster",
20
                    amount: 1
21
                }, {
22
                    nodeType: "Label",
23
                    amount: 1
24
                }
25
            ]
26
        }
27

28
        pools = {}
29
        poolInfo = {
30
            totalAcquiredNodes: 0, ' Configured and acquired nodes from pools
31
            totalReleasedNodes: 0, ' Released nodes back to pools
32
            outOfStockNodes: {}, ' Nodes that out of stock
33
            poolFulness: {} ' Current amount of nodes in each pool
34
        }
35

36
        ' ---------------------------------------------------------------------
37
        ' new - Initializes the instance
38
        '
39
        ' @description Initializes the node pool
40
        ' ---------------------------------------------------------------------
41
        sub new()
42
        end sub
43

44
        ' ---------------------------------------------------------------------
45
        ' init - Initializes the pool with framework instance reference
46
        '
47

48
        ' @param {Rotor.Framework} frameworkInstance - Framework instance reference
49
        ' ---------------------------------------------------------------------
50
        sub init(frameworkInstance as Rotor.Framework)
51
            m.frameworkInstance = frameworkInstance
1✔
52
        end sub
53

54
        ' ---------------------------------------------------------------------
55
        ' destroy - Cleans up framework instance reference and pools
56
        ' ---------------------------------------------------------------------
57
        sub destroy()
58
            m.frameworkInstance = invalid
1✔
59
            m.pools.Clear()
1✔
60
        end sub
61

62
        ' ---------------------------------------------------------------------
63
        '
64

65
        ' presetNodePool - Presets node pools with specified amounts of each node type
66
        '
67
        ' @param {object} config - Configuration with nodePool array
68
        ' ---------------------------------------------------------------------
69
        sub presetNodePool(config)
70
            Rotor.Utils.deepExtendAA(m.config, config)
1✔
71
            for each thisPool in m.config.nodePool
1✔
72
                for index = 0 to thisPool.amount - 1
1✔
73
                    if not m.pools.doesExist(thisPool.nodeType)
2✔
74
                        m.pools[thisPool.nodeType] = []
1✔
75
                        #if debug
4✔
76
                            m.poolInfo.outOfStockNodes[thisPool.nodeType] = 0
1✔
77
                        #end if
78
                    end if
79
                    node = CreateObject("roSGNode", thisPool.nodeType)
1✔
80
                    m.pools[thisPool.nodeType].push(node)
1✔
81
                end for
82
            end for
83
        end sub
84

85
        ' ---------------------------------------------------------------------
86
        ' acquireNode - Acquires a node from the pool or creates a new one
87
        '
88

89
        ' @param {string} nodeType - Type of SceneGraph node to acquire
90
        ' @returns {object} SceneGraph node instance
91
        ' ---------------------------------------------------------------------
92
        function acquireNode(nodeType)
93
            if m.pools.doesExist(nodeType) and m.pools[nodeType].Count() > 0
2✔
94
                node = m.pools[nodeType].pop()
1✔
95
                #if debug
4✔
96
                    m.poolInfo.totalAcquiredNodes++
1✔
97
                #end if
98
            else
3✔
99
                node = CreateObject("roSGNode", nodeType)
1✔
100
                #if debug
4✔
101
                    if m.pools.doesExist(nodeType)
2✔
102
                        m.poolInfo.outOfStockNodes[nodeType]++
×
103
                    end if
104
                #end if
105
            end if
106

107
            return node
1✔
108
        end function
109

110
        ' ---------------------------------------------------------------------
111
        ' releaseNodeBranch - Recursively releases a node and its children back to pools
112
        '
113

114
        ' @param {object} node - SceneGraph node to release
115
        ' @param {object} parent - Parent node for removal (default: invalid)
116
        ' ---------------------------------------------------------------------
117
        sub releaseNodeBranch(node as object, parent = invalid as object)
118

119
            children = node.getChildren(-1, 0)
1✔
120

121
            if children <> invalid and children.count() > 0
2✔
122
                for each child in children
×
123
                    m.releaseNodeBranch(child, node)
×
124
                end for
125
            end if
126

127
            nodeType = node.subtype()
1✔
128

129
            if m.pools.doesExist(nodeType)
3✔
130
                if parent <> invalid
2✔
131
                    parent.removeChild(node)
×
132
                end if
133
                m.resetNode(node)
1✔
134
                m.pools[nodeType].push(node)
1✔
135

136
                #if debug
4✔
137
                    m.poolInfo.totalReleasedNodes++
1✔
138
                #end if
139
            end if
140

141
        end sub
142

143
        ' ---------------------------------------------------------------------
144
        ' resetNode - Resets a node's properties to default values before returning to pool
145
        '
146

147
        ' @param {object} node - SceneGraph node to reset
148
        ' @private
149
        ' ---------------------------------------------------------------------
150
        private sub resetNode(node as object)
151
            if node = invalid then return
2✔
152

153
            nodeType = node.subtype()
1✔
154

155
            node.visible = true
1✔
156
            node.opacity = 1.0
1✔
157
            node.translation = [0.0, 0.0]
1✔
158
            node.rotation = 0.0
1✔
159
            node.scale = [1.0, 1.0]
1✔
160
            node.scaleRotateCenter = [0.0, 0.0]
1✔
161
            node.inheritParentTransform = true
1✔
162
            node.inheritParentOpacity = true
1✔
163
            node.muteAudioGuide = false
1✔
164
            node.renderPass = 0
1✔
165
            node.enableRenderTracking = false
1✔
166
            ' TODO: test below properties to reset
167
            ' node.childRenderOrder = "renderLast"
168
            ' node.clippingRect = [0.0, 0.0, 0.0, 0.0]
169

170
            if nodeType = "Rectangle"
2✔
171
                node.setFields({
×
172
                    color: "#FFFFFFFF",
173
                    width: 0,
174
                    height: 0,
175
                    blendingEnabled: true
176
                })
177

178
            else if nodeType = "Poster"
2✔
179
                node.setFields({
×
180
                    uri: "",
181
                    width: 0,
182
                    height: 0,
183
                    loadWidth: 0,
184
                    loadHeight: 0,
185
                    blendColor: "#FFFFFFFF",
186
                    loadDisplayMode: "noScale",
187
                    loadSync: false,
188
                    loadingBitmapUri: "",
189
                    failedBitmapUri: "",
190
                    loadingBitmapOpacity: 1.0,
191
                    failedBitmapOpacity: 1.0
192
                })
193

194
            else if nodeType = "Label"
3✔
195
                node.setFields({
1✔
196
                    text: "",
197
                    color: "#FFFFFFFF",
198
                    horizAlign: "left",
199
                    vertAlign: "top",
200
                    width: 0,
201
                    height: 0,
202
                    wrap: false,
203
                    numLines: 0,
204
                    lineSpacing: 0.0,
205
                    maxLines: 0,
206
                    ellipsisText: "",
207
                    font: "font:MediumSystemFont"
208
                })
209

210
            end if
211
        end sub
212

213
        ' ---------------------------------------------------------------------
214
        ' getNodePoolInfo - Gets node pool statistics (debug mode only)
215
        '
216

217
        ' @returns {object} Pool information with counts and stats
218
        ' ---------------------------------------------------------------------
219
        function getNodePoolInfo()
220
            info = {}
1✔
221
            #if debug
4✔
222
                for each nodeType in m.pools
1✔
223
                    m.poolInfo.poolFulness[nodeType] = m.pools[nodeType].Count()
1✔
224
                end for
225
                info = m.poolInfo
1✔
226
            #end if
227
            return info
1✔
228
        end function
229

230

231
    end class
232

233

234

235

236
end namespace
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc