Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: sky/sdk/lib/framework/rendering/box.dart

Issue 1146893004: Attempt to write a RenderShadowedBox (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Added blur, moved back to src mode Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/examples/raw/shadowed_box.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 void performLayout() { 575 void performLayout() {
576 sky.Size oldSize = size; 576 sky.Size oldSize = size;
577 577
578 super.performLayout(); 578 super.performLayout();
579 579
580 if (oldSize != size) 580 if (oldSize != size)
581 callback(size); 581 callback(size);
582 } 582 }
583 } 583 }
584 584
585 // This must be immutable, because we won't notice when it changes
586 class BoxShadow {
587 const BoxShadow({
588 this.color,
589 this.offset,
590 this.blur
591 });
592
593 final sky.Size offset;
594 final double blur;
595 final sky.Color color;
596 }
597
598 class RenderShadowedBox extends RenderProxyBox {
599
600 RenderShadowedBox({
601 BoxShadow shadow,
602 RenderBox child
603 }) : _shadow = shadow, super(child);
604
605 BoxShadow _shadow;
606 BoxShadow get shadow => _shadow;
607 void set shadow (BoxShadow value) {
608 if (value == _shadow)
609 return;
610 _shadow = value;
611 markNeedsPaint();
612 }
613
614 sky.Paint _createShadowPaint(BoxShadow shadow) {
615 // TODO(eseidel): This should not be hard-coded yellow.
616 sky.Paint paint = new sky.Paint()..color = const sky.Color.fromARGB(255, 0, 255, 0);
617 var builder = new sky.LayerDrawLooperBuilder()
618 // Shadow layer.
619 ..addLayerOnTop(
620 new sky.DrawLooperLayerInfo()
621 ..setPaintBits(-1)
622 ..setOffset(shadow.offset.toPoint())
623 ..setColorMode(sky.TransferMode.srcMode),
624 (sky.Paint layerPaint) {
625 layerPaint.color = shadow.color;
626 layerPaint.setMaskFilter(
627 new sky.MaskFilter.Blur(sky.BlurStyle.normal, shadow.blur, highQuality : true));
628 })
629 // Main layer.
630 ..addLayerOnTop(new sky.DrawLooperLayerInfo(), (_) {});
631 paint.setDrawLooper(builder.build());
632 return paint;
633 }
634
635 void paint(RenderObjectDisplayList canvas) {
636 sky.Paint paint = _createShadowPaint(_shadow);
637 canvas.drawRect(new sky.Rect.fromLTRB(0.0, 0.0, size.width, size.height), pa int);
638 super.paint(canvas);
639 }
640 }
585 641
586 // RENDER VIEW LAYOUT MANAGER 642 // RENDER VIEW LAYOUT MANAGER
587 643
588 class ViewConstraints { 644 class ViewConstraints {
589 645
590 const ViewConstraints({ 646 const ViewConstraints({
591 this.width: 0.0, this.height: 0.0, this.orientation: null 647 this.width: 0.0, this.height: 0.0, this.orientation: null
592 }); 648 });
593 649
594 final double width; 650 final double width;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 739
684 void defaultPaint(RenderObjectDisplayList canvas) { 740 void defaultPaint(RenderObjectDisplayList canvas) {
685 RenderBox child = firstChild; 741 RenderBox child = firstChild;
686 while (child != null) { 742 while (child != null) {
687 assert(child.parentData is ParentDataType); 743 assert(child.parentData is ParentDataType);
688 canvas.paintChild(child, child.parentData.position); 744 canvas.paintChild(child, child.parentData.position);
689 child = child.parentData.nextSibling; 745 child = child.parentData.nextSibling;
690 } 746 }
691 } 747 }
692 } 748 }
OLDNEW
« no previous file with comments | « sky/examples/raw/shadowed_box.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698