@leafer/renderer 1.0.0-rc.2 → 1.0.0-rc.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/renderer",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.21",
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.0-rc.2"
25
+ "@leafer/core": "1.0.0-rc.21"
26
26
  },
27
27
  "devDependencies": {
28
- "@leafer/interface": "1.0.0-rc.2"
28
+ "@leafer/interface": "1.0.0-rc.21"
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) {
@@ -134,7 +140,7 @@ export class Renderer implements IRenderer {
134
140
  const { canvas, updateBlocks: list } = this
135
141
  if (!list) return debug.warn('PartRender: need update attr')
136
142
 
137
- if (list.some(block => block.includes(this.target.__world))) this.mergeBlocks()
143
+ this.mergeBlocks()
138
144
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty()) this.clipRender(block) })
139
145
  }
140
146
 
@@ -144,7 +150,7 @@ export class Renderer implements IRenderer {
144
150
 
145
151
  const bounds = block.getIntersect(canvas.bounds)
146
152
  const includes = block.includes(this.target.__world)
147
- const realBounds = new Bounds().copy(bounds)
153
+ const realBounds = new Bounds(bounds)
148
154
 
149
155
  canvas.save()
150
156
 
@@ -156,7 +162,7 @@ export class Renderer implements IRenderer {
156
162
  canvas.clipWorld(bounds, true)
157
163
  }
158
164
 
159
- this.__render(bounds, realBounds)
165
+ this.__render(bounds, includes, realBounds)
160
166
  canvas.restore()
161
167
 
162
168
  Run.end(t)
@@ -168,14 +174,14 @@ export class Renderer implements IRenderer {
168
174
 
169
175
  canvas.save()
170
176
  canvas.clear()
171
- this.__render(canvas.bounds)
177
+ this.__render(canvas.bounds, true)
172
178
  canvas.restore()
173
179
 
174
180
  Run.end(t)
175
181
  }
176
182
 
177
- protected __render(bounds: IBounds, realBounds?: IBounds): void {
178
- const options: IRenderOptions = bounds?.includes(this.target.__world) ? {} : { bounds }
183
+ protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds,): void {
184
+ const options: IRenderOptions = bounds.includes(this.target.__world) ? { includes } : { bounds, includes }
179
185
 
180
186
  if (this.needFill) this.canvas.fillWorld(bounds, this.config.fill)
181
187
  if (Debug.showRepaint) this.canvas.strokeWorld(bounds, 'red')
@@ -204,7 +210,7 @@ export class Renderer implements IRenderer {
204
210
  const { updateBlocks: list } = this
205
211
  if (list) {
206
212
  const bounds = new Bounds()
207
- bounds.setByList(list)
213
+ bounds.setList(list)
208
214
  list.length = 0
209
215
  list.push(bounds)
210
216
  }
@@ -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
- if (this.changed) {
218
- if (this.running && this.canvas.view) this.render()
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
- if (this.running) this.target.emit(AnimateEvent.FRAME)
229
+
221
230
  if (this.target) this.__requestRender()
222
231
  })
223
232
  }
@@ -229,7 +238,7 @@ 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('blendMode')
241
+ this.target.forceUpdate('surface')
233
242
  }
234
243
  }
235
244
  }
@@ -240,7 +249,7 @@ export class Renderer implements IRenderer {
240
249
  if (item.updatedList) item.updatedList.list.some(leaf => {
241
250
  empty = (!leaf.__world.width || !leaf.__world.height)
242
251
  if (empty) {
243
- if (!leaf.isLeafer) debug.warn(leaf.innerName, ': empty')
252
+ if (!leaf.isLeafer) debug.tip(leaf.innerName, ': empty')
244
253
  empty = (!leaf.isBranch || leaf.isBranchLeaf) // render object
245
254
  }
246
255
  return empty
@@ -271,9 +280,7 @@ export class Renderer implements IRenderer {
271
280
  if (this.target) {
272
281
  this.stop()
273
282
  this.__removeListenEvents()
274
- this.target = null
275
- this.canvas = null
276
- this.config = null
283
+ this.target = this.canvas = this.config = null
277
284
  }
278
285
  }
279
286
  }
package/types/index.d.ts CHANGED
@@ -12,6 +12,7 @@ declare class Renderer implements IRenderer {
12
12
  rendering: boolean;
13
13
  waitAgain: boolean;
14
14
  changed: boolean;
15
+ ignore: boolean;
15
16
  config: IRendererConfig;
16
17
  protected renderBounds: IBounds;
17
18
  protected renderOptions: IRenderOptions;
@@ -29,7 +30,7 @@ declare class Renderer implements IRenderer {
29
30
  partRender(): void;
30
31
  clipRender(block: IBounds): void;
31
32
  fullRender(): void;
32
- protected __render(bounds: IBounds, realBounds?: IBounds): void;
33
+ protected __render(bounds: IBounds, includes?: boolean, realBounds?: IBounds): void;
33
34
  renderHitView(_options: IRenderOptions): void;
34
35
  renderBoundsView(_options: IRenderOptions): void;
35
36
  addBlock(block: IBounds): void;