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

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

Issue 1206373002: Implement ClipRRect (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: cr feedback 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
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 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';
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 void paint(RenderCanvas canvas) { 549 void paint(RenderCanvas canvas) {
550 if (child != null) { 550 if (child != null) {
551 canvas.save(); 551 canvas.save();
552 canvas.clipRect(new Rect.fromSize(size)); 552 canvas.clipRect(new Rect.fromSize(size));
553 child.paint(canvas); 553 child.paint(canvas);
554 canvas.restore(); 554 canvas.restore();
555 } 555 }
556 } 556 }
557 } 557 }
558 558
559 class RenderClipRRect extends RenderProxyBox {
560 RenderClipRRect({ RenderBox child, double xRadius, double yRadius })
561 : _xRadius = xRadius,_yRadius = yRadius, super(child) {
abarth-chromium 2015/06/25 18:04:12 s/xRadius,_yRadius/xRadius, _yRadius/
562 assert(_xRadius != null);
563 assert(_yRadius != null);
564 }
565
566 double _xRadius;
567 double get xRadius => _xRadius;
568 void set xRadius (double value) {
569 assert(value != null);
570 if (_xRadius == value)
571 return;
572 _xRadius = value;
573 markNeedsPaint();
574 }
575
576 double _yRadius;
577 double get yRadius => _yRadius;
578 void set yRadius (double value) {
579 assert(value != null);
580 if (_yRadius == value)
581 return;
582 _yRadius = value;
583 markNeedsPaint();
584 }
585
586 void paint(RenderCanvas canvas) {
587 if (child != null) {
588 Rect rect = new Rect.fromSize(size);
589 canvas.saveLayer(rect, new Paint());
590 sky.RRect rrect = new sky.RRect()..setRectXY(rect, xRadius, yRadius);
591 canvas.clipRRect(rrect);
592 child.paint(canvas);
593 canvas.restore();
594 }
595 }
596 }
597
559 class RenderClipOval extends RenderProxyBox { 598 class RenderClipOval extends RenderProxyBox {
560 RenderClipOval({ RenderBox child }) : super(child); 599 RenderClipOval({ RenderBox child }) : super(child);
561 600
562 void paint(RenderCanvas canvas) { 601 void paint(RenderCanvas canvas) {
563 if (child != null) { 602 if (child != null) {
564 Rect rect = new Rect.fromSize(size); 603 Rect rect = new Rect.fromSize(size);
565 canvas.saveLayer(rect, new Paint()); 604 canvas.saveLayer(rect, new Paint());
566 Path path = new Path(); 605 Path path = new Path();
567 path.addOval(rect); 606 path.addOval(rect);
568 canvas.clipPath(path); 607 canvas.clipPath(path);
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 1145
1107 void defaultPaint(RenderCanvas canvas) { 1146 void defaultPaint(RenderCanvas canvas) {
1108 RenderBox child = firstChild; 1147 RenderBox child = firstChild;
1109 while (child != null) { 1148 while (child != null) {
1110 assert(child.parentData is ParentDataType); 1149 assert(child.parentData is ParentDataType);
1111 canvas.paintChild(child, child.parentData.position); 1150 canvas.paintChild(child, child.parentData.position);
1112 child = child.parentData.nextSibling; 1151 child = child.parentData.nextSibling;
1113 } 1152 }
1114 } 1153 }
1115 } 1154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698