Chromium Code Reviews

Side by Side Diff: sky/examples/rendering/sector_layout.dart

Issue 1190123003: Decouple Canvas from DisplayList and map Picture and PictureRecorder more directly to their Skia co… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rework the API a bit Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 import 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 7
8 import 'package:sky/rendering/box.dart'; 8 import 'package:sky/rendering/box.dart';
9 import 'package:sky/rendering/object.dart'; 9 import 'package:sky/rendering/object.dart';
10 import 'package:sky/rendering/sky_binding.dart'; 10 import 'package:sky/rendering/sky_binding.dart';
(...skipping 96 matching lines...)
107 BoxDecoration _decoration; 107 BoxDecoration _decoration;
108 BoxDecoration get decoration => _decoration; 108 BoxDecoration get decoration => _decoration;
109 void set decoration (BoxDecoration value) { 109 void set decoration (BoxDecoration value) {
110 if (value == _decoration) 110 if (value == _decoration)
111 return; 111 return;
112 _decoration = value; 112 _decoration = value;
113 markNeedsPaint(); 113 markNeedsPaint();
114 } 114 }
115 115
116 // origin must be set to the center of the circle 116 // origin must be set to the center of the circle
117 void paint(RenderObjectDisplayList canvas) { 117 void paint(RenderCanvas canvas) {
118 assert(deltaRadius != null); 118 assert(deltaRadius != null);
119 assert(deltaTheta != null); 119 assert(deltaTheta != null);
120 assert(parentData is SectorParentData); 120 assert(parentData is SectorParentData);
121 121
122 if (_decoration == null) 122 if (_decoration == null)
123 return; 123 return;
124 124
125 if (_decoration.backgroundColor != null) { 125 if (_decoration.backgroundColor != null) {
126 Paint paint = new Paint()..color = _decoration.backgroundColor; 126 Paint paint = new Paint()..color = _decoration.backgroundColor;
127 Path path = new Path(); 127 Path path = new Path();
(...skipping 116 matching lines...)
244 if (child != null) { 244 if (child != null) {
245 innerTheta += paddingTheta; 245 innerTheta += paddingTheta;
246 remainingDeltaTheta -= paddingTheta; 246 remainingDeltaTheta -= paddingTheta;
247 } 247 }
248 } 248 }
249 deltaTheta = innerTheta; 249 deltaTheta = innerTheta;
250 } 250 }
251 251
252 // paint origin is 0,0 of our circle 252 // paint origin is 0,0 of our circle
253 // each sector then knows how to paint itself at its location 253 // each sector then knows how to paint itself at its location
254 void paint(RenderObjectDisplayList canvas) { 254 void paint(RenderCanvas canvas) {
255 // TODO(ianh): avoid code duplication 255 // TODO(ianh): avoid code duplication
256 super.paint(canvas); 256 super.paint(canvas);
257 RenderSector child = firstChild; 257 RenderSector child = firstChild;
258 while (child != null) { 258 while (child != null) {
259 assert(child.parentData is SectorChildListParentData); 259 assert(child.parentData is SectorChildListParentData);
260 canvas.paintChild(child, Point.origin); 260 canvas.paintChild(child, Point.origin);
261 child = child.parentData.nextSibling; 261 child = child.parentData.nextSibling;
262 } 262 }
263 } 263 }
264 264
(...skipping 84 matching lines...)
349 assert(child.parentData is SectorChildListParentData); 349 assert(child.parentData is SectorChildListParentData);
350 child = child.parentData.nextSibling; 350 child = child.parentData.nextSibling;
351 childRadius += padding; 351 childRadius += padding;
352 remainingDeltaRadius -= padding; 352 remainingDeltaRadius -= padding;
353 } 353 }
354 deltaRadius = childRadius - this.parentData.radius; 354 deltaRadius = childRadius - this.parentData.radius;
355 } 355 }
356 356
357 // paint origin is 0,0 of our circle 357 // paint origin is 0,0 of our circle
358 // each sector then knows how to paint itself at its location 358 // each sector then knows how to paint itself at its location
359 void paint(RenderObjectDisplayList canvas) { 359 void paint(RenderCanvas canvas) {
360 // TODO(ianh): avoid code duplication 360 // TODO(ianh): avoid code duplication
361 super.paint(canvas); 361 super.paint(canvas);
362 RenderSector child = firstChild; 362 RenderSector child = firstChild;
363 while (child != null) { 363 while (child != null) {
364 assert(child.parentData is SectorChildListParentData); 364 assert(child.parentData is SectorChildListParentData);
365 canvas.paintChild(child, Point.origin); 365 canvas.paintChild(child, Point.origin);
366 child = child.parentData.nextSibling; 366 child = child.parentData.nextSibling;
367 } 367 }
368 } 368 }
369 369
(...skipping 73 matching lines...)
443 assert(child.parentData is SectorParentData); 443 assert(child.parentData is SectorParentData);
444 child.parentData.radius = innerRadius; 444 child.parentData.radius = innerRadius;
445 child.parentData.theta = 0.0; 445 child.parentData.theta = 0.0;
446 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p arentUsesSize: true); 446 child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), p arentUsesSize: true);
447 double dimension = (innerRadius + child.deltaRadius) * 2.0; 447 double dimension = (innerRadius + child.deltaRadius) * 2.0;
448 size = constraints.constrain(new Size(dimension, dimension)); 448 size = constraints.constrain(new Size(dimension, dimension));
449 } 449 }
450 } 450 }
451 451
452 // paint origin is 0,0 of our circle 452 // paint origin is 0,0 of our circle
453 void paint(RenderObjectDisplayList canvas) { 453 void paint(RenderCanvas canvas) {
454 super.paint(canvas); 454 super.paint(canvas);
455 if (child != null) { 455 if (child != null) {
456 Rect bounds = new Rect.fromSize(size); 456 Rect bounds = new Rect.fromSize(size);
457 canvas.paintChild(child, bounds.center); 457 canvas.paintChild(child, bounds.center);
458 } 458 }
459 } 459 }
460 460
461 bool hitTest(HitTestResult result, { Point position }) { 461 bool hitTest(HitTestResult result, { Point position }) {
462 double x = position.x; 462 double x = position.x;
463 double y = position.y; 463 double y = position.y;
(...skipping 54 matching lines...)
518 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0)); 518 stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20 .0));
519 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0)); 519 stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20 .0));
520 stack.add(new RenderSolidColor(const Color(0xFF00FF00))); 520 stack.add(new RenderSolidColor(const Color(0xFF00FF00)));
521 rootCircle.add(stack); 521 rootCircle.add(stack);
522 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle ); 522 return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle );
523 } 523 }
524 524
525 void main() { 525 void main() {
526 new SkyBinding(root: buildSectorExample()); 526 new SkyBinding(root: buildSectorExample());
527 } 527 }
OLDNEW

Powered by Google App Engine