Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 3df86d2

Browse files
author
Yuncong Zhang
committed
Fill null reference issues.
1 parent dc2baa3 commit 3df86d2

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ bool _mustRenderClip(uint clipGenId, uiRect clipBounds) {
391391
RenderLayer _createMaskLayer(RenderLayer parentLayer, uiRect maskBounds,
392392
_drawPathDrawMeshCallbackDelegate drawCallback,
393393
uiPaint paint, bool convex, float alpha, Texture tex, uiRect texBound, TextBlobMesh textMesh,
394-
uiMeshMesh mesh, bool notEmoji) {
394+
uiMeshMesh fillMesh, uiMeshMesh strokeMesh, bool notEmoji) {
395395
var textureWidth = Mathf.CeilToInt(maskBounds.width * this._devicePixelRatio);
396396
if (textureWidth < 1) {
397397
textureWidth = 1;
@@ -419,7 +419,7 @@ RenderLayer _createMaskLayer(RenderLayer parentLayer, uiRect maskBounds,
419419
var maskState = maskLayer.states[maskLayer.states.Count - 1];
420420
maskState.matrix = parentState.matrix;
421421

422-
drawCallback.Invoke(uiPaint.shapeOnly(paint), mesh, null, convex, alpha, tex, texBound, textMesh, notEmoji);
422+
drawCallback.Invoke(uiPaint.shapeOnly(paint), fillMesh, strokeMesh, convex, alpha, tex, texBound, textMesh, notEmoji);
423423

424424
var removed = this._layers.removeLast();
425425
D.assert(removed == maskLayer);
@@ -481,7 +481,7 @@ RenderLayer _createBlurLayer(RenderLayer maskLayer, float sigmaX, float sigmaY,
481481
}
482482

483483
void _drawWithMaskFilter(uiRect meshBounds, uiPaint paint, uiMaskFilter maskFilter,
484-
uiMeshMesh mesh, bool convex, float alpha, Texture tex, uiRect texBound, TextBlobMesh textMesh, bool notEmoji,
484+
uiMeshMesh fillMesh, uiMeshMesh strokeMesh, bool convex, float alpha, Texture tex, uiRect texBound, TextBlobMesh textMesh, bool notEmoji,
485485
_drawPathDrawMeshCallbackDelegate drawCallback) {
486486
var layer = this._currentLayer;
487487
var clipBounds = layer.layerBounds;
@@ -495,27 +495,27 @@ void _drawWithMaskFilter(uiRect meshBounds, uiPaint paint, uiMaskFilter maskFilt
495495
}
496496

497497
if (clipBounds.isEmpty) {
498-
this._drawPathDrawMeshQuit(mesh, textMesh);
498+
this._drawPathDrawMeshQuit(fillMesh, strokeMesh, textMesh);
499499
return;
500500
}
501501

502502
var state = layer.currentState;
503503
float sigma = state.scale * maskFilter.sigma;
504504
if (sigma <= 0) {
505-
this._drawPathDrawMeshQuit(mesh, textMesh);
505+
this._drawPathDrawMeshQuit(fillMesh, strokeMesh, textMesh);
506506
return;
507507
}
508508

509509
float sigma3 = 3 * sigma;
510510
var maskBounds = uiRectHelper.inflate(meshBounds, sigma3);
511511
maskBounds = uiRectHelper.intersect(maskBounds, uiRectHelper.inflate(clipBounds, sigma3));
512512
if (maskBounds.isEmpty) {
513-
this._drawPathDrawMeshQuit(mesh, textMesh);
513+
this._drawPathDrawMeshQuit(fillMesh, strokeMesh, textMesh);
514514
return;
515515
}
516516

517517
var maskLayer = this._createMaskLayer(layer, maskBounds, drawCallback, paint, convex, alpha, tex, texBound,
518-
textMesh, mesh, notEmoji);
518+
textMesh, fillMesh, strokeMesh, notEmoji);
519519

520520
var blurLayer = this._createBlurLayer(maskLayer, sigma, sigma, layer);
521521

@@ -591,8 +591,9 @@ void _drawTextDrawMeshCallback(uiPaint p, uiMeshMesh fillMesh, uiMeshMesh stroke
591591
}
592592
}
593593

594-
void _drawPathDrawMeshQuit(uiMeshMesh mesh, TextBlobMesh textMesh) {
595-
ObjectPool<uiMeshMesh>.release(mesh);
594+
void _drawPathDrawMeshQuit(uiMeshMesh fillMesh, uiMeshMesh strokeMesh, TextBlobMesh textMesh) {
595+
ObjectPool<uiMeshMesh>.release(fillMesh);
596+
ObjectPool<uiMeshMesh>.release(strokeMesh);
596597
ObjectPool<TextBlobMesh>.release(textMesh);
597598
}
598599

@@ -611,7 +612,7 @@ void _drawPath(uiPath path, uiPaint paint) {
611612
var smesh = strokeMesh?.transform(state.matrix);
612613

613614
if (paint.maskFilter != null && paint.maskFilter.Value.sigma != 0) {
614-
this._drawWithMaskFilter(fmesh.bounds, paint, paint.maskFilter.Value, fmesh, convex, 0, null,
615+
this._drawWithMaskFilter(fmesh.bounds, paint, paint.maskFilter.Value, fmesh, smesh, convex, 0, null,
615616
uiRectHelper.zero, null, false, this.___drawPathDrawMeshCallback);
616617
return;
617618
}
@@ -646,7 +647,7 @@ void _drawPath(uiPath path, uiPaint paint) {
646647
var mesh = strokeMesh.transform(state.matrix);
647648

648649
if (paint.maskFilter != null && paint.maskFilter.Value.sigma != 0) {
649-
this._drawWithMaskFilter(mesh.bounds, paint, paint.maskFilter.Value, mesh, false, alpha, null,
650+
this._drawWithMaskFilter(mesh.bounds, paint, paint.maskFilter.Value, null, mesh, false, alpha, null,
650651
uiRectHelper.zero, null, false, this.___drawPathDrawMeshCallback2);
651652
return;
652653
}
@@ -961,7 +962,7 @@ void _drawTextBlob(TextBlob textBlob, uiOffset offset, uiPaint paint) {
961962
}
962963

963964
if (paint.maskFilter != null && paint.maskFilter.Value.sigma != 0) {
964-
this._drawWithMaskFilter(textBlobBounds, paint, paint.maskFilter.Value, null, false, 0, tex,
965+
this._drawWithMaskFilter(textBlobBounds, paint, paint.maskFilter.Value, null, null, false, 0, tex,
965966
textBlobBounds, mesh, notEmoji, this.___drawTextDrawMeshCallback);
966967
return;
967968
}

0 commit comments

Comments
 (0)