OLD | NEW |
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:vector_math/vector_math.dart'; | 8 import 'package:vector_math/vector_math.dart'; |
9 | 9 |
10 import '../base/debug.dart'; | 10 import '../base/debug.dart'; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 482 |
483 void hitTestChildren(HitTestResult result, { Point position }) { | 483 void hitTestChildren(HitTestResult result, { Point position }) { |
484 if (child != null) | 484 if (child != null) |
485 child.hitTest(result, position: position); | 485 child.hitTest(result, position: position); |
486 else | 486 else |
487 super.hitTestChildren(result, position: position); | 487 super.hitTestChildren(result, position: position); |
488 } | 488 } |
489 | 489 |
490 void paint(PaintingCanvas canvas, Offset offset) { | 490 void paint(PaintingCanvas canvas, Offset offset) { |
491 if (child != null) | 491 if (child != null) |
492 child.paint(canvas, offset); | 492 canvas.paintChild(child, offset.toPoint()); |
493 } | 493 } |
494 | 494 |
495 } | 495 } |
496 | 496 |
497 class RenderConstrainedBox extends RenderProxyBox { | 497 class RenderConstrainedBox extends RenderProxyBox { |
498 RenderConstrainedBox({ | 498 RenderConstrainedBox({ |
499 RenderBox child, | 499 RenderBox child, |
500 BoxConstraints additionalConstraints | 500 BoxConstraints additionalConstraints |
501 }) : super(child), _additionalConstraints = additionalConstraints { | 501 }) : super(child), _additionalConstraints = additionalConstraints { |
502 assert(additionalConstraints != null); | 502 assert(additionalConstraints != null); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 } | 655 } |
656 | 656 |
657 void paint(PaintingCanvas canvas, Offset offset) { | 657 void paint(PaintingCanvas canvas, Offset offset) { |
658 if (child != null) { | 658 if (child != null) { |
659 int a = (_opacity * 255).round(); | 659 int a = (_opacity * 255).round(); |
660 | 660 |
661 if (a == 0) | 661 if (a == 0) |
662 return; | 662 return; |
663 | 663 |
664 if (a == 255) { | 664 if (a == 255) { |
665 child.paint(canvas, offset); | 665 canvas.paintChild(child, offset.toPoint()); |
666 return; | 666 return; |
667 } | 667 } |
668 | 668 |
669 Paint paint = new Paint() | 669 Paint paint = new Paint() |
670 ..color = new Color.fromARGB(a, 0, 0, 0) | 670 ..color = new Color.fromARGB(a, 0, 0, 0) |
671 ..setTransferMode(sky.TransferMode.srcOver); | 671 ..setTransferMode(sky.TransferMode.srcOver); |
672 canvas.saveLayer(null, paint); | 672 canvas.saveLayer(null, paint); |
673 child.paint(canvas, offset); | 673 canvas.paintChild(child, offset.toPoint()); |
674 canvas.restore(); | 674 canvas.restore(); |
675 } | 675 } |
676 } | 676 } |
677 } | 677 } |
678 | 678 |
679 class RenderColorFilter extends RenderProxyBox { | 679 class RenderColorFilter extends RenderProxyBox { |
680 RenderColorFilter({ RenderBox child, Color color, sky.TransferMode transferMod
e }) | 680 RenderColorFilter({ RenderBox child, Color color, sky.TransferMode transferMod
e }) |
681 : _color = color, _transferMode = transferMode, super(child) { | 681 : _color = color, _transferMode = transferMode, super(child) { |
682 } | 682 } |
683 | 683 |
(...skipping 15 matching lines...) Expand all Loading... |
699 return; | 699 return; |
700 _transferMode = value; | 700 _transferMode = value; |
701 markNeedsPaint(); | 701 markNeedsPaint(); |
702 } | 702 } |
703 | 703 |
704 void paint(PaintingCanvas canvas, Offset offset) { | 704 void paint(PaintingCanvas canvas, Offset offset) { |
705 if (child != null) { | 705 if (child != null) { |
706 Paint paint = new Paint() | 706 Paint paint = new Paint() |
707 ..setColorFilter(new sky.ColorFilter.mode(_color, _transferMode)); | 707 ..setColorFilter(new sky.ColorFilter.mode(_color, _transferMode)); |
708 canvas.saveLayer(null, paint); | 708 canvas.saveLayer(null, paint); |
709 child.paint(canvas, offset); | 709 canvas.paintChild(child, offset.toPoint()); |
710 canvas.restore(); | 710 canvas.restore(); |
711 } | 711 } |
712 } | 712 } |
713 } | 713 } |
714 | 714 |
715 class RenderClipRect extends RenderProxyBox { | 715 class RenderClipRect extends RenderProxyBox { |
716 RenderClipRect({ RenderBox child }) : super(child); | 716 RenderClipRect({ RenderBox child }) : super(child); |
717 | 717 |
718 void paint(PaintingCanvas canvas, Offset offset) { | 718 void paint(PaintingCanvas canvas, Offset offset) { |
719 if (child != null) { | 719 if (child != null) { |
720 canvas.save(); | 720 canvas.save(); |
721 canvas.clipRect(offset & size); | 721 canvas.clipRect(offset & size); |
722 child.paint(canvas, offset); | 722 canvas.paintChild(child, offset.toPoint()); |
723 canvas.restore(); | 723 canvas.restore(); |
724 } | 724 } |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 class RenderClipRRect extends RenderProxyBox { | 728 class RenderClipRRect extends RenderProxyBox { |
729 RenderClipRRect({ RenderBox child, double xRadius, double yRadius }) | 729 RenderClipRRect({ RenderBox child, double xRadius, double yRadius }) |
730 : _xRadius = xRadius, _yRadius = yRadius, super(child) { | 730 : _xRadius = xRadius, _yRadius = yRadius, super(child) { |
731 assert(_xRadius != null); | 731 assert(_xRadius != null); |
732 assert(_yRadius != null); | 732 assert(_yRadius != null); |
(...skipping 18 matching lines...) Expand all Loading... |
751 _yRadius = value; | 751 _yRadius = value; |
752 markNeedsPaint(); | 752 markNeedsPaint(); |
753 } | 753 } |
754 | 754 |
755 void paint(PaintingCanvas canvas, Offset offset) { | 755 void paint(PaintingCanvas canvas, Offset offset) { |
756 if (child != null) { | 756 if (child != null) { |
757 Rect rect = offset & size; | 757 Rect rect = offset & size; |
758 canvas.saveLayer(rect, new Paint()); | 758 canvas.saveLayer(rect, new Paint()); |
759 sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius); | 759 sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius); |
760 canvas.clipRRect(rrect); | 760 canvas.clipRRect(rrect); |
761 child.paint(canvas, offset); | 761 canvas.paintChild(child, offset.toPoint()); |
762 canvas.restore(); | 762 canvas.restore(); |
763 } | 763 } |
764 } | 764 } |
765 } | 765 } |
766 | 766 |
767 class RenderClipOval extends RenderProxyBox { | 767 class RenderClipOval extends RenderProxyBox { |
768 RenderClipOval({ RenderBox child }) : super(child); | 768 RenderClipOval({ RenderBox child }) : super(child); |
769 | 769 |
770 void paint(PaintingCanvas canvas, Offset offset) { | 770 void paint(PaintingCanvas canvas, Offset offset) { |
771 if (child != null) { | 771 if (child != null) { |
772 Rect rect = offset & size; | 772 Rect rect = offset & size; |
773 canvas.saveLayer(rect, new Paint()); | 773 canvas.saveLayer(rect, new Paint()); |
774 Path path = new Path(); | 774 Path path = new Path(); |
775 path.addOval(rect); | 775 path.addOval(rect); |
776 canvas.clipPath(path); | 776 canvas.clipPath(path); |
777 child.paint(canvas, offset); | 777 canvas.paintChild(child, offset.toPoint()); |
778 canvas.restore(); | 778 canvas.restore(); |
779 } | 779 } |
780 } | 780 } |
781 } | 781 } |
782 | 782 |
783 abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
n<RenderBox> { | 783 abstract class RenderShiftedBox extends RenderBox with RenderObjectWithChildMixi
n<RenderBox> { |
784 | 784 |
785 // Abstract class for one-child-layout render boxes | 785 // Abstract class for one-child-layout render boxes |
786 | 786 |
787 RenderShiftedBox(RenderBox child) { | 787 RenderShiftedBox(RenderBox child) { |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1435 |
1436 void defaultPaint(PaintingCanvas canvas, Offset offset) { | 1436 void defaultPaint(PaintingCanvas canvas, Offset offset) { |
1437 RenderBox child = firstChild; | 1437 RenderBox child = firstChild; |
1438 while (child != null) { | 1438 while (child != null) { |
1439 assert(child.parentData is ParentDataType); | 1439 assert(child.parentData is ParentDataType); |
1440 canvas.paintChild(child, child.parentData.position + offset); | 1440 canvas.paintChild(child, child.parentData.position + offset); |
1441 child = child.parentData.nextSibling; | 1441 child = child.parentData.nextSibling; |
1442 } | 1442 } |
1443 } | 1443 } |
1444 } | 1444 } |
OLD | NEW |