OLD | NEW |
1 | 1 |
2 import 'dart:async'; | 2 import 'dart:async'; |
3 import 'dart:sky' as sky; | 3 import 'dart:sky' as sky; |
4 import "dart:sky.internals" as internals; | 4 import "dart:sky.internals" as internals; |
| 5 import 'dart:typed_data'; |
5 | 6 |
6 import 'package:sky/widgets/basic.dart'; | 7 import 'package:sky/widgets/basic.dart'; |
7 import 'package:sky/rendering/box.dart'; | 8 import 'package:sky/rendering/box.dart'; |
8 import 'package:sky/rendering/object.dart'; | 9 import 'package:sky/rendering/object.dart'; |
9 | 10 |
10 typedef void Logger (String s); | 11 typedef void Logger (String s); |
11 | 12 |
12 class TestDisplayList extends RenderObjectDisplayList { | 13 class TestRenderCanvas extends RenderCanvas { |
13 TestDisplayList(double width, double height, this.logger, { this.indent: '' })
: | 14 TestRenderCanvas(sky.PictureRecorder recorder, double width, double height, th
is.logger, { this.indent: '' }) |
14 this.width = width, | 15 : width = width, |
15 this.height = height, | 16 height = height, |
16 super(width, height) { | 17 super(recorder, width, height) { |
17 log("TestDisplayList() constructor: $width x $height"); | 18 log("TestRenderCanvas() constructor: $width x $height"); |
18 } | 19 } |
19 | 20 |
20 final String indent; | 21 final String indent; |
21 final double width; | 22 final double width; |
22 final double height; | 23 final double height; |
23 | 24 |
24 Logger logger; | 25 Logger logger; |
25 void log(String s) { | 26 void log(String s) { |
26 logger("${indent} ${s}"); | 27 logger("${indent} ${s}"); |
27 } | 28 } |
(...skipping 19 matching lines...) Expand all Loading... |
47 } | 48 } |
48 | 49 |
49 void rotate(double radians) { | 50 void rotate(double radians) { |
50 log("rotate($radians)"); | 51 log("rotate($radians)"); |
51 } | 52 } |
52 | 53 |
53 void skew(double sx, double sy) { | 54 void skew(double sx, double sy) { |
54 log("skew($sx, $sy)"); | 55 log("skew($sx, $sy)"); |
55 } | 56 } |
56 | 57 |
57 void concat(List<double> matrix9) { | 58 void concat(Float32List matrix4) { |
58 log("concat($matrix9)"); | 59 log("concat($matrix4)"); |
59 } | 60 } |
60 | 61 |
61 void clipRect(Rect rect) { | 62 void clipRect(Rect rect) { |
62 log("clipRect($rect)"); | 63 log("clipRect($rect)"); |
63 } | 64 } |
64 | 65 |
65 void clipRRect(sky.RRect rrect) { | 66 void clipRRect(sky.RRect rrect) { |
66 log("clipRRect()"); | 67 log("clipRRect()"); |
67 } | 68 } |
68 | 69 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void drawPath(Path path, Paint paint) { | 102 void drawPath(Path path, Paint paint) { |
102 log("drawPath($path, $paint)"); | 103 log("drawPath($path, $paint)"); |
103 } | 104 } |
104 | 105 |
105 void drawImage(sky.Image image, double x, double y, Paint paint) { | 106 void drawImage(sky.Image image, double x, double y, Paint paint) { |
106 log("drawImage($image, $x, $y, $paint)"); | 107 log("drawImage($image, $x, $y, $paint)"); |
107 } | 108 } |
108 | 109 |
109 void paintChild(RenderObject child, Point position) { | 110 void paintChild(RenderObject child, Point position) { |
110 log("paintChild ${child.runtimeType} at $position"); | 111 log("paintChild ${child.runtimeType} at $position"); |
111 child.paint(new TestDisplayList(width, height, logger, indent: "$indent |")
); | 112 child.paint(new TestRenderCanvas(new sky.PictureRecorder(), width, height, l
ogger, indent: "$indent |")); |
112 } | 113 } |
113 } | 114 } |
114 | 115 |
115 class TestRenderView extends RenderView { | 116 class TestRenderView extends RenderView { |
116 | 117 |
117 TestRenderView([ RenderBox child = null ]) : super(child: child) { | 118 TestRenderView([ RenderBox child = null ]) : super(child: child) { |
118 print("TestRenderView enabled"); | 119 print("TestRenderView enabled"); |
119 attach(); | 120 attach(); |
120 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit
rary figures | 121 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit
rary figures |
121 scheduleInitialLayout(); | 122 scheduleInitialLayout(); |
122 syncCheckFrame(); | 123 syncCheckFrame(); |
123 } | 124 } |
124 | 125 |
125 int frame = 0; | 126 int frame = 0; |
126 | 127 |
127 String lastPaint = ''; | 128 String lastPaint = ''; |
128 void log(String s) { | 129 void log(String s) { |
129 lastPaint += "\n$s"; | 130 lastPaint += "\n$s"; |
130 } | 131 } |
131 | 132 |
132 void paintFrame() { | 133 void paintFrame() { |
133 RenderObject.debugDoingPaint = true; | 134 RenderObject.debugDoingPaint = true; |
134 frame += 1; | 135 frame += 1; |
135 lastPaint = ''; | 136 lastPaint = ''; |
136 log("PAINT FOR FRAME #${frame} ---------------------------------------------
-"); | 137 log("PAINT FOR FRAME #${frame} ---------------------------------------------
-"); |
137 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig
ht, log, indent: "${frame} |"); | 138 var recorder = new sky.PictureRecorder(); |
| 139 var canvas = new TestRenderCanvas(recorder, rootConstraints.width, rootConst
raints.height, log, indent: "${frame} |"); |
138 paint(canvas); | 140 paint(canvas); |
| 141 recorder.endRecording(); |
139 log("-----------------------------------------------------------------------
-"); | 142 log("-----------------------------------------------------------------------
-"); |
140 RenderObject.debugDoingPaint = false; | 143 RenderObject.debugDoingPaint = false; |
141 } | 144 } |
142 | 145 |
143 // TEST API: | 146 // TEST API: |
144 | 147 |
145 void syncCheckFrame() { | 148 void syncCheckFrame() { |
146 RenderObject.flushLayout(); | 149 RenderObject.flushLayout(); |
147 paintFrame(); | 150 paintFrame(); |
148 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te
sting framework better | 151 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te
sting framework better |
(...skipping 24 matching lines...) Expand all Loading... |
173 | 176 |
174 Future test(Function builder) { | 177 Future test(Function builder) { |
175 runApp(new TestApp(builder: builder), renderViewOverride: renderView); | 178 runApp(new TestApp(builder: builder), renderViewOverride: renderView); |
176 return renderView.checkFrame(); | 179 return renderView.checkFrame(); |
177 } | 180 } |
178 | 181 |
179 void endTest() { | 182 void endTest() { |
180 renderView.endTest(); | 183 renderView.endTest(); |
181 } | 184 } |
182 } | 185 } |
OLD | NEW |