Chromium Code Reviews| 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 : recorder = recorder, |
| 15 this.height = height, | 16 width = width, |
| 16 super(width, height) { | 17 height = height, |
| 17 log("TestDisplayList() constructor: $width x $height"); | 18 super(recorder, width, height) { |
| 19 log("TestRenderCanvas() constructor: $width x $height"); | |
| 18 } | 20 } |
| 19 | 21 |
| 20 final String indent; | 22 final String indent; |
| 23 final sky.PictureRecorder recorder; | |
|
Hixie
2015/06/23 16:36:48
what's this used for?
iansf
2015/06/23 22:46:09
Acknowledged.
| |
| 21 final double width; | 24 final double width; |
| 22 final double height; | 25 final double height; |
| 23 | 26 |
| 24 Logger logger; | 27 Logger logger; |
| 25 void log(String s) { | 28 void log(String s) { |
| 26 logger("${indent} ${s}"); | 29 logger("${indent} ${s}"); |
| 27 } | 30 } |
| 28 | 31 |
| 29 void save() { | 32 void save() { |
| 30 log("save"); | 33 log("save"); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 47 } | 50 } |
| 48 | 51 |
| 49 void rotate(double radians) { | 52 void rotate(double radians) { |
| 50 log("rotate($radians)"); | 53 log("rotate($radians)"); |
| 51 } | 54 } |
| 52 | 55 |
| 53 void skew(double sx, double sy) { | 56 void skew(double sx, double sy) { |
| 54 log("skew($sx, $sy)"); | 57 log("skew($sx, $sy)"); |
| 55 } | 58 } |
| 56 | 59 |
| 57 void concat(List<double> matrix9) { | 60 void concat(Float32List matrix4) { |
| 58 log("concat($matrix9)"); | 61 log("concat($matrix4)"); |
| 59 } | 62 } |
| 60 | 63 |
| 61 void clipRect(Rect rect) { | 64 void clipRect(Rect rect) { |
| 62 log("clipRect($rect)"); | 65 log("clipRect($rect)"); |
| 63 } | 66 } |
| 64 | 67 |
| 65 void clipRRect(sky.RRect rrect) { | 68 void clipRRect(sky.RRect rrect) { |
| 66 log("clipRRect()"); | 69 log("clipRRect()"); |
| 67 } | 70 } |
| 68 | 71 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 void drawPath(Path path, Paint paint) { | 104 void drawPath(Path path, Paint paint) { |
| 102 log("drawPath($path, $paint)"); | 105 log("drawPath($path, $paint)"); |
| 103 } | 106 } |
| 104 | 107 |
| 105 void drawImage(sky.Image image, double x, double y, Paint paint) { | 108 void drawImage(sky.Image image, double x, double y, Paint paint) { |
| 106 log("drawImage($image, $x, $y, $paint)"); | 109 log("drawImage($image, $x, $y, $paint)"); |
| 107 } | 110 } |
| 108 | 111 |
| 109 void paintChild(RenderObject child, Point position) { | 112 void paintChild(RenderObject child, Point position) { |
| 110 log("paintChild ${child.runtimeType} at $position"); | 113 log("paintChild ${child.runtimeType} at $position"); |
| 111 child.paint(new TestDisplayList(width, height, logger, indent: "$indent |") ); | 114 child.paint(new TestRenderCanvas(recorder, width, height, logger, indent: "$ indent |")); |
| 112 } | 115 } |
| 113 } | 116 } |
| 114 | 117 |
| 115 class TestRenderView extends RenderView { | 118 class TestRenderView extends RenderView { |
| 116 | 119 |
| 117 TestRenderView([ RenderBox child = null ]) : super(child: child) { | 120 TestRenderView([ RenderBox child = null ]) : super(child: child) { |
| 118 print("TestRenderView enabled"); | 121 print("TestRenderView enabled"); |
| 119 attach(); | 122 attach(); |
| 120 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures | 123 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures |
| 121 scheduleInitialLayout(); | 124 scheduleInitialLayout(); |
| 122 syncCheckFrame(); | 125 syncCheckFrame(); |
| 123 } | 126 } |
| 124 | 127 |
| 125 int frame = 0; | 128 int frame = 0; |
| 126 | 129 |
| 127 String lastPaint = ''; | 130 String lastPaint = ''; |
| 128 void log(String s) { | 131 void log(String s) { |
| 129 lastPaint += "\n$s"; | 132 lastPaint += "\n$s"; |
| 130 } | 133 } |
| 131 | 134 |
| 132 void paintFrame() { | 135 void paintFrame() { |
| 133 RenderObject.debugDoingPaint = true; | 136 RenderObject.debugDoingPaint = true; |
| 134 frame += 1; | 137 frame += 1; |
| 135 lastPaint = ''; | 138 lastPaint = ''; |
| 136 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); | 139 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); |
| 137 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig ht, log, indent: "${frame} |"); | 140 var recorder = new sky.PictureRecorder(); |
|
Hixie
2015/06/23 16:36:49
why is the recorder needed here?
iansf
2015/06/23 22:46:09
As discussed, changing this to create a new |sky.P
| |
| 141 var canvas = new TestRenderCanvas(recorder, rootConstraints.width, rootConst raints.height, log, indent: "${frame} |"); | |
| 138 paint(canvas); | 142 paint(canvas); |
| 143 recorder.endRecording(); | |
| 139 log("----------------------------------------------------------------------- -"); | 144 log("----------------------------------------------------------------------- -"); |
| 140 RenderObject.debugDoingPaint = false; | 145 RenderObject.debugDoingPaint = false; |
| 141 } | 146 } |
| 142 | 147 |
| 143 // TEST API: | 148 // TEST API: |
| 144 | 149 |
| 145 void syncCheckFrame() { | 150 void syncCheckFrame() { |
| 146 RenderObject.flushLayout(); | 151 RenderObject.flushLayout(); |
| 147 paintFrame(); | 152 paintFrame(); |
| 148 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better | 153 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 | 178 |
| 174 Future test(Function builder) { | 179 Future test(Function builder) { |
| 175 runApp(new TestApp(builder: builder), renderViewOverride: renderView); | 180 runApp(new TestApp(builder: builder), renderViewOverride: renderView); |
| 176 return renderView.checkFrame(); | 181 return renderView.checkFrame(); |
| 177 } | 182 } |
| 178 | 183 |
| 179 void endTest() { | 184 void endTest() { |
| 180 renderView.endTest(); | 185 renderView.endTest(); |
| 181 } | 186 } |
| 182 } | 187 } |
| OLD | NEW |