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 TestPictureRecorder extends sky.PictureRecorder { |
13 TestDisplayList(double width, double height, this.logger, { this.indent: '' }) : | 14 TestPictureRecorder(this.logger, { this.indent: '' }) { |
14 this.width = width, | 15 log("TestPictureRecorder() constructor"); |
15 this.height = height, | 16 } |
16 super(width, height) { | 17 final String indent; |
17 log("TestDisplayList() constructor: $width x $height"); | 18 Logger logger; |
19 | |
20 void log(String s) { | |
21 logger("${indent} ${s}"); | |
22 } | |
23 | |
24 sky.Canvas beginRecording(double width, double height) { | |
25 log("beginRecording($width, $height)"); | |
26 | |
27 var canvas = super.beginRecording(width, height); | |
28 | |
29 return new TestCanvas(width, height, this.logger, indent: this.indent); | |
abarth-chromium
2015/06/20 00:50:29
This function then becomes:
return new TestCanvas
| |
30 } | |
31 } | |
32 | |
33 class TestCanvas extends sky.Canvas { | |
34 TestCanvas(this.width, this.height, this.logger, { this.indent: '' }) { | |
abarth-chromium
2015/06/20 00:50:29
I'd call |super| here.
| |
35 log("TestCanvas() constructor: $width x $height"); | |
18 } | 36 } |
19 | 37 |
20 final String indent; | 38 final String indent; |
21 final double width; | 39 final double width; |
22 final double height; | 40 final double height; |
23 | 41 |
24 Logger logger; | 42 Logger logger; |
25 void log(String s) { | 43 void log(String s) { |
26 logger("${indent} ${s}"); | 44 logger("${indent} ${s}"); |
27 } | 45 } |
(...skipping 19 matching lines...) Expand all Loading... | |
47 } | 65 } |
48 | 66 |
49 void rotate(double radians) { | 67 void rotate(double radians) { |
50 log("rotate($radians)"); | 68 log("rotate($radians)"); |
51 } | 69 } |
52 | 70 |
53 void skew(double sx, double sy) { | 71 void skew(double sx, double sy) { |
54 log("skew($sx, $sy)"); | 72 log("skew($sx, $sy)"); |
55 } | 73 } |
56 | 74 |
57 void concat(List<double> matrix9) { | 75 void concat(Float32List matrix4) { |
58 log("concat($matrix9)"); | 76 log("concat($matrix4)"); |
59 } | 77 } |
60 | 78 |
61 void clipRect(Rect rect) { | 79 void clipRect(Rect rect) { |
62 log("clipRect($rect)"); | 80 log("clipRect($rect)"); |
63 } | 81 } |
64 | 82 |
65 void clipRRect(sky.RRect rrect) { | 83 void clipRRect(sky.RRect rrect) { |
66 log("clipRRect()"); | 84 log("clipRRect()"); |
67 } | 85 } |
68 | 86 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 void drawPath(Path path, Paint paint) { | 119 void drawPath(Path path, Paint paint) { |
102 log("drawPath($path, $paint)"); | 120 log("drawPath($path, $paint)"); |
103 } | 121 } |
104 | 122 |
105 void drawImage(sky.Image image, double x, double y, Paint paint) { | 123 void drawImage(sky.Image image, double x, double y, Paint paint) { |
106 log("drawImage($image, $x, $y, $paint)"); | 124 log("drawImage($image, $x, $y, $paint)"); |
107 } | 125 } |
108 | 126 |
109 void paintChild(RenderObject child, Point position) { | 127 void paintChild(RenderObject child, Point position) { |
110 log("paintChild ${child.runtimeType} at $position"); | 128 log("paintChild ${child.runtimeType} at $position"); |
111 child.paint(new TestDisplayList(width, height, logger, indent: "$indent |") ); | 129 child.paint(new TestCanvas(width, height, logger, indent: "$indent |")); |
112 } | 130 } |
113 } | 131 } |
114 | 132 |
115 class TestRenderView extends RenderView { | 133 class TestRenderView extends RenderView { |
116 | 134 |
117 TestRenderView([ RenderBox child = null ]) : super(child: child) { | 135 TestRenderView([ RenderBox child = null ]) : super(child: child) { |
118 print("TestRenderView enabled"); | 136 print("TestRenderView enabled"); |
119 attach(); | 137 attach(); |
120 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures | 138 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures |
121 scheduleInitialLayout(); | 139 scheduleInitialLayout(); |
122 syncCheckFrame(); | 140 syncCheckFrame(); |
123 } | 141 } |
124 | 142 |
125 int frame = 0; | 143 int frame = 0; |
126 | 144 |
127 String lastPaint = ''; | 145 String lastPaint = ''; |
128 void log(String s) { | 146 void log(String s) { |
129 lastPaint += "\n$s"; | 147 lastPaint += "\n$s"; |
130 } | 148 } |
131 | 149 |
132 void paintFrame() { | 150 void paintFrame() { |
133 RenderObject.debugDoingPaint = true; | 151 RenderObject.debugDoingPaint = true; |
134 frame += 1; | 152 frame += 1; |
135 lastPaint = ''; | 153 lastPaint = ''; |
136 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); | 154 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); |
137 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig ht, log, indent: "${frame} |"); | 155 var recorder = new TestPictureRecorder(log, indent: "${frame} |"); |
156 var canvas = recorder.beginRecording(rootConstraints.width, rootConstraints. height); | |
138 paint(canvas); | 157 paint(canvas); |
158 recorder.endRecording(); | |
139 log("----------------------------------------------------------------------- -"); | 159 log("----------------------------------------------------------------------- -"); |
140 RenderObject.debugDoingPaint = false; | 160 RenderObject.debugDoingPaint = false; |
141 } | 161 } |
142 | 162 |
143 // TEST API: | 163 // TEST API: |
144 | 164 |
145 void syncCheckFrame() { | 165 void syncCheckFrame() { |
146 RenderObject.flushLayout(); | 166 RenderObject.flushLayout(); |
147 paintFrame(); | 167 paintFrame(); |
148 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better | 168 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 | 193 |
174 Future test(Function builder) { | 194 Future test(Function builder) { |
175 runApp(new TestApp(builder: builder), renderViewOverride: renderView); | 195 runApp(new TestApp(builder: builder), renderViewOverride: renderView); |
176 return renderView.checkFrame(); | 196 return renderView.checkFrame(); |
177 } | 197 } |
178 | 198 |
179 void endTest() { | 199 void endTest() { |
180 renderView.endTest(); | 200 renderView.endTest(); |
181 } | 201 } |
182 } | 202 } |
OLD | NEW |