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

Unified Diff: sky/sdk/lib/example/rendering/sector_layout.dart

Issue 1209413004: Instead of applying a transform for every RenderObject, pass down an Offset for where to paint. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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/sdk/lib/example/rendering/sector_layout.dart
diff --git a/sky/sdk/lib/example/rendering/sector_layout.dart b/sky/sdk/lib/example/rendering/sector_layout.dart
index a1aa03bcbecacab4b461122de119323c53595db9..68d38afe85ce24958d12cdd318ba2e8aefc17d07 100644
--- a/sky/sdk/lib/example/rendering/sector_layout.dart
+++ b/sky/sdk/lib/example/rendering/sector_layout.dart
@@ -126,8 +126,8 @@ abstract class RenderDecoratedSector extends RenderSector {
markNeedsPaint();
}
- // origin must be set to the center of the circle
- void paint(RenderCanvas canvas) {
+ // offset must point to the center of the circle
+ void paint(RenderCanvas canvas, Offset offset) {
assert(deltaRadius != null);
assert(deltaTheta != null);
assert(parentData is SectorParentData);
@@ -139,10 +139,10 @@ abstract class RenderDecoratedSector extends RenderSector {
Paint paint = new Paint()..color = _decoration.backgroundColor;
Path path = new Path();
double outerRadius = (parentData.radius + deltaRadius);
- Rect outerBounds = new Rect.fromLTRB(-outerRadius, -outerRadius, outerRadius, outerRadius);
+ Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius);
path.arcTo(outerBounds, parentData.theta, deltaTheta, true);
double innerRadius = parentData.radius;
- Rect innerBounds = new Rect.fromLTRB(-innerRadius, -innerRadius, innerRadius, innerRadius);
+ Rect innerBounds = new Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius);
path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false);
path.close();
canvas.drawPath(path, paint);
@@ -262,15 +262,15 @@ class RenderSectorRing extends RenderSectorWithChildren {
deltaTheta = innerTheta;
}
- // paint origin is 0,0 of our circle
+ // offset must point to the center of our circle
// each sector then knows how to paint itself at its location
- void paint(RenderCanvas canvas) {
+ void paint(RenderCanvas canvas, Offset offset) {
// TODO(ianh): avoid code duplication
- super.paint(canvas);
+ super.paint(canvas, offset);
RenderSector child = firstChild;
while (child != null) {
assert(child.parentData is SectorChildListParentData);
- canvas.paintChild(child, Point.origin);
+ canvas.paintChild(child, offset.toPoint());
child = child.parentData.nextSibling;
}
}
@@ -367,15 +367,15 @@ class RenderSectorSlice extends RenderSectorWithChildren {
deltaRadius = childRadius - this.parentData.radius;
}
- // paint origin is 0,0 of our circle
+ // offset must point to the center of our circle
// each sector then knows how to paint itself at its location
- void paint(RenderCanvas canvas) {
+ void paint(RenderCanvas canvas, Offset offset) {
// TODO(ianh): avoid code duplication
- super.paint(canvas);
+ super.paint(canvas, offset);
RenderSector child = firstChild;
while (child != null) {
assert(child.parentData is SectorChildListParentData);
- canvas.paintChild(child, Point.origin);
+ canvas.paintChild(child, offset.toPoint());
child = child.parentData.nextSibling;
}
}
@@ -462,11 +462,11 @@ class RenderBoxToRenderSectorAdapter extends RenderBox {
}
}
- // paint origin is 0,0 of our circle
- void paint(RenderCanvas canvas) {
- super.paint(canvas);
+ void paint(RenderCanvas canvas, Offset offset) {
+ super.paint(canvas, offset);
if (child != null) {
- Rect bounds = new Rect.fromSize(size);
+ Rect bounds = offset + size;
+ // we move the offset to the center of the circle for the RenderSectors
canvas.paintChild(child, bounds.center);
}
}

Powered by Google App Engine
This is Rietveld 408576698