1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5part of engine; 6 7class SkRecordingCanvas implements RecordingCanvas { 8 final js.JsObject skCanvas; 9 SkRecordingCanvas(this.skCanvas); 10 11 js.JsObject _makeSkRect(ui.Rect rect) { 12 return js.JsObject(canvasKit['LTRBRect'], 13 <double>[rect.left, rect.top, rect.right, rect.bottom]); 14 } 15 16 js.JsObject _makeSkPaint(ui.Paint paint) { 17 final skPaint = js.JsObject(canvasKit['SkPaint']); 18 19 skPaint.callMethod('setColor', <int>[paint.color.value]); 20 21 js.JsObject skPaintStyle; 22 switch (paint.style) { 23 case ui.PaintingStyle.stroke: 24 skPaintStyle = canvasKit['PaintStyle']['Stroke']; 25 break; 26 case ui.PaintingStyle.fill: 27 skPaintStyle = canvasKit['PaintStyle']['Fill']; 28 break; 29 } 30 skPaint.callMethod('setStyle', <js.JsObject>[skPaintStyle]); 31 32 skPaint.callMethod('setAntiAlias', <bool>[paint.isAntiAlias]); 33 return skPaint; 34 } 35 36 @override 37 bool _didDraw = true; 38 39 @override 40 bool _hasArbitraryPaint = true; 41 42 @override 43 int saveCount; 44 45 @override 46 // TODO: implement _commands 47 List<PaintCommand> get _commands => null; 48 49 @override 50 // TODO: implement _paintBounds 51 _PaintBounds get _paintBounds => null; 52 53 @override 54 void apply(EngineCanvas engineCanvas) { 55 throw 'apply'; 56 } 57 58 @override 59 void clipPath(ui.Path path) { 60 throw 'clipPath'; 61 } 62 63 @override 64 void clipRRect(ui.RRect rrect) { 65 throw 'clipRRect'; 66 } 67 68 @override 69 void clipRect(ui.Rect rect) { 70 throw 'clipRect'; 71 } 72 73 @override 74 ui.Rect computePaintBounds() { 75 throw 'computePaintBounds'; 76 } 77 78 @override 79 void debugDumpCommands() { 80 throw 'debugDumpCommands'; 81 } 82 83 @override 84 void debugEnforceArbitraryPaint() { 85 throw 'debugEnforceArbitraryPaint'; 86 } 87 88 @override 89 String debugPrintCommands() { 90 throw 'debugPrintCommands'; 91 } 92 93 @override 94 bool get didDraw => true; 95 96 @override 97 void drawCircle(ui.Offset c, double radius, ui.Paint paint) { 98 throw 'drawCircle'; 99 } 100 101 @override 102 void drawColor(ui.Color color, ui.BlendMode blendMode) { 103 throw 'drawColor'; 104 } 105 106 @override 107 void drawDRRect(ui.RRect outer, ui.RRect inner, ui.Paint paint) { 108 throw 'drawDRRect'; 109 } 110 111 @override 112 void drawImage(ui.Image image, ui.Offset offset, ui.Paint paint) { 113 throw 'drawImage'; 114 } 115 116 @override 117 void drawImageRect(ui.Image image, ui.Rect src, ui.Rect dst, ui.Paint paint) { 118 throw 'drawImageRect'; 119 } 120 121 @override 122 void drawLine(ui.Offset p1, ui.Offset p2, ui.Paint paint) { 123 throw 'drawLine'; 124 } 125 126 @override 127 void drawOval(ui.Rect rect, ui.Paint paint) { 128 throw 'drawOval'; 129 } 130 131 @override 132 void drawPaint(ui.Paint paint) { 133 throw 'drawPaint'; 134 } 135 136 @override 137 void drawParagraph(ui.Paragraph paragraph, ui.Offset offset) { 138 throw 'drawParagraph'; 139 } 140 141 @override 142 void drawPath(ui.Path path, ui.Paint paint) { 143 throw 'drawPath'; 144 } 145 146 @override 147 void drawRRect(ui.RRect rrect, ui.Paint paint) { 148 throw 'drawRRect'; 149 } 150 151 @override 152 void drawRect(ui.Rect rect, ui.Paint paint) { 153 final js.JsObject skRect = _makeSkRect(rect); 154 final js.JsObject skPaint = _makeSkPaint(paint); 155 skCanvas.callMethod('drawRect', <js.JsObject>[skRect, skPaint]); 156 } 157 158 @override 159 void drawShadow(ui.Path path, ui.Color color, double elevation, 160 bool transparentOccluder) { 161 throw 'drawShadow'; 162 } 163 164 @override 165 bool get hasArbitraryPaint => true; 166 167 @override 168 void restore() { 169 throw 'restore'; 170 } 171 172 @override 173 void rotate(double radians) { 174 throw 'rotate'; 175 } 176 177 @override 178 void save() { 179 throw 'save'; 180 } 181 182 @override 183 void saveLayer(ui.Rect bounds, ui.Paint paint) { 184 throw 'saveLayer'; 185 } 186 187 @override 188 void saveLayerWithoutBounds(ui.Paint paint) { 189 throw 'saveLayerWithoutBounds'; 190 } 191 192 @override 193 void scale(double sx, double sy) { 194 throw 'scale'; 195 } 196 197 @override 198 void skew(double sx, double sy) { 199 throw 'skew'; 200 } 201 202 @override 203 void transform(Float64List matrix4) { 204 throw 'transform'; 205 } 206 207 @override 208 void translate(double dx, double dy) { 209 throw 'translate'; 210 } 211} 212