Remove all clients of sky.view.picture

Everyone uses sky.view.scene now. This patch also cleans up the raw examples
and makes them follow a consistent pattern.
This commit is contained in:
Adam Barth 2015-09-02 22:22:32 -07:00
parent a56aa095f7
commit 36c62edffb
9 changed files with 280 additions and 126 deletions

View file

@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'dart:sky' as sky;
import 'dart:typed_data';
void drawText(sky.Canvas canvas, String lh) {
sky.Paint paint = new sky.Paint();
@ -44,14 +45,10 @@ void drawText(sky.Canvas canvas, String lh) {
layoutRoot.paint(canvas);
}
void main() {
// prepare the rendering
sky.Picture paint(sky.Rect paintBounds) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Canvas canvas = new sky.Canvas(recorder, new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
// background
sky.Paint paint = new sky.Paint();
paint.color = const sky.Color(0xFFFFFFFF);
paint.setStyle(sky.PaintingStyle.fill);
@ -61,7 +58,30 @@ void main() {
drawText(canvas, '1.0');
drawText(canvas, 'lh');
// put it on the screen
sky.view.picture = recorder.endRecording();
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void main() {
sky.view.setFrameCallback(beginFrame);
sky.view.scheduleFrame();
}

View file

@ -2,37 +2,59 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:sky';
import 'dart:sky' as sky;
import 'dart:typed_data';
Picture draw(int a, int r, int g, int b) {
Size size = new Size(view.width, view.height);
sky.Color color;
sky.Picture paint(sky.Rect paintBounds) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
sky.Size size = paintBounds.size;
PictureRecorder recorder = new PictureRecorder();
final double devicePixelRatio = view.devicePixelRatio;
Canvas canvas = new Canvas(recorder, Point.origin & (size * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
double radius = size.shortestSide * 0.45;
sky.Paint paint = new sky.Paint()
..color = color;
canvas.drawCircle(size.center(sky.Point.origin), radius, paint);
Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
canvas.drawCircle(size.center(Point.origin), radius, paint);
return recorder.endRecording();
}
bool handleEvent(Event event) {
if (event.type == "pointerdown") {
view.picture = draw(255, 0, 0, 255);
view.scheduleFrame();
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
bool handleEvent(sky.Event event) {
if (event.type == 'pointerdown') {
color = new sky.Color.fromARGB(255, 0, 0, 255);
sky.view.scheduleFrame();
return true;
}
if (event.type == "pointerup") {
view.picture = draw(255, 0, 255, 0);
view.scheduleFrame();
if (event.type == 'pointerup') {
color = new sky.Color.fromARGB(255, 0, 255, 0);
sky.view.scheduleFrame();
return true;
}
if (event.type == "back") {
print("Pressed back button.");
if (event.type == 'back') {
print('Pressed back button.');
return true;
}
@ -40,9 +62,9 @@ bool handleEvent(Event event) {
}
void main() {
print("Hello, world");
view.picture = draw(255, 0, 255, 0);
view.scheduleFrame();
view.setEventCallback(handleEvent);
print('Hello, world');
color = new sky.Color.fromARGB(255, 0, 255, 0);
sky.view.setFrameCallback(beginFrame);
sky.view.setEventCallback(handleEvent);
sky.view.scheduleFrame();
}

View file

@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import "dart:math" as math;
import 'dart:math' as math;
import 'dart:sky' as sky;
import 'dart:typed_data';
const kMaxIterations = 100;
int peakCount = 1000; // this is the number that must be reached for us to start reporting the peak number of nodes in the tree each frame
@ -32,7 +33,7 @@ String colorToCSSString(sky.Color color) {
return 'rgba(${color.red}, ${color.green}, ${color.blue}, ${color.alpha / 255.0})';
}
void doFrame(double timeStamp) {
void mutate(sky.Canvas canvas) {
// mutate the DOM randomly
int iterationsLeft = kMaxIterations;
sky.Node node = root;
@ -201,16 +202,37 @@ void doFrame(double timeStamp) {
// draw the result
report("recording...");
sky.PictureRecorder recorder = new sky.PictureRecorder();
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Canvas canvas = new sky.Canvas(recorder, new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
layoutRoot.maxWidth = sky.view.width;
layoutRoot.layout();
layoutRoot.paint(canvas);
report("painting...");
sky.view.picture = recorder.endRecording();
sky.view.scheduleFrame();
}
sky.Picture paint(sky.Rect paintBounds) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
mutate(canvas);
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void main() {
@ -218,6 +240,6 @@ void main() {
root.style['display'] = 'paragraph';
root.style['color'] = '#FFFFFF';
layoutRoot.rootElement = root;
sky.view.setFrameCallback(doFrame);
sky.view.setFrameCallback(beginFrame);
sky.view.scheduleFrame();
}

View file

@ -6,21 +6,17 @@ import 'dart:sky' as sky;
import 'dart:math' as math;
import 'dart:typed_data';
void beginFrame(double timeStamp) {
sky.Size size = new sky.Size(sky.view.width, sky.view.height);
sky.Picture paint(sky.Rect paintBounds) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Canvas canvas = new sky.Canvas(recorder, sky.Point.origin & (size * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
sky.Size size = paintBounds.size;
sky.Paint paint = new sky.Paint();
sky.Point mid = size.center(sky.Point.origin);
double radius = size.shortestSide / 2.0;
canvas.drawPaint(new sky.Paint()..color = const sky.Color(0xFFFFFFFF));
canvas.save();
canvas.translate(-mid.x/2.0, sky.view.height*2.0);
canvas.clipRect(
new sky.Rect.fromLTRB(0.0, -sky.view.height, sky.view.width, radius));
@ -39,7 +35,7 @@ void beginFrame(double timeStamp) {
var scaleMatrix = new Float32List.fromList([
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0,
]);
canvas.concat(scaleMatrix);
@ -81,7 +77,27 @@ void beginFrame(double timeStamp) {
paint.setDrawLooper(builder.build());
canvas.drawCircle(sky.Point.origin, radius, paint);
sky.view.picture = recorder.endRecording();
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void main() {

View file

@ -2,41 +2,62 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:sky';
import 'dart:sky' as sky;
import 'dart:typed_data';
sky.Picture paint(sky.Rect paintBounds) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
void beginFrame(double timeStamp) {
double size = 100.0;
PictureRecorder recorder = new PictureRecorder();
final double devicePixelRatio = view.devicePixelRatio;
Canvas canvas = new Canvas(recorder, new Rect.fromLTWH(0.0, 0.0, view.width * devicePixelRatio, view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
canvas.translate(size + 10.0, size + 10.0);
Paint paint = new Paint();
paint.color = const Color.fromARGB(255, 0, 255, 0);
var builder = new LayerDrawLooperBuilder()
sky.Paint paint = new sky.Paint();
paint.color = const sky.Color.fromARGB(255, 0, 255, 0);
var builder = new sky.LayerDrawLooperBuilder()
// Shadow layer.
..addLayerOnTop(
new DrawLooperLayerInfo()
..setPaintBits(PaintBits.all)
..setOffset(const Offset(5.0, 5.0))
..setColorMode(TransferMode.src),
new Paint()
..color = const Color.fromARGB(128, 55, 55, 55)
new sky.DrawLooperLayerInfo()
..setPaintBits(sky.PaintBits.all)
..setOffset(const sky.Offset(5.0, 5.0))
..setColorMode(sky.TransferMode.src),
new sky.Paint()
..color = const sky.Color.fromARGB(128, 55, 55, 55)
..setMaskFilter(
new MaskFilter.blur(BlurStyle.normal, 5.0, highQuality: true))
new sky.MaskFilter.blur(sky.BlurStyle.normal, 5.0))
)
// Main layer.
..addLayerOnTop(new DrawLooperLayerInfo(), new Paint());
..addLayerOnTop(new sky.DrawLooperLayerInfo(), new sky.Paint());
paint.setDrawLooper(builder.build());
canvas.drawPaint(
new Paint()..color = const Color.fromARGB(255, 255, 255, 255));
canvas.drawRect(new Rect.fromLTRB(-size, -size, size, size), paint);
view.picture = recorder.endRecording();
new sky.Paint()..color = const sky.Color.fromARGB(255, 255, 255, 255));
canvas.drawRect(new sky.Rect.fromLTRB(-size, -size, size, size), paint);
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void main() {
view.setFrameCallback(beginFrame);
view.scheduleFrame();
sky.view.setFrameCallback(beginFrame);
sky.view.scheduleFrame();
}

View file

@ -2,24 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import "dart:math" as math;
import 'dart:sky';
import 'dart:math' as math;
import 'dart:sky' as sky;
import 'dart:typed_data';
double timeBase = null;
LayoutRoot layoutRoot = new LayoutRoot();
sky.LayoutRoot layoutRoot = new sky.LayoutRoot();
void beginFrame(double timeStamp) {
if (timeBase == null)
timeBase = timeStamp;
double delta = timeStamp - timeBase;
PictureRecorder recorder = new PictureRecorder();
final double devicePixelRatio = view.devicePixelRatio;
Canvas canvas = new Canvas(recorder, new Rect.fromLTWH(0.0, 0.0, view.width * devicePixelRatio, view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
canvas.translate(view.width / 2.0, view.height / 2.0);
sky.Picture paint(sky.Rect paintBounds, double delta) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
canvas.translate(sky.view.width / 2.0, sky.view.height / 2.0);
canvas.rotate(math.PI * delta / 1800);
canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new Paint()..color = const Color.fromARGB(255, 0, 255, 0));
canvas.drawRect(new sky.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0));
double sin = math.sin(delta / 200);
layoutRoot.maxWidth = 150.0 + (50 * sin);
@ -28,12 +25,34 @@ void beginFrame(double timeStamp) {
canvas.translate(layoutRoot.maxWidth / -2.0, (layoutRoot.maxWidth / 2.0) - 125);
layoutRoot.paint(canvas);
view.picture = recorder.endRecording();
view.scheduleFrame();
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
if (timeBase == null)
timeBase = timeStamp;
double delta = timeStamp - timeBase;
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds, delta);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void main() {
var document = new Document();
var document = new sky.Document();
var arabic = document.createText("هذا هو قليلا طويلة من النص الذي يجب التفاف .");
var more = document.createText(" و أكثر قليلا لجعله أطول. ");
var block = document.createElement('p');
@ -45,6 +64,6 @@ void main() {
layoutRoot.rootElement = block;
view.setFrameCallback(beginFrame);
view.scheduleFrame();
sky.view.setFrameCallback(beginFrame);
sky.view.scheduleFrame();
}

View file

@ -3,32 +3,29 @@
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:sky';
import 'dart:sky' as sky;
import 'dart:typed_data';
import 'package:sky/mojo/net/image_cache.dart' as image_cache;
double timeBase = null;
Image image = null;
sky.Image image = null;
String url1 = "https://www.dartlang.org/logos/dart-logo.png";
String url2 = "http://i2.kym-cdn.com/photos/images/facebook/000/581/296/c09.jpg";
void beginFrame(double timeStamp) {
if (timeBase == null)
timeBase = timeStamp;
double delta = timeStamp - timeBase;
PictureRecorder recorder = new PictureRecorder();
final double devicePixelRatio = view.devicePixelRatio;
Canvas canvas = new Canvas(recorder, Point.origin & new Size(view.width * devicePixelRatio, view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
canvas.translate(view.width / 2.0, view.height / 2.0);
sky.Picture paint(sky.Rect paintBounds, double delta) {
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
canvas.rotate(math.PI * delta / 1800);
canvas.scale(0.2, 0.2);
Paint paint = new Paint()..color = const Color.fromARGB(255, 0, 255, 0);
sky.Paint paint = new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0);
// Draw image
if (image != null)
canvas.drawImage(image, new Point(-image.width / 2.0, -image.height / 2.0), paint);
canvas.drawImage(image, new sky.Point(-image.width / 2.0, -image.height / 2.0), paint);
// Draw cut out of image
canvas.rotate(math.PI * delta / 1800);
@ -36,26 +33,49 @@ void beginFrame(double timeStamp) {
var w = image.width.toDouble();
var h = image.width.toDouble();
canvas.drawImageRect(image,
new Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
new Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
new sky.Rect.fromLTRB(w * 0.25, h * 0.25, w * 0.75, h * 0.75),
new sky.Rect.fromLTRB(-w / 4.0, -h / 4.0, w / 4.0, h / 4.0),
paint);
}
view.picture = recorder.endRecording();
view.scheduleFrame();
return recorder.endRecording();
}
sky.Scene composite(sky.Picture picture, sky.Rect paintBounds) {
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
return sceneBuilder.build();
}
void beginFrame(double timeStamp) {
if (timeBase == null)
timeBase = timeStamp;
double delta = timeStamp - timeBase;
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.Picture picture = paint(paintBounds, delta);
sky.Scene scene = composite(picture, paintBounds);
sky.view.scene = scene;
}
void handleImageLoad(result) {
if (result != image) {
print("${result.width}x${result.width} image loaded!");
image = result;
view.scheduleFrame();
sky.view.scheduleFrame();
} else {
print("Existing image was loaded again");
}
}
bool handleEvent(Event event) {
bool handleEvent(sky.Event event) {
if (event.type == "pointerdown") {
return true;
}
@ -70,6 +90,6 @@ bool handleEvent(Event event) {
void main() {
image_cache.load(url1).first.then(handleImageLoad);
view.setEventCallback(handleEvent);
view.setFrameCallback(beginFrame);
sky.view.setEventCallback(handleEvent);
sky.view.setFrameCallback(beginFrame);
}

View file

@ -2,30 +2,44 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:sky';
import 'dart:math' as math;
import 'dart:sky' as sky;
import 'dart:typed_data';
double timeBase = null;
void beginFrame(double timeStamp) {
tracing.begin('beginFrame');
sky.tracing.begin('beginFrame');
if (timeBase == null)
timeBase = timeStamp;
double delta = timeStamp - timeBase;
PictureRecorder recorder = new PictureRecorder();
final double devicePixelRatio = view.devicePixelRatio;
Canvas canvas = new Canvas(recorder, new Rect.fromLTWH(0.0, 0.0, view.width * devicePixelRatio, view.height * devicePixelRatio));
canvas.scale(devicePixelRatio, devicePixelRatio);
canvas.translate(view.width / 2.0, view.height / 2.0);
// paint
sky.Rect paintBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width, sky.view.height);
sky.PictureRecorder recorder = new sky.PictureRecorder();
sky.Canvas canvas = new sky.Canvas(recorder, paintBounds);
canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0);
canvas.rotate(math.PI * delta / 1800);
canvas.drawRect(new Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new Paint()..color = const Color.fromARGB(255, 0, 255, 0));
view.picture = recorder.endRecording();
view.scheduleFrame();
tracing.end('beginFrame');
canvas.drawRect(new sky.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0),
new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0));
sky.Picture picture = recorder.endRecording();
// composite
final double devicePixelRatio = sky.view.devicePixelRatio;
sky.Rect sceneBounds = new sky.Rect.fromLTWH(0.0, 0.0, sky.view.width * devicePixelRatio, sky.view.height * devicePixelRatio);
Float32List deviceTransform = new Float32List(16)
..[0] = devicePixelRatio
..[5] = devicePixelRatio;
sky.SceneBuilder sceneBuilder = new sky.SceneBuilder(sceneBounds)
..pushTransform(deviceTransform)
..addPicture(sky.Offset.zero, picture, paintBounds)
..pop();
sky.view.scene = sceneBuilder.build();
sky.tracing.end('beginFrame');
}
void main() {
view.setFrameCallback(beginFrame);
view.scheduleFrame();
sky.view.setFrameCallback(beginFrame);
sky.view.scheduleFrame();
}

View file

@ -15,7 +15,7 @@ import 'package:sky/src/widgets/icon.dart';
import 'package:sky/src/widgets/ink_well.dart';
import 'package:sky/src/widgets/theme.dart';
typedef EventDisposition OnPressedFunction();
typedef void OnPressedFunction();
class DrawerItem extends ButtonBase {
DrawerItem({ Key key, this.icon, this.child, this.onPressed, this.selected: false })