| 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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 } else { | 1007 } else { |
| 1009 performResize(); | 1008 performResize(); |
| 1010 } | 1009 } |
| 1011 } | 1010 } |
| 1012 | 1011 |
| 1013 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}baseline: ${baseline}\nbaselineType: ${baselineType}'; | 1012 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}baseline: ${baseline}\nbaselineType: ${baselineType}'; |
| 1014 } | 1013 } |
| 1015 | 1014 |
| 1016 class RenderImage extends RenderBox { | 1015 class RenderImage extends RenderBox { |
| 1017 | 1016 |
| 1018 RenderImage(String url, Size dimensions) { | 1017 RenderImage(sky.Image image, Size requestedSize) |
| 1019 requestedSize = dimensions; | 1018 : _image = image, _requestedSize = requestedSize; |
| 1020 src = url; | |
| 1021 } | |
| 1022 | 1019 |
| 1023 sky.Image _image; | 1020 sky.Image _image; |
| 1024 String _src; | 1021 sky.Image get image => _image; |
| 1025 String get src => _src; | 1022 void set image (sky.Image value) { |
| 1026 void set src (String value) { | 1023 if (value == _image) |
| 1027 if (value == _src) | |
| 1028 return; | 1024 return; |
| 1029 _src = value; | 1025 _image = value; |
| 1030 image_cache.load(_src).then((result) { | 1026 markNeedsPaint(); |
| 1031 _image = result; | 1027 if (_requestedSize.width == null || _requestedSize.height == null) |
| 1032 if (requestedSize.width == null || requestedSize.height == null) | 1028 markNeedsLayout(); |
| 1033 markNeedsLayout(); | |
| 1034 markNeedsPaint(); | |
| 1035 }); | |
| 1036 } | 1029 } |
| 1037 | 1030 |
| 1038 Size _requestedSize; | 1031 Size _requestedSize; |
| 1039 Size get requestedSize => _requestedSize; | 1032 Size get requestedSize => _requestedSize; |
| 1040 void set requestedSize (Size value) { | 1033 void set requestedSize (Size value) { |
| 1041 if (value == null) | 1034 if (value == null) |
| 1042 value = const Size(null, null); | 1035 value = const Size(null, null); |
| 1043 if (value == _requestedSize) | 1036 if (value == _requestedSize) |
| 1044 return; | 1037 return; |
| 1045 _requestedSize = value; | 1038 _requestedSize = value; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 canvas.translate(offset.dx, offset.dy); | 1100 canvas.translate(offset.dx, offset.dy); |
| 1108 canvas.scale(widthScale, heightScale); | 1101 canvas.scale(widthScale, heightScale); |
| 1109 offset = Offset.zero; | 1102 offset = Offset.zero; |
| 1110 } | 1103 } |
| 1111 Paint paint = new Paint(); | 1104 Paint paint = new Paint(); |
| 1112 canvas.drawImage(_image, offset.toPoint(), paint); | 1105 canvas.drawImage(_image, offset.toPoint(), paint); |
| 1113 if (needsScale) | 1106 if (needsScale) |
| 1114 canvas.restore(); | 1107 canvas.restore(); |
| 1115 } | 1108 } |
| 1116 | 1109 |
| 1117 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}url: ${src}\n${prefix}dimensions: ${requestedSize}\n'; | 1110 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}dimensions: ${requestedSize}\n'; |
| 1118 } | 1111 } |
| 1119 | 1112 |
| 1120 class RenderDecoratedBox extends RenderProxyBox { | 1113 class RenderDecoratedBox extends RenderProxyBox { |
| 1121 | 1114 |
| 1122 RenderDecoratedBox({ | 1115 RenderDecoratedBox({ |
| 1123 BoxDecoration decoration, | 1116 BoxDecoration decoration, |
| 1124 RenderBox child | 1117 RenderBox child |
| 1125 }) : _painter = new BoxPainter(decoration), super(child); | 1118 }) : _painter = new BoxPainter(decoration), super(child); |
| 1126 | 1119 |
| 1127 BoxPainter _painter; | 1120 BoxPainter _painter; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 | 1420 |
| 1428 void defaultPaint(PaintingCanvas canvas, Offset offset) { | 1421 void defaultPaint(PaintingCanvas canvas, Offset offset) { |
| 1429 RenderBox child = firstChild; | 1422 RenderBox child = firstChild; |
| 1430 while (child != null) { | 1423 while (child != null) { |
| 1431 assert(child.parentData is ParentDataType); | 1424 assert(child.parentData is ParentDataType); |
| 1432 canvas.paintChild(child, child.parentData.position + offset); | 1425 canvas.paintChild(child, child.parentData.position + offset); |
| 1433 child = child.parentData.nextSibling; | 1426 child = child.parentData.nextSibling; |
| 1434 } | 1427 } |
| 1435 } | 1428 } |
| 1436 } | 1429 } |
| OLD | NEW |