| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This example makes use of mojo:camera_roll which is available only when | 5 // This example makes use of mojo:camera_roll which is available only when |
| 6 // running on Android. | 6 // running on Android. |
| 7 // | 7 // |
| 8 // Example usage: | 8 // Example usage: |
| 9 // pub get | 9 // pub get |
| 10 // pub run sky_tools build | 10 // pub run sky_tools build |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 void beginFrame(double timeStamp) { | 49 void beginFrame(double timeStamp) { |
| 50 Rect paintBounds = new Rect.fromLTWH(0.0, 0.0, view.width, view.height); | 50 Rect paintBounds = new Rect.fromLTWH(0.0, 0.0, view.width, view.height); |
| 51 Picture picture = paint(paintBounds); | 51 Picture picture = paint(paintBounds); |
| 52 Scene scene = composite(picture, paintBounds); | 52 Scene scene = composite(picture, paintBounds); |
| 53 view.scene = scene; | 53 view.scene = scene; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void getPhoto() { | 56 void getPhoto() { |
| 57 var future = cameraRoll.ptr.getPhoto(photoIndex); | 57 var future = cameraRoll.getPhoto(photoIndex); |
| 58 future.then((response) { | 58 future.then((response) { |
| 59 if (response.photo == null) { | 59 if (response.photo == null) { |
| 60 print("Photo $photoIndex not found, returning to the first photo."); | 60 print("Photo $photoIndex not found, returning to the first photo."); |
| 61 cameraRoll.ptr.update(); | 61 cameraRoll.update(); |
| 62 photoIndex = 0; | 62 photoIndex = 0; |
| 63 getPhoto(); | 63 getPhoto(); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 new ImageDecoder(response.photo.content.handle.h, (image) { | 67 new ImageDecoder(response.photo.content.handle.h, (image) { |
| 68 if (image != null) { | 68 if (image != null) { |
| 69 currentImage = image; | 69 currentImage = image; |
| 70 print("view.scheduleFrame"); | 70 print("view.scheduleFrame"); |
| 71 view.scheduleFrame(); | 71 view.scheduleFrame(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 | 87 |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void main() { | 91 void main() { |
| 92 embedder.connectToService("mojo:camera", cameraRoll); | 92 embedder.connectToService("mojo:camera", cameraRoll); |
| 93 view.setFrameCallback(beginFrame); | 93 view.setFrameCallback(beginFrame); |
| 94 view.setEventCallback(handleEvent); | 94 view.setEventCallback(handleEvent); |
| 95 getPhoto(); | 95 getPhoto(); |
| 96 } | 96 } |
| OLD | NEW |