Commit bc1b47e9 authored by Adam Barth's avatar Adam Barth

Merge pull request #755 from abarth/rm_painting_canvas

Remove PaintingCanvas
parents 5a17c2bc abf03595
......@@ -139,7 +139,7 @@ abstract class RenderDecoratedSector extends RenderSector {
return;
if (_decoration.backgroundColor != null) {
final PaintingCanvas canvas = context.canvas;
final Canvas canvas = context.canvas;
Paint paint = new Paint()..color = _decoration.backgroundColor;
Path path = new Path();
double outerRadius = (parentData.radius + deltaRadius);
......
......@@ -62,7 +62,7 @@ class RenderTouchDemo extends RenderBox {
}
void paint(PaintingContext context, Offset offset) {
final PaintingCanvas canvas = context.canvas;
final Canvas canvas = context.canvas;
Paint white = new Paint()
..color = const Color(0xFFFFFFFF);
canvas.drawRect(offset & size, white);
......
......@@ -10,7 +10,7 @@ class StockArrowPainter extends CustomPainter {
final Color color;
final double percentChange;
void paint(PaintingCanvas canvas, Size size) {
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()..color = color;
paint.strokeWidth = 1.0;
const double padding = 2.0;
......
......@@ -30,7 +30,7 @@ class _GesturePainter extends CustomPainter {
final bool doubleTapEnabled;
final bool longPressEnabled;
void paint(PaintingCanvas canvas, Size size) {
void paint(Canvas canvas, Size size) {
Point center = (size.center(Point.origin).toOffset() * zoom + offset).toPoint();
double radius = size.width / 2.0 * zoom;
Gradient gradient = new RadialGradient(
......
......@@ -28,7 +28,7 @@ class _MarkerPainter extends CustomPainter {
final double size;
final MarkerType type;
void paint(PaintingCanvas canvas, _) {
void paint(Canvas canvas, _) {
Paint paint = new Paint()..color = const Color(0x8000FF00);
double r = size / 2.0;
canvas.drawCircle(new Point(r, r), r, paint);
......
......@@ -173,7 +173,7 @@ class _RenderSwitch extends RenderToggleable {
final BoxPainter _thumbPainter = new BoxPainter(const BoxDecoration());
void paint(PaintingContext context, Offset offset) {
final PaintingCanvas canvas = context.canvas;
final Canvas canvas = context.canvas;
final bool isActive = onChanged != null;
......
......@@ -209,7 +209,7 @@ class _RenderTabBar extends RenderBox with
return defaultHitTestChildren(result, position: position);
}
void _paintIndicator(PaintingCanvas canvas, RenderBox selectedTab, Offset offset) {
void _paintIndicator(Canvas canvas, RenderBox selectedTab, Offset offset) {
if (indicatorColor == null)
return;
......
......@@ -38,12 +38,6 @@ class ParentData {
String toString() => '<none>';
}
/// Obsolete class that will be removed eventually
class PaintingCanvas extends Canvas {
PaintingCanvas(ui.PictureRecorder recorder, Rect bounds) : super(recorder, bounds);
// TODO(ianh): Just use ui.Canvas everywhere instead
}
typedef void PaintingContextCallback(PaintingContext context, Offset offset);
/// A place to paint.
......@@ -145,14 +139,14 @@ class PaintingContext {
// Recording state
PictureLayer _currentLayer;
ui.PictureRecorder _recorder;
PaintingCanvas _canvas;
Canvas _canvas;
/// The canvas on which to paint.
///
/// The current canvas can change whenever you paint a child using this
/// context, which means it's fragile to hold a reference to the canvas
/// returned by this getter.
PaintingCanvas get canvas {
Canvas get canvas {
if (_canvas == null)
_startRecording();
return _canvas;
......@@ -162,7 +156,7 @@ class PaintingContext {
assert(!_isRecording);
_currentLayer = new PictureLayer(paintBounds: _paintBounds);
_recorder = new ui.PictureRecorder();
_canvas = new PaintingCanvas(_recorder, _paintBounds);
_canvas = new Canvas(_recorder, _paintBounds);
_containerLayer.append(_currentLayer);
}
......
......@@ -991,7 +991,7 @@ class RenderSizeObserver extends RenderProxyBox {
abstract class CustomPainter {
const CustomPainter();
void paint(PaintingCanvas canvas, Size size);
void paint(Canvas canvas, Size size);
bool shouldRepaint(CustomPainter oldDelegate);
bool hitTest(Point position) => null;
}
......
......@@ -121,7 +121,7 @@ class EffectLine extends Node {
}
}
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
if (points.length < 2) return;
_painter.points = points;
......
......@@ -33,7 +33,7 @@ class Label extends Node {
TextPainter _painter;
double _width;
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
if (_painter == null) {
PlainTextSpan textSpan = new PlainTextSpan(_text);
StyledTextSpan styledTextSpan = new StyledTextSpan(_textStyle, <TextSpan>[textSpan]);
......
......@@ -25,14 +25,14 @@ class Layer extends Node with SpritePaint {
..filterQuality = ui.FilterQuality.low
..isAntiAlias = false;
void _prePaint(PaintingCanvas canvas, Matrix4 matrix) {
void _prePaint(Canvas canvas, Matrix4 matrix) {
super._prePaint(canvas, matrix);
_updatePaint(_cachedPaint);
canvas.saveLayer(layerRect, _cachedPaint);
}
void _postPaint(PaintingCanvas canvas, Matrix4 totalMatrix) {
void _postPaint(Canvas canvas, Matrix4 totalMatrix) {
canvas.restore();
super._postPaint(canvas, totalMatrix);
}
......
......@@ -648,7 +648,7 @@ class Node {
// Rendering
void _visit(PaintingCanvas canvas, Matrix4 totalMatrix) {
void _visit(Canvas canvas, Matrix4 totalMatrix) {
assert(canvas != null);
if (!visible) return;
......@@ -657,7 +657,7 @@ class Node {
_postPaint(canvas, totalMatrix);
}
void _prePaint(PaintingCanvas canvas, Matrix4 matrix) {
void _prePaint(Canvas canvas, Matrix4 matrix) {
_savedTotalMatrix = new Matrix4.copy(matrix);
// Get the transformation matrix and apply transform
......@@ -672,7 +672,7 @@ class Node {
/// bounding box's origin, override [NodeWithSize] and call the applyTransformForPivot method before making calls for
/// drawing.
///
/// void paint(PaintingCanvas canvas) {
/// void paint(Canvas canvas) {
/// canvas.save();
/// applyTransformForPivot(canvas);
///
......@@ -680,10 +680,10 @@ class Node {
///
/// canvas.restore();
/// }
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
}
void _visitChildren(PaintingCanvas canvas, Matrix4 totalMatrix) {
void _visitChildren(Canvas canvas, Matrix4 totalMatrix) {
// Sort children if needed
_sortChildren();
......@@ -709,7 +709,7 @@ class Node {
}
}
void _postPaint(PaintingCanvas canvas, Matrix4 totalMatrix) {
void _postPaint(Canvas canvas, Matrix4 totalMatrix) {
totalMatrix.setFrom(_savedTotalMatrix);
}
......
......@@ -33,7 +33,7 @@ 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(PaintingCanvas canvas) {
/// void paint(Canvas canvas) {
/// canvas.save();
/// applyTransformForPivot(canvas);
///
......@@ -41,7 +41,7 @@ class NodeWithSize extends Node {
///
/// canvas.restore();
/// }
void applyTransformForPivot(PaintingCanvas canvas) {
void applyTransformForPivot(Canvas canvas) {
if (pivot.x != 0 || pivot.y != 0) {
double pivotInPointsX = size.width * pivot.x;
double pivotInPointsY = size.height * pivot.y;
......
......@@ -357,7 +357,7 @@ class ParticleSystem extends Node {
_numEmittedParticles++;
}
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
List<ui.RSTransform> transforms = <ui.RSTransform>[];
List<Rect> rects = <Rect>[];
......
......@@ -14,7 +14,7 @@ class _PhysicsDebugDraw extends box2d.DebugDraw {
PhysicsWorld physicsWorld;
PaintingCanvas canvas;
Canvas canvas;
void drawSegment(Vector2 p1, Vector2 p2, box2d.Color3i color) {
Paint paint = new Paint()
......
......@@ -267,7 +267,7 @@ class PhysicsWorld extends Node {
_contactHandler.addContactCallback(callback, tagA, tagB, type);
}
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
if (drawDebug) {
_debugDrawTransform = new Matrix4.fromFloat64List(canvas.getTotalMatrix());
}
......@@ -276,7 +276,7 @@ class PhysicsWorld extends Node {
/// Draws the debug data of the physics world, normally this method isn't
/// invoked directly. Instead, set the [drawDebug] property to true.
void paintDebug(PaintingCanvas canvas) {
void paintDebug(Canvas canvas) {
_debugDraw.canvas = canvas;
b2World.drawDebugData();
}
......
......@@ -44,7 +44,7 @@ class Sprite extends NodeWithSize with SpritePaint {
pivot = new Point(0.5, 0.5);
}
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
// Account for pivot point
applyTransformForPivot(canvas);
......
......@@ -336,7 +336,7 @@ class SpriteBox extends RenderBox {
}
void paint(PaintingContext context, Offset offset) {
final PaintingCanvas canvas = context.canvas;
final Canvas canvas = context.canvas;
canvas.save();
// Move to correct coordinate space before drawing
......
......@@ -73,7 +73,7 @@ class Texture {
return new Texture._fromSpriteFrame(image, name, rect.size, false, false, srcFrame, dstFrame, new Point(0.5, 0.5));
}
void drawTexture(PaintingCanvas canvas, Point position, Paint paint) {
void drawTexture(Canvas canvas, Point position, Paint paint) {
// Get drawing position
double x = position.x;
double y = position.y;
......
......@@ -7,7 +7,7 @@ class TexturedLine extends Node {
TexturedLinePainter painter;
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
painter.paint(canvas);
}
}
......@@ -81,7 +81,7 @@ class TexturedLinePainter {
Paint _cachedPaint = new Paint();
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
// Check input values
assert(_points != null);
if (_points.length < 2) return;
......
......@@ -54,7 +54,7 @@ class VirtualJoystick extends NodeWithSize {
return true;
}
void paint(PaintingCanvas canvas) {
void paint(Canvas canvas) {
applyTransformForPivot(canvas);
canvas.drawCircle(_handlePos, 25.0, _paintHandle);
canvas.drawCircle(_center, 40.0, _paintControl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment