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

Commit 25f5432

Browse files
committed
fix image slice bug
1 parent 7f0cd4a commit 25f5432

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void _setMatrix(uiMatrix3 matrix) {
281281

282282
void _clipRect(Rect rect) {
283283
var path = uiPath.create();
284-
path.addRect(uiRectHelper.fromRect(rect));
284+
path.addRect(uiRectHelper.fromRect(rect).Value);
285285
this._clipPath(path);
286286
uiPathCacheManager.putToCache(path);
287287
}
@@ -771,7 +771,7 @@ void _drawPicture(Picture picture, bool needsSave = true) {
771771
break;
772772
case DrawSaveLayer cmd: {
773773
saveCount++;
774-
this._saveLayer(uiRectHelper.fromRect(cmd.rect), uiPaint.fromPaint(cmd.paint));
774+
this._saveLayer(uiRectHelper.fromRect(cmd.rect).Value, uiPaint.fromPaint(cmd.paint));
775775
break;
776776
}
777777

@@ -849,14 +849,14 @@ void _drawPicture(Picture picture, bool needsSave = true) {
849849
}
850850

851851
case DrawImageRect cmd: {
852-
this._drawImageRect(cmd.image, uiRectHelper.fromRect(cmd.src), uiRectHelper.fromRect(cmd.dst),
852+
this._drawImageRect(cmd.image, uiRectHelper.fromRect(cmd.src), uiRectHelper.fromRect(cmd.dst).Value,
853853
uiPaint.fromPaint(cmd.paint));
854854
break;
855855
}
856856

857857
case DrawImageNine cmd: {
858858
this._drawImageNine(cmd.image, uiRectHelper.fromRect(cmd.src),
859-
uiRectHelper.fromRect(cmd.center), uiRectHelper.fromRect(cmd.dst),
859+
uiRectHelper.fromRect(cmd.center).Value, uiRectHelper.fromRect(cmd.dst).Value,
860860
uiPaint.fromPaint(cmd.paint));
861861
break;
862862
}
@@ -1019,7 +1019,7 @@ void _drawTextBlob(TextBlob? textBlob, uiOffset offset, uiPaint paint) {
10191019
matrix.preTranslate(offset.dx, offset.dy);
10201020

10211021
var mesh = TextBlobMesh.create(textBlob.Value, scale, matrix);
1022-
var textBlobBounds = matrix.mapRect(uiRectHelper.fromRect(textBlob.Value.boundsInText));
1022+
var textBlobBounds = matrix.mapRect(uiRectHelper.fromRect(textBlob.Value.boundsInText).Value);
10231023

10241024
// request font texture so text mesh could be generated correctly
10251025
var style = textBlob.Value.style;

Runtime/ui/renderer/common/geometry/rect.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ public uiRect expandToInclude(uiRect? other) {
9595
}
9696

9797
public static class uiRectHelper {
98-
public static uiRect fromRect(Rect rect) {
98+
public static uiRect? fromRect(Rect rect) {
99+
if (rect == null) {
100+
return null;
101+
}
99102
return new uiRect(rect.left, rect.top, rect.right, rect.bottom);
100103
}
101104

Runtime/ui/renderer/common/picture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void addDrawCmd(uiDrawCmd drawCmd) {
170170
case uiDrawClipRRect cmd: {
171171
var state = this._getState();
172172

173-
var rect = state.xform.mapRect(uiRectHelper.fromRect(cmd.rrect.outerRect));
173+
var rect = state.xform.mapRect(uiRectHelper.fromRect(cmd.rrect.outerRect).Value);
174174
state.scissor = state.scissor == null ? rect : state.scissor.Value.intersect(rect);
175175
this._setState(state);
176176
break;
@@ -258,15 +258,15 @@ public void addDrawCmd(uiDrawCmd drawCmd) {
258258
}
259259
case uiDrawPicture cmd: {
260260
var state = this._getState();
261-
var rect = state.xform.mapRect(uiRectHelper.fromRect(cmd.picture.paintBounds));
261+
var rect = state.xform.mapRect(uiRectHelper.fromRect(cmd.picture.paintBounds).Value);
262262
this._addPaintBounds(rect);
263263
break;
264264
}
265265
case uiDrawTextBlob cmd: {
266266
var state = this._getState();
267267
var scale = uiXformUtils.getScale(state.xform);
268268
var rect = uiRectHelper.fromRect(
269-
cmd.textBlob.Value.shiftedBoundsInText(cmd.offset.Value.dx, cmd.offset.Value.dy));
269+
cmd.textBlob.Value.shiftedBoundsInText(cmd.offset.Value.dx, cmd.offset.Value.dy)).Value;
270270
rect = state.xform.mapRect(rect);
271271

272272
var paint = cmd.paint;

0 commit comments

Comments
 (0)