Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5237933

Browse files
committed
[canvaskit] Fix test for drawOnce
I belatedly realized that drawOnce's test would always be blank now that drawOnce is async. Change-Id: If30bbdd895039bd8de050a59dd348ba6849c5835 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266631 Reviewed-by: Kevin Lubick <kjlubick@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
1 parent 2c5b856 commit 5237933

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

modules/canvaskit/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- `SkSurface.drawOnce` for drawing a single frame (in addition to already existing
10+
`SkSurface.requestAnimationFrame` for animation logic).
811

912
## [0.12.0] - 2020-01-22
1013

modules/canvaskit/interface.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ CanvasKit.onRuntimeInitialized = function() {
762762
}.bind(this));
763763
}
764764

765+
// drawOnce will dispose of the surface after drawing the frame using the provided
766+
// callback.
765767
CanvasKit.SkSurface.prototype.drawOnce = function(callback, dirtyRect) {
766768
if (!this._cached_canvas) {
767769
this._cached_canvas = this.getCanvas();

modules/canvaskit/tests/core.spec.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,17 @@ describe('Core canvas behavior', function() {
389389
path.lineTo(30, 20);
390390
path.lineTo(40, 10);
391391
canvas.drawPath(path, paint);
392-
393392
path.delete();
394393
paint.delete();
394+
// surface hasn't been flushed yet (nor should we call flush
395+
// ourselves), so reportSurface would likely be blank if we
396+
// were to call it.
397+
done();
395398
}
396399
surface.drawOnce(drawFrame);
397-
398-
reportSurface(surface, 'drawOnce', done);
400+
// Reminder: drawOnce is async. In this test, we are just making
401+
// sure the drawOnce function is there and doesn't crash, so we can
402+
// just call done() when the frame is rendered.
399403
}));
400404
});
401405

0 commit comments

Comments
 (0)