Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 import 'dart:sky' as sky; | 2 import 'dart:sky' as sky; |
| 3 import 'dart:typed_data'; | |
| 3 | 4 |
| 4 import 'package:sky/framework/rendering/box.dart'; | 5 import 'package:sky/framework/rendering/box.dart'; |
| 5 import 'package:sky/framework/rendering/object.dart'; | 6 import 'package:sky/framework/rendering/object.dart'; |
| 6 | 7 |
| 7 typedef void Logger (String s); | 8 typedef void Logger (String s); |
| 8 | 9 |
| 9 class TestDisplayList extends RenderObjectDisplayList { | 10 class TestPictureRecorder extends sky.PictureRecorder { |
| 10 TestDisplayList(double width, double height, this.logger, { this.indent: '' }) : | 11 TestPictureRecorder(this.logger, { this.indent: '' }) { |
| 11 this.width = width, | 12 log("TestPictureRecorder() constructor"); |
| 12 this.height = height, | 13 } |
| 13 super(width, height) { | 14 final String indent; |
| 14 log("TestDisplayList() constructor: $width x $height"); | 15 Logger logger; |
| 16 | |
| 17 void log(String s) { | |
| 18 logger("${indent} ${s}"); | |
| 19 } | |
| 20 | |
| 21 sky.Canvas beginRecording(double width, double height) { | |
| 22 log("beginRecording($width, $height)"); | |
| 23 | |
| 24 var canvas = super.beginRecording(width, height); | |
| 25 | |
| 26 return new TestCanvas(canvas, width, height, this.logger, indent: this.inden t); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 class TestCanvas implements sky.Canvas { | |
| 31 TestCanvas(this.canvas, this.width, this.height, this.logger, { this.indent: ' ' }) { | |
| 32 log("TestCanvas() constructor: $width x $height"); | |
| 15 } | 33 } |
| 16 | 34 |
| 17 final String indent; | 35 final String indent; |
| 18 final double width; | 36 final double width; |
| 19 final double height; | 37 final double height; |
| 38 sky.Canvas canvas; | |
|
abarth-chromium
2015/06/18 00:03:52
I don't think you need to pass |canvas| to this ob
iansf
2015/06/20 00:02:40
Done. (This file is still in flux, though, so don
| |
| 20 | 39 |
| 21 Logger logger; | 40 Logger logger; |
| 22 void log(String s) { | 41 void log(String s) { |
| 23 logger("${indent} ${s}"); | 42 logger("${indent} ${s}"); |
| 24 } | 43 } |
| 25 | 44 |
| 26 String explainPaint(Paint paint) { | 45 String explainPaint(Paint paint) { |
| 27 assert(paint.toString() == "Instance of 'Paint'"); // if this assertion fail s, remove all calls to explainPaint with just inlining $paint | 46 assert(paint.toString() == "Instance of 'Paint'"); // if this assertion fail s, remove all calls to explainPaint with just inlining $paint |
| 28 return "Paint(${paint.color})"; | 47 return "Paint(${paint.color})"; |
| 29 } | 48 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 49 } | 68 } |
| 50 | 69 |
| 51 void rotate(double radians) { | 70 void rotate(double radians) { |
| 52 log("rotate($radians)"); | 71 log("rotate($radians)"); |
| 53 } | 72 } |
| 54 | 73 |
| 55 void skew(double sx, double sy) { | 74 void skew(double sx, double sy) { |
| 56 log("skew($sx, $sy)"); | 75 log("skew($sx, $sy)"); |
| 57 } | 76 } |
| 58 | 77 |
| 59 void concat(List<double> matrix9) { | 78 void concat(Float32List matrix4) { |
| 60 log("concat($matrix9)"); | 79 log("concat($matrix4)"); |
| 61 } | 80 } |
| 62 | 81 |
| 63 void clipRect(Rect rect) { | 82 void clipRect(Rect rect) { |
| 64 log("clipRect($rect)"); | 83 log("clipRect($rect)"); |
| 65 } | 84 } |
| 66 | 85 |
| 67 void clipRRect(sky.RRect rrect) { | 86 void clipRRect(sky.RRect rrect) { |
| 68 log("clipRRect()"); | 87 log("clipRRect()"); |
| 69 } | 88 } |
| 70 | 89 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 100 log("drawCircle($x, $y, $radius, ${explainPaint(paint)})"); | 119 log("drawCircle($x, $y, $radius, ${explainPaint(paint)})"); |
| 101 } | 120 } |
| 102 | 121 |
| 103 void drawPath(Path path, Paint paint) { | 122 void drawPath(Path path, Paint paint) { |
| 104 log("drawPath($path, ${explainPaint(paint)})"); | 123 log("drawPath($path, ${explainPaint(paint)})"); |
| 105 } | 124 } |
| 106 | 125 |
| 107 void drawImage(sky.Image image, double x, double y, Paint paint) { | 126 void drawImage(sky.Image image, double x, double y, Paint paint) { |
| 108 log("drawImage($image, $x, $y, ${explainPaint(paint)})"); | 127 log("drawImage($image, $x, $y, ${explainPaint(paint)})"); |
| 109 } | 128 } |
| 110 | |
| 111 void paintChild(RenderObject child, Point position) { | |
| 112 log("paintChild ${child.runtimeType} at $position"); | |
| 113 child.paint(new TestDisplayList(width, height, logger, indent: "$indent |") ); | |
| 114 } | |
| 115 } | 129 } |
| 116 | 130 |
| 117 class TestRenderView extends RenderView { | 131 class TestRenderView extends RenderView { |
| 118 | 132 |
| 119 TestRenderView([ RenderBox child = null ]) : super(child: child) { | 133 TestRenderView([ RenderBox child = null ]) : super(child: child) { |
| 120 print("TestRenderView enabled"); | 134 print("TestRenderView enabled"); |
| 121 attach(); | 135 attach(); |
| 122 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures | 136 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures |
| 123 scheduleInitialLayout(); | 137 scheduleInitialLayout(); |
| 124 checkFrame(); | 138 checkFrame(); |
| 125 } | 139 } |
| 126 | 140 |
| 127 int frame = 0; | 141 int frame = 0; |
| 128 | 142 |
| 129 String lastPaint = ''; | 143 String lastPaint = ''; |
| 130 void log(String s) { | 144 void log(String s) { |
| 131 lastPaint += "\n$s"; | 145 lastPaint += "\n$s"; |
| 132 } | 146 } |
| 133 | 147 |
| 134 void paintFrame() { | 148 void paintFrame() { |
| 135 RenderObject.debugDoingPaint = true; | 149 RenderObject.debugDoingPaint = true; |
| 136 frame += 1; | 150 frame += 1; |
| 137 lastPaint = ''; | 151 lastPaint = ''; |
| 138 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); | 152 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); |
| 139 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig ht, log, indent: "${frame} |"); | 153 var recorder = new TestPictureRecorder(log, indent: "${frame} |"); |
| 154 var canvas = recorder.beginRecording(rootConstraints.width, rootConstraints. height); | |
| 140 paint(canvas); | 155 paint(canvas); |
| 156 recorder.endRecording(); | |
| 141 log("----------------------------------------------------------------------- -"); | 157 log("----------------------------------------------------------------------- -"); |
| 142 RenderObject.debugDoingPaint = false; | 158 RenderObject.debugDoingPaint = false; |
| 143 } | 159 } |
| 144 | 160 |
| 145 void checkFrame() { | 161 void checkFrame() { |
| 146 RenderObject.flushLayout(); | 162 RenderObject.flushLayout(); |
| 147 paintFrame(); | 163 paintFrame(); |
| 148 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better | 164 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better |
| 149 } | 165 } |
| 150 | 166 |
| 151 } | 167 } |
| OLD | NEW |