@leafer/renderer 1.0.0-rc.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/Renderer.ts +23 -11
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "@leafer/renderer",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/leaferjs/leafer.git"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/leaferjs/leafer/tree/main/packages/renderer",
|
|
18
|
+
"homepage": "https://github.com/leaferjs/leafer/tree/main/packages/partner/renderer",
|
|
19
19
|
"bugs": "https://github.com/leaferjs/leafer/issues",
|
|
20
20
|
"keywords": [
|
|
21
21
|
"leafer",
|
|
22
22
|
"leaferjs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@leafer/core": "1.0.
|
|
25
|
+
"@leafer/core": "1.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@leafer/interface": "1.0.
|
|
28
|
+
"@leafer/interface": "1.0.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/Renderer.ts
CHANGED
|
@@ -19,6 +19,7 @@ export class Renderer implements IRenderer {
|
|
|
19
19
|
|
|
20
20
|
public waitAgain: boolean
|
|
21
21
|
public changed: boolean
|
|
22
|
+
public ignore: boolean
|
|
22
23
|
|
|
23
24
|
public config: IRendererConfig = {
|
|
24
25
|
usePartRender: true,
|
|
@@ -109,6 +110,11 @@ export class Renderer implements IRenderer {
|
|
|
109
110
|
} else {
|
|
110
111
|
this.requestLayout()
|
|
111
112
|
|
|
113
|
+
if (this.ignore) {
|
|
114
|
+
this.ignore = this.rendering = false
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
112
118
|
this.emitRender(RenderEvent.BEFORE)
|
|
113
119
|
|
|
114
120
|
if (this.config.usePartRender && this.totalTimes > 1) {
|
|
@@ -151,7 +157,7 @@ export class Renderer implements IRenderer {
|
|
|
151
157
|
if (includes && !Debug.showRepaint) {
|
|
152
158
|
canvas.clear()
|
|
153
159
|
} else {
|
|
154
|
-
bounds.spread(
|
|
160
|
+
bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil()
|
|
155
161
|
canvas.clearWorld(bounds, true)
|
|
156
162
|
canvas.clipWorld(bounds, true)
|
|
157
163
|
}
|
|
@@ -182,13 +188,13 @@ export class Renderer implements IRenderer {
|
|
|
182
188
|
|
|
183
189
|
this.target.__render(this.canvas, options)
|
|
184
190
|
|
|
185
|
-
this.renderBounds = realBounds || bounds
|
|
191
|
+
this.renderBounds = realBounds = realBounds || bounds
|
|
186
192
|
this.renderOptions = options
|
|
187
|
-
this.totalBounds.isEmpty() ? this.totalBounds =
|
|
193
|
+
this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds)
|
|
188
194
|
|
|
189
195
|
if (Debug.showHitView) this.renderHitView(options)
|
|
190
196
|
if (Debug.showBoundsView) this.renderBoundsView(options)
|
|
191
|
-
this.canvas.updateRender()
|
|
197
|
+
this.canvas.updateRender(realBounds)
|
|
192
198
|
}
|
|
193
199
|
|
|
194
200
|
public renderHitView(_options: IRenderOptions): void { }
|
|
@@ -214,10 +220,13 @@ export class Renderer implements IRenderer {
|
|
|
214
220
|
const startTime = Date.now()
|
|
215
221
|
Platform.requestRender(() => {
|
|
216
222
|
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - startTime)))
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
|
|
224
|
+
if (this.running) {
|
|
225
|
+
this.target.emit(AnimateEvent.FRAME)
|
|
226
|
+
if (this.changed && this.canvas.view) this.render()
|
|
227
|
+
this.target.emit(RenderEvent.NEXT)
|
|
219
228
|
}
|
|
220
|
-
|
|
229
|
+
|
|
221
230
|
if (this.target) this.__requestRender()
|
|
222
231
|
})
|
|
223
232
|
}
|
|
@@ -229,9 +238,14 @@ export class Renderer implements IRenderer {
|
|
|
229
238
|
const bounds = new Bounds(0, 0, width, height)
|
|
230
239
|
if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
|
|
231
240
|
this.addBlock(this.canvas.bounds)
|
|
232
|
-
this.target.forceUpdate('
|
|
241
|
+
this.target.forceUpdate('surface')
|
|
242
|
+
return
|
|
233
243
|
}
|
|
234
244
|
}
|
|
245
|
+
|
|
246
|
+
// 需要象征性派发一下渲染事件
|
|
247
|
+
this.addBlock(new Bounds(0, 0, 1, 1))
|
|
248
|
+
this.changed = true
|
|
235
249
|
}
|
|
236
250
|
|
|
237
251
|
protected __onLayoutEnd(event: LayoutEvent): void {
|
|
@@ -271,9 +285,7 @@ export class Renderer implements IRenderer {
|
|
|
271
285
|
if (this.target) {
|
|
272
286
|
this.stop()
|
|
273
287
|
this.__removeListenEvents()
|
|
274
|
-
this.target = null
|
|
275
|
-
this.canvas = null
|
|
276
|
-
this.config = null
|
|
288
|
+
this.target = this.canvas = this.config = null
|
|
277
289
|
}
|
|
278
290
|
}
|
|
279
291
|
}
|
package/types/index.d.ts
CHANGED