Chromium Code Reviews| 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 'node.dart'; | 8 import 'node.dart'; |
| 9 import 'package:vector_math/vector_math.dart'; | 9 import 'package:vector_math/vector_math.dart'; |
| 10 | 10 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 canvas.concat([ | 353 canvas.concat([ |
| 354 storage[ 0], storage[ 1], storage[ 3], | 354 storage[ 0], storage[ 1], storage[ 3], |
| 355 storage[ 4], storage[ 5], storage[ 7], | 355 storage[ 4], storage[ 5], storage[ 7], |
| 356 storage[12], storage[13], storage[15], | 356 storage[12], storage[13], storage[15], |
| 357 ]); | 357 ]); |
| 358 super.paint(canvas); | 358 super.paint(canvas); |
| 359 canvas.restore(); | 359 canvas.restore(); |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 // This must be immutable, because we won't notice when it changes | |
| 364 class BoxShadow { | |
| 365 const BoxShadow({ | |
| 366 this.color, | |
| 367 this.offset | |
| 368 }); | |
| 369 | |
| 370 final sky.Size offset; | |
| 371 final sky.Color color; | |
| 372 } | |
| 373 | |
| 374 class RenderShadowedBox extends RenderProxyBox { | |
| 375 | |
| 376 RenderShadowedBox({ | |
| 377 BoxShadow shadow, | |
| 378 RenderBox child | |
| 379 }) : _shadow = shadow, super(child); | |
| 380 | |
| 381 BoxShadow _shadow; | |
| 382 BoxShadow get shadow => _shadow; | |
| 383 void set shadow (BoxShadow value) { | |
| 384 if (value == _shadow) | |
| 385 return; | |
| 386 _shadow = value; | |
| 387 markNeedsPaint(); | |
| 388 } | |
| 389 | |
| 390 sky.Paint _createShadowPaint(BoxShadow shadow) { | |
| 391 // Make the main layer transparent for now. | |
| 392 sky.Paint paint = new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0); | |
| 393 var builder = new sky.LayerDrawLooperBuilder() | |
| 394 // Shadow layer. | |
| 395 ..addLayerOnTop( | |
| 396 new sky.DrawLooperLayerInfo() | |
| 397 ..setPaintBits(-1) | |
| 398 ..setOffset(shadow.offset.toPoint()) | |
| 399 ..setColorMode(sky.TransferMode.srcInMode), | |
|
Matt Perry
2015/06/03 19:13:59
Did you mean to revert to srcInMode here?
| |
| 400 (sky.Paint layerPaint) { | |
| 401 layerPaint.color = shadow.color; | |
| 402 // TODO(mpcomplete): blur should respect the offset? | |
|
Matt Perry
2015/06/03 19:13:58
Are you saying it doesn't, or that it does but you
| |
| 403 layerPaint.setMaskFilter( | |
| 404 new sky.MaskFilter.Blur(sky.BlurStyle.normal, 5.0, highQuality: true)) ; | |
| 405 }) | |
| 406 // Main layer. | |
| 407 ..addLayerOnTop(new sky.DrawLooperLayerInfo(), (_) {}); | |
| 408 paint.setDrawLooper(builder.build()); | |
| 409 return paint; | |
| 410 } | |
| 411 | |
| 412 void paint(RenderNodeDisplayList canvas) { | |
| 413 sky.Paint paint = _createShadowPaint(_shadow); | |
| 414 canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, size.width, size.height), pa int); | |
| 415 super.paint(canvas); | |
| 416 } | |
| 417 } | |
| 363 | 418 |
| 364 // RENDER VIEW LAYOUT MANAGER | 419 // RENDER VIEW LAYOUT MANAGER |
| 365 | 420 |
| 366 class ViewConstraints { | 421 class ViewConstraints { |
| 367 | 422 |
| 368 const ViewConstraints({ | 423 const ViewConstraints({ |
| 369 this.width: 0.0, this.height: 0.0, this.orientation: null | 424 this.width: 0.0, this.height: 0.0, this.orientation: null |
| 370 }); | 425 }); |
| 371 | 426 |
| 372 final double width; | 427 final double width; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 | 516 |
| 462 void defaultPaint(RenderNodeDisplayList canvas) { | 517 void defaultPaint(RenderNodeDisplayList canvas) { |
| 463 RenderBox child = firstChild; | 518 RenderBox child = firstChild; |
| 464 while (child != null) { | 519 while (child != null) { |
| 465 assert(child.parentData is ParentDataType); | 520 assert(child.parentData is ParentDataType); |
| 466 canvas.paintChild(child, child.parentData.position); | 521 canvas.paintChild(child, child.parentData.position); |
| 467 child = child.parentData.nextSibling; | 522 child = child.parentData.nextSibling; |
| 468 } | 523 } |
| 469 } | 524 } |
| 470 } | 525 } |
| OLD | NEW |