| 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 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 import 'object.dart'; | 8 import 'object.dart'; |
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; | 10 import 'package:sky/framework/net/image_cache.dart' as image_cache; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool hitTest(HitTestResult result, { sky.Point position }) { | 145 bool hitTest(HitTestResult result, { sky.Point position }) { |
| 146 hitTestChildren(result, position: position); | 146 hitTestChildren(result, position: position); |
| 147 result.add(this); | 147 result.add(this); |
| 148 return true; | 148 return true; |
| 149 } | 149 } |
| 150 void hitTestChildren(HitTestResult result, { sky.Point position }) { } | 150 void hitTestChildren(HitTestResult result, { sky.Point position }) { } |
| 151 | 151 |
| 152 sky.Size size = new sky.Size(0.0, 0.0); | 152 sky.Size size = new sky.Size(0.0, 0.0); |
| 153 |
| 154 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}size: ${size}\n'; |
| 153 } | 155 } |
| 154 | 156 |
| 155 abstract class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<
RenderBox> { | 157 abstract class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<
RenderBox> { |
| 156 RenderProxyBox(RenderBox child) { | 158 RenderProxyBox(RenderBox child) { |
| 157 this.child = child; | 159 this.child = child; |
| 158 } | 160 } |
| 159 | 161 |
| 160 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 162 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 161 if (child != null) | 163 if (child != null) |
| 162 return child.getIntrinsicDimensions(constraints); | 164 return child.getIntrinsicDimensions(constraints); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { | 210 sky.Size getIntrinsicDimensions(BoxConstraints constraints) { |
| 209 return constraints.constrain(_desiredSize); | 211 return constraints.constrain(_desiredSize); |
| 210 } | 212 } |
| 211 | 213 |
| 212 void performLayout() { | 214 void performLayout() { |
| 213 size = constraints.constrain(_desiredSize); | 215 size = constraints.constrain(_desiredSize); |
| 214 if (child != null) | 216 if (child != null) |
| 215 child.layout(new BoxConstraints.tight(size)); | 217 child.layout(new BoxConstraints.tight(size)); |
| 216 } | 218 } |
| 217 | 219 |
| 218 String debugDescribeSettings(String prefix) => '${prefix}desiredSize: ${desire
dSize}'; | 220 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}desiredSize: ${desiredSize}\n'; |
| 219 } | 221 } |
| 220 | 222 |
| 221 class RenderClip extends RenderProxyBox { | 223 class RenderClip extends RenderProxyBox { |
| 222 RenderClip({ RenderBox child }) : super(child); | 224 RenderClip({ RenderBox child }) : super(child); |
| 223 | 225 |
| 224 void paint(RenderObjectDisplayList canvas) { | 226 void paint(RenderObjectDisplayList canvas) { |
| 225 if (child != null) { | 227 if (child != null) { |
| 226 canvas.save(); | 228 canvas.save(); |
| 227 canvas.clipRect(new sky.Rect.fromSize(size)); | 229 canvas.clipRect(new sky.Rect.fromSize(size)); |
| 228 child.paint(canvas); | 230 child.paint(canvas); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (child != null) { | 283 if (child != null) { |
| 282 assert(child.parentData is BoxParentData); | 284 assert(child.parentData is BoxParentData); |
| 283 sky.Rect childBounds = new sky.Rect.fromPointAndSize(child.parentData.posi
tion, child.size); | 285 sky.Rect childBounds = new sky.Rect.fromPointAndSize(child.parentData.posi
tion, child.size); |
| 284 if (childBounds.contains(position)) { | 286 if (childBounds.contains(position)) { |
| 285 child.hitTest(result, position: new sky.Point(position.x - child.parentD
ata.position.x, | 287 child.hitTest(result, position: new sky.Point(position.x - child.parentD
ata.position.x, |
| 286 position.y - child.parentD
ata.position.y)); | 288 position.y - child.parentD
ata.position.y)); |
| 287 } | 289 } |
| 288 } | 290 } |
| 289 } | 291 } |
| 290 | 292 |
| 291 String debugDescribeSettings(String prefix) => '${prefix}padding: ${padding}'; | 293 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}padding: ${padding}\n'; |
| 292 } | 294 } |
| 293 | 295 |
| 294 class RenderImage extends RenderBox { | 296 class RenderImage extends RenderBox { |
| 295 | 297 |
| 296 RenderImage(String url, sky.Size dimensions) { | 298 RenderImage(String url, sky.Size dimensions) { |
| 297 requestedSize = dimensions; | 299 requestedSize = dimensions; |
| 298 src = url; | 300 src = url; |
| 299 } | 301 } |
| 300 | 302 |
| 301 sky.Image _image; | 303 sky.Image _image; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 double heightScale = size.height / _image.height; | 359 double heightScale = size.height / _image.height; |
| 358 canvas.save(); | 360 canvas.save(); |
| 359 canvas.scale(widthScale, heightScale); | 361 canvas.scale(widthScale, heightScale); |
| 360 } | 362 } |
| 361 sky.Paint paint = new sky.Paint(); | 363 sky.Paint paint = new sky.Paint(); |
| 362 canvas.drawImage(_image, 0.0, 0.0, paint); | 364 canvas.drawImage(_image, 0.0, 0.0, paint); |
| 363 if (needsScale) | 365 if (needsScale) |
| 364 canvas.restore(); | 366 canvas.restore(); |
| 365 } | 367 } |
| 366 | 368 |
| 367 String debugDescribeSettings(String prefix) => '${prefix}url: ${src}\n${prefix
}dimensions: ${requestedSize}'; | 369 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}url: ${src}\n${prefix}dimensions: ${requestedSize}\n'; |
| 368 } | 370 } |
| 369 | 371 |
| 370 class BorderSide { | 372 class BorderSide { |
| 371 const BorderSide({ | 373 const BorderSide({ |
| 372 this.color: const sky.Color(0xFF000000), | 374 this.color: const sky.Color(0xFF000000), |
| 373 this.width: 1.0 | 375 this.width: 1.0 |
| 374 }); | 376 }); |
| 375 final sky.Color color; | 377 final sky.Color color; |
| 376 final double width; | 378 final double width; |
| 377 | 379 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); | 508 path.lineTo(_decoration.border.left.width, size.height - _decoration.borde
r.bottom.width); |
| 507 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); | 509 path.lineTo(_decoration.border.left.width, _decoration.border.top.width); |
| 508 path.lineTo(0.0,0.0); | 510 path.lineTo(0.0,0.0); |
| 509 path.close(); | 511 path.close(); |
| 510 canvas.drawPath(path, paint); | 512 canvas.drawPath(path, paint); |
| 511 } | 513 } |
| 512 | 514 |
| 513 super.paint(canvas); | 515 super.paint(canvas); |
| 514 } | 516 } |
| 515 | 517 |
| 516 String debugDescribeSettings(String prefix) => '${prefix}decoration:\n${decora
tion.toString(prefix + " ")}'; | 518 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(
prefix)}${prefix}decoration:\n${decoration.toString(prefix + " ")}\n'; |
| 517 } | 519 } |
| 518 | 520 |
| 519 class RenderTransform extends RenderProxyBox { | 521 class RenderTransform extends RenderProxyBox { |
| 520 RenderTransform({ | 522 RenderTransform({ |
| 521 Matrix4 transform, | 523 Matrix4 transform, |
| 522 RenderBox child | 524 RenderBox child |
| 523 }) : super(child) { | 525 }) : super(child) { |
| 524 assert(transform != null); | 526 assert(transform != null); |
| 525 this.transform = transform; | 527 this.transform = transform; |
| 526 } | 528 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 sky.Point transformed = new sky.Point(transformed3.x, transformed3.y); | 572 sky.Point transformed = new sky.Point(transformed3.x, transformed3.y); |
| 571 super.hitTestChildren(result, position: transformed); | 573 super.hitTestChildren(result, position: transformed); |
| 572 } | 574 } |
| 573 | 575 |
| 574 void paint(RenderObjectDisplayList canvas) { | 576 void paint(RenderObjectDisplayList canvas) { |
| 575 canvas.save(); | 577 canvas.save(); |
| 576 canvas.concat(_transform.storage); | 578 canvas.concat(_transform.storage); |
| 577 super.paint(canvas); | 579 super.paint(canvas); |
| 578 canvas.restore(); | 580 canvas.restore(); |
| 579 } | 581 } |
| 582 |
| 583 String debugDescribeSettings(String prefix) { |
| 584 List<String> result = _transform.toString().split('\n').map((s) => '$prefix
$s\n').toList(); |
| 585 result.removeLast(); |
| 586 return '${super.debugDescribeSettings(prefix)}${prefix}transform matrix:\n${
result.join()}'; |
| 587 } |
| 580 } | 588 } |
| 581 | 589 |
| 582 typedef void SizeChangedCallback(sky.Size newSize); | 590 typedef void SizeChangedCallback(sky.Size newSize); |
| 583 | 591 |
| 584 class RenderSizeObserver extends RenderProxyBox { | 592 class RenderSizeObserver extends RenderProxyBox { |
| 585 RenderSizeObserver({ | 593 RenderSizeObserver({ |
| 586 this.callback, | 594 this.callback, |
| 587 RenderBox child | 595 RenderBox child |
| 588 }) : super(child) { | 596 }) : super(child) { |
| 589 assert(callback != null); | 597 assert(callback != null); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 766 |
| 759 void defaultPaint(RenderObjectDisplayList canvas) { | 767 void defaultPaint(RenderObjectDisplayList canvas) { |
| 760 RenderBox child = firstChild; | 768 RenderBox child = firstChild; |
| 761 while (child != null) { | 769 while (child != null) { |
| 762 assert(child.parentData is ParentDataType); | 770 assert(child.parentData is ParentDataType); |
| 763 canvas.paintChild(child, child.parentData.position); | 771 canvas.paintChild(child, child.parentData.position); |
| 764 child = child.parentData.nextSibling; | 772 child = child.parentData.nextSibling; |
| 765 } | 773 } |
| 766 } | 774 } |
| 767 } | 775 } |
| OLD | NEW |