| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkJSONCanvas_DEFINED | 8 #ifndef SkJSONCanvas_DEFINED |
| 9 #define SkJSONCanvas_DEFINED | 9 #define SkJSONCanvas_DEFINED |
| 10 | 10 |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkStream.h" | 12 #include "SkStream.h" |
| 13 #include "SkJSONCPP.h" |
| 13 | 14 |
| 14 #define SKJSONCANVAS_VERSION "version" | 15 #define SKJSONCANVAS_VERSION "version" |
| 15 #define SKJSONCANVAS_COMMANDS "commands" | 16 #define SKJSONCANVAS_COMMANDS "commands" |
| 16 #define SKJSONCANVAS_COMMAND "command" | 17 #define SKJSONCANVAS_COMMAND "command" |
| 17 | 18 |
| 18 #define SKJSONCANVAS_COMMAND_MATRIX "Matrix" | 19 #define SKJSONCANVAS_COMMAND_MATRIX "Matrix" |
| 19 #define SKJSONCANVAS_COMMAND_PAINT "Paint" | 20 #define SKJSONCANVAS_COMMAND_PAINT "Paint" |
| 20 #define SKJSONCANVAS_COMMAND_RECT "Rect" | 21 #define SKJSONCANVAS_COMMAND_RECT "Rect" |
| 21 #define SKJSONCANVAS_COMMAND_OVAL "Oval" | 22 #define SKJSONCANVAS_COMMAND_OVAL "Oval" |
| 22 #define SKJSONCANVAS_COMMAND_RRECT "RRect" | 23 #define SKJSONCANVAS_COMMAND_RRECT "RRect" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 #define SKJSONCANVAS_ATTRIBUTE_OUTER "outer" | 52 #define SKJSONCANVAS_ATTRIBUTE_OUTER "outer" |
| 52 #define SKJSONCANVAS_ATTRIBUTE_INNER "inner" | 53 #define SKJSONCANVAS_ATTRIBUTE_INNER "inner" |
| 53 #define SKJSONCANVAS_ATTRIBUTE_MODE "mode" | 54 #define SKJSONCANVAS_ATTRIBUTE_MODE "mode" |
| 54 #define SKJSONCANVAS_ATTRIBUTE_POINTS "points" | 55 #define SKJSONCANVAS_ATTRIBUTE_POINTS "points" |
| 55 #define SKJSONCANVAS_ATTRIBUTE_PATH "path" | 56 #define SKJSONCANVAS_ATTRIBUTE_PATH "path" |
| 56 #define SKJSONCANVAS_ATTRIBUTE_TEXT "text" | 57 #define SKJSONCANVAS_ATTRIBUTE_TEXT "text" |
| 57 #define SKJSONCANVAS_ATTRIBUTE_COLOR "color" | 58 #define SKJSONCANVAS_ATTRIBUTE_COLOR "color" |
| 58 #define SKJSONCANVAS_ATTRIBUTE_STYLE "style" | 59 #define SKJSONCANVAS_ATTRIBUTE_STYLE "style" |
| 59 #define SKJSONCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth" | 60 #define SKJSONCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth" |
| 60 #define SKJSONCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias" | 61 #define SKJSONCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias" |
| 62 #define SKJSONCANVAS_ATTRIBUTE_REGION "region" |
| 61 #define SKJSONCANVAS_ATTRIBUTE_REGIONOP "op" | 63 #define SKJSONCANVAS_ATTRIBUTE_REGIONOP "op" |
| 62 #define SKJSONCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle" | 64 #define SKJSONCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle" |
| 63 #define SKJSONCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion" | 65 #define SKJSONCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion" |
| 64 | 66 |
| 65 #define SKJSONCANVAS_VERB_MOVE "move" | 67 #define SKJSONCANVAS_VERB_MOVE "move" |
| 66 #define SKJSONCANVAS_VERB_LINE "line" | 68 #define SKJSONCANVAS_VERB_LINE "line" |
| 67 #define SKJSONCANVAS_VERB_QUAD "quad" | 69 #define SKJSONCANVAS_VERB_QUAD "quad" |
| 68 #define SKJSONCANVAS_VERB_CUBIC "cubic" | 70 #define SKJSONCANVAS_VERB_CUBIC "cubic" |
| 69 #define SKJSONCANVAS_VERB_CONIC "conic" | 71 #define SKJSONCANVAS_VERB_CONIC "conic" |
| 70 #define SKJSONCANVAS_VERB_CLOSE "close" | 72 #define SKJSONCANVAS_VERB_CLOSE "close" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 170 |
| 169 void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle
) override; | 171 void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle
) override; |
| 170 | 172 |
| 171 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) override; | 173 void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) override; |
| 172 | 174 |
| 173 void willSave() override; | 175 void willSave() override; |
| 174 | 176 |
| 175 void willRestore() override; | 177 void willRestore() override; |
| 176 | 178 |
| 177 private: | 179 private: |
| 178 void writef(const char* fmt, ...); | 180 Json::Value makePoint(const SkPoint& point); |
| 179 | 181 |
| 180 void open(const char* name); | 182 Json::Value makePoint(SkScalar x, SkScalar y); |
| 181 | 183 |
| 182 void close(); | 184 Json::Value makeRect(const SkRect& rect); |
| 183 | 185 |
| 184 void writeString(const char* name, const char* text); | 186 Json::Value makeRRect(const SkRRect& rrect); |
| 185 | 187 |
| 186 void writeString(const char* name, const void* text, size_t length); | 188 Json::Value makePath(const SkPath& path); |
| 187 | 189 |
| 188 void writePoint(const char* name, const SkPoint& point); | 190 Json::Value makeRegion(const SkRegion& region); |
| 189 | |
| 190 void writeRect(const char* name, const SkRect& rect); | |
| 191 | |
| 192 void writeRRect(const char* name, const SkRRect& rrect); | |
| 193 | |
| 194 void writePath(const char* name, const SkPath& path); | |
| 195 | |
| 196 void writeRegion(const char* name, const SkRegion& region); | |
| 197 | 191 |
| 198 void writePaint(const SkPaint& paint); | 192 Json::Value makePaint(const SkPaint& paint); |
| 199 | 193 |
| 200 void writeRegionOp(const char* name, SkRegion::Op op); | 194 Json::Value makeRegionOp(SkRegion::Op op); |
| 201 | 195 |
| 202 void writeEdgeStyle(const char* name, SkCanvas::ClipEdgeStyle edgeStyle); | 196 Json::Value makeEdgeStyle(SkCanvas::ClipEdgeStyle edgeStyle); |
| 203 | 197 |
| 204 void writePointMode(const char* name, SkCanvas::PointMode mode); | 198 Json::Value makePointMode(SkCanvas::PointMode mode); |
| 205 | 199 |
| 206 void writeMatrix(const char* name, const SkMatrix& matrix); | 200 Json::Value makeMatrix(const SkMatrix& matrix); |
| 207 | 201 |
| 208 void updateMatrix(); | 202 void updateMatrix(); |
| 209 | 203 |
| 210 SkWStream& fOut; | 204 SkWStream& fOut; |
| 211 SkMatrix fLastMatrix; | 205 SkMatrix fLastMatrix; |
| 212 bool fFirstCommand; | 206 Json::Value fRoot; |
| 207 Json::Value fCommands; |
| 213 | 208 |
| 214 typedef SkCanvas INHERITED; | 209 typedef SkCanvas INHERITED; |
| 215 }; | 210 }; |
| 216 | 211 |
| 217 #endif | 212 #endif |
| OLD | NEW |