Fix canvas crash in CanvasDrawTextTest

Call drawText in begin/end recording section.

Bug: 168846481
Test: atest CanvasDrawTextTest
Change-Id: I512f7a7b3de44236e567f80281a2fd9fbb61be9a
This commit is contained in:
Seigo Nonaka
2020-10-01 20:42:09 -07:00
parent 16b02d4899
commit f61ce18e44

View File

@@ -53,19 +53,19 @@ public class CanvasDrawTextTest {
final String text = mTextUtil.nextRandomParagraph(
WORD_LENGTH, 4 * 1024 * 1024 /* 4mb text */).toString();
final RenderNode node = RenderNode.create("benchmark", null);
final RenderNode child = RenderNode.create("child", null);
child.setLeftTopRightBottom(50, 50, 100, 100);
RecordingCanvas canvas = node.start(100, 100);
node.end(canvas);
canvas = child.start(50, 50);
child.end(canvas);
final Random r = new Random(0);
while (state.keepRunning()) {
state.pauseTiming();
RecordingCanvas canvas = node.beginRecording();
int start = r.nextInt(text.length() - 100);
state.resumeTiming();
canvas.drawText(text, start, start + 100, 0, 0, PAINT);
state.pauseTiming();
node.endRecording();
state.resumeTiming();
}
}
}