Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: sky/examples/raw/spinning_image.dart

Issue 1156003007: Refactor image handling in Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: CR feedback from abarth Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/examples/raw/spinning_image.dart
diff --git a/sky/examples/raw/spinning_image.dart b/sky/examples/raw/spinning_image.dart
index 53fe140460f3b4dbc19e556d937e50c582b77596..cd5339fbf01ec43a35833825545b3c26a6aea665 100644
--- a/sky/examples/raw/spinning_image.dart
+++ b/sky/examples/raw/spinning_image.dart
@@ -6,7 +6,7 @@ import 'dart:sky';
double timeBase = null;
-Image image;
+Image image = null;
void beginFrame(double timeStamp) {
if (timeBase == null) timeBase = timeStamp;
@@ -16,14 +16,21 @@ void beginFrame(double timeStamp) {
canvas.rotateDegrees(delta / 10);
canvas.scale(0.2, 0.2);
Paint paint = new Paint()..setARGB(255, 0, 255, 0);
- canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint);
+ if (image != null)
+ canvas.drawImage(image, -image.width / 2.0, -image.height / 2.0, paint);
view.picture = canvas.endRecording();
view.scheduleFrame();
}
void main() {
- image = new Image();
- image.src = "https://www.dartlang.org/logos/dart-logo.png";
+ new ImageLoader("https://www.dartlang.org/logos/dart-logo.png", (result) {
+ if (result != null) {
+ print("${result.width}x${result.width} image loaded!");
+ image = result;
+ view.scheduleFrame();
+ } else {
+ print("Image failed to load");
+ }
+ }).load();
view.setBeginFrameCallback(beginFrame);
- view.scheduleFrame();
}
« sky/engine/core/loader/ImageLoader.idl ('K') | « sky/engine/core/painting/Image.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698