Decouple Canvas from DisplayList and map Picture and PictureRecorder more directly to their Skia counterparts.

Also changes the framework dart code to use the
refactored APIs and fixes the various examples and
tests.

R=abarth@chromium.org, ianh@chromium.org

Review URL: https://codereview.chromium.org/1190123003.
This commit is contained in:
Ian Fischer
2015-06-24 10:21:45 -07:00
parent 9b1985c237
commit 82d1eb2fdb
15 changed files with 54 additions and 45 deletions

View File

@@ -5,5 +5,6 @@ import 'dart:math' as Math;
import 'package:vector_math/vector_math_64.dart';
import 'sprites.dart';
import 'package:box2d/box2d.dart';
import 'package:sky/rendering/object.dart';
part 'game_demo_world.dart';

View File

@@ -372,7 +372,7 @@ class StarField extends Node {
}
}
void paint(PictureRecorder canvas) {
void paint(RenderCanvas canvas) {
// Setup paint object for opacity and transfer mode
Paint paint = new Paint();
paint.setTransferMode(TransferMode.plus);

View File

@@ -395,7 +395,7 @@ class Node {
// Rendering
void _visit(PictureRecorder canvas) {
void _visit(RenderCanvas canvas) {
assert(canvas != null);
if (!visible) return;
@@ -404,7 +404,7 @@ class Node {
_postPaint(canvas);
}
void _prePaint(PictureRecorder canvas) {
void _prePaint(RenderCanvas canvas) {
canvas.save();
// Get the transformation matrix and apply transform
@@ -419,7 +419,7 @@ class Node {
/// bounding box's origin, override [NodeWithSize] and call the applyTransformForPivot method before making calls for
/// drawing.
///
/// void paint(PictureRecorder canvas) {
/// void paint(RenderCanvas canvas) {
/// canvas.save();
/// applyTransformForPivot(canvas);
///
@@ -427,10 +427,10 @@ class Node {
///
/// canvas.restore();
/// }
void paint(PictureRecorder canvas) {
void paint(RenderCanvas canvas) {
}
void _visitChildren(PictureRecorder canvas) {
void _visitChildren(RenderCanvas canvas) {
// Sort children if needed
_sortChildren();
@@ -455,7 +455,7 @@ class Node {
}
}
void _postPaint(PictureRecorder canvas) {
void _postPaint(RenderCanvas canvas) {
canvas.restore();
}

View File

@@ -32,7 +32,7 @@ abstract class NodeWithSize extends Node {
/// If you use this method you will need to save and restore your canvas at the beginning and
/// end of your [paint] method.
///
/// void paint(PictureRecorder canvas) {
/// void paint(RenderCanvas canvas) {
/// canvas.save();
/// applyTransformForPivot(canvas);
///
@@ -40,7 +40,7 @@ abstract class NodeWithSize extends Node {
///
/// canvas.restore();
/// }
void applyTransformForPivot(PictureRecorder canvas) {
void applyTransformForPivot(RenderCanvas canvas) {
if (pivot.x != 0 || pivot.y != 0) {
double pivotInPointsX = size.width * pivot.x;
double pivotInPointsY = size.height * pivot.y;

View File

@@ -64,7 +64,7 @@ class Sprite extends NodeWithSize {
_opacity = opacity;
}
void paint(PictureRecorder canvas) {
void paint(RenderCanvas canvas) {
canvas.save();
// Account for pivot point

View File

@@ -251,7 +251,7 @@ class SpriteBox extends RenderBox {
_rootNode._invalidateToBoxTransformMatrix();
}
void paint(RenderObjectDisplayList canvas) {
void paint(RenderCanvas canvas) {
canvas.save();
// Move to correct coordinate space before drawing