| 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'; |
| 11 import '../mojo/net/image_cache.dart' as image_cache; | |
| 12 import '../painting/box_painter.dart'; | 11 import '../painting/box_painter.dart'; |
| 13 import 'object.dart'; | 12 import 'object.dart'; |
| 14 | 13 |
| 15 export '../painting/box_painter.dart'; | 14 export '../painting/box_painter.dart'; |
| 16 | 15 |
| 17 // GENERIC BOX RENDERING | 16 // GENERIC BOX RENDERING |
| 18 // Anything that has a concept of x, y, width, height is going to derive from th
is | 17 // Anything that has a concept of x, y, width, height is going to derive from th
is |
| 19 | 18 |
| 20 // This class should only be used in debug builds | 19 // This class should only be used in debug builds |
| 21 class _DebugSize extends Size { | 20 class _DebugSize extends Size { |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 } else { | 884 } else { |
| 886 performResize(); | 885 performResize(); |
| 887 } | 886 } |
| 888 } | 887 } |
| 889 | 888 |
| 890 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}horizontal: ${horizontal}\n${prefix}vertical: ${vertical}\n'; | 889 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}horizontal: ${horizontal}\n${prefix}vertical: ${vertical}\n'; |
| 891 } | 890 } |
| 892 | 891 |
| 893 class RenderImage extends RenderBox { | 892 class RenderImage extends RenderBox { |
| 894 | 893 |
| 895 RenderImage(String url, Size dimensions) { | 894 RenderImage(sky.Image image, Size requestedSize) |
| 896 requestedSize = dimensions; | 895 : _image = image, _requestedSize = requestedSize; |
| 897 src = url; | |
| 898 } | |
| 899 | 896 |
| 900 sky.Image _image; | 897 sky.Image _image; |
| 901 String _src; | 898 sky.Image get image => _image; |
| 902 String get src => _src; | 899 void set image (sky.Image value) { |
| 903 void set src (String value) { | 900 if (value == _image) |
| 904 if (value == _src) | |
| 905 return; | 901 return; |
| 906 _src = value; | 902 _image = value; |
| 907 image_cache.load(_src).then((result) { | 903 markNeedsPaint(); |
| 908 _image = result; | 904 if (_requestedSize.width == null || _requestedSize.height == null) |
| 909 if (requestedSize.width == null || requestedSize.height == null) | 905 markNeedsLayout(); |
| 910 markNeedsLayout(); | |
| 911 markNeedsPaint(); | |
| 912 }); | |
| 913 } | 906 } |
| 914 | 907 |
| 915 Size _requestedSize; | 908 Size _requestedSize; |
| 916 Size get requestedSize => _requestedSize; | 909 Size get requestedSize => _requestedSize; |
| 917 void set requestedSize (Size value) { | 910 void set requestedSize (Size value) { |
| 918 if (value == null) | 911 if (value == null) |
| 919 value = const Size(null, null); | 912 value = const Size(null, null); |
| 920 if (value == _requestedSize) | 913 if (value == _requestedSize) |
| 921 return; | 914 return; |
| 922 _requestedSize = value; | 915 _requestedSize = value; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 canvas.translate(offset.dx, offset.dy); | 977 canvas.translate(offset.dx, offset.dy); |
| 985 canvas.scale(widthScale, heightScale); | 978 canvas.scale(widthScale, heightScale); |
| 986 offset = Offset.zero; | 979 offset = Offset.zero; |
| 987 } | 980 } |
| 988 Paint paint = new Paint(); | 981 Paint paint = new Paint(); |
| 989 canvas.drawImage(_image, offset.toPoint(), paint); | 982 canvas.drawImage(_image, offset.toPoint(), paint); |
| 990 if (needsScale) | 983 if (needsScale) |
| 991 canvas.restore(); | 984 canvas.restore(); |
| 992 } | 985 } |
| 993 | 986 |
| 994 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}url: ${src}\n${prefix}dimensions: ${requestedSize}\n'; | 987 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}dimensions: ${requestedSize}\n'; |
| 995 } | 988 } |
| 996 | 989 |
| 997 class RenderDecoratedBox extends RenderProxyBox { | 990 class RenderDecoratedBox extends RenderProxyBox { |
| 998 | 991 |
| 999 RenderDecoratedBox({ | 992 RenderDecoratedBox({ |
| 1000 BoxDecoration decoration, | 993 BoxDecoration decoration, |
| 1001 RenderBox child | 994 RenderBox child |
| 1002 }) : _painter = new BoxPainter(decoration), super(child); | 995 }) : _painter = new BoxPainter(decoration), super(child); |
| 1003 | 996 |
| 1004 BoxPainter _painter; | 997 BoxPainter _painter; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 | 1297 |
| 1305 void defaultPaint(PaintingCanvas canvas, Offset offset) { | 1298 void defaultPaint(PaintingCanvas canvas, Offset offset) { |
| 1306 RenderBox child = firstChild; | 1299 RenderBox child = firstChild; |
| 1307 while (child != null) { | 1300 while (child != null) { |
| 1308 assert(child.parentData is ParentDataType); | 1301 assert(child.parentData is ParentDataType); |
| 1309 canvas.paintChild(child, child.parentData.position + offset); | 1302 canvas.paintChild(child, child.parentData.position + offset); |
| 1310 child = child.parentData.nextSibling; | 1303 child = child.parentData.nextSibling; |
| 1311 } | 1304 } |
| 1312 } | 1305 } |
| 1313 } | 1306 } |
| OLD | NEW |