| 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 BD-style license that can be | 4 * Use of this source code is governed by a BD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkParsePath.h" | 9 #include "SkParsePath.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 10
0); | 102 path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 10
0); |
| 103 canvas->drawPath(path, paint); | 103 canvas->drawPath(path, paint); |
| 104 } | 104 } |
| 105 | 105 |
| 106 #include "random_parse_path.h" | 106 #include "random_parse_path.h" |
| 107 #include "SkRandom.h" | 107 #include "SkRandom.h" |
| 108 | 108 |
| 109 /* The test below generates a reference image using SVG. To compare the result f
or correctness, | 109 /* The test below generates a reference image using SVG. To compare the result f
or correctness, |
| 110 enable the define below and then view the generated SVG in a browser. | 110 enable the define below and then view the generated SVG in a browser. |
| 111 */ | 111 */ |
| 112 #define GENERATE_SVG_REFERENCE 0 | 112 #define GENERATE_SVG_REFERENCE 01 |
| 113 | 113 |
| 114 #if GENERATE_SVG_REFERENCE | 114 #if GENERATE_SVG_REFERENCE |
| 115 #include "SkOSFile.h" | 115 #include "SkOSFile.h" |
| 116 #endif | 116 #endif |
| 117 | 117 |
| 118 enum { | 118 enum { |
| 119 kParsePathTestDimension = 500 | 119 kParsePathTestDimension = 500 |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 DEF_SIMPLE_GM(parsedpaths, canvas, kParsePathTestDimension, kParsePathTestDimens
ion) { | 122 DEF_SIMPLE_GM(parsedpaths, canvas, kParsePathTestDimension, kParsePathTestDimens
ion) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 141 sk_fwrite(str.c_str(), str.size(), file); | 141 sk_fwrite(str.c_str(), str.size(), file); |
| 142 str.printf("<rect width='100' height='100' x='0' y='0'></rect>\n"); | 142 str.printf("<rect width='100' height='100' x='0' y='0'></rect>\n"); |
| 143 sk_fwrite(str.c_str(), str.size(), file); | 143 sk_fwrite(str.c_str(), str.size(), file); |
| 144 str.printf("</clipPath>\n"); | 144 str.printf("</clipPath>\n"); |
| 145 sk_fwrite(str.c_str(), str.size(), file); | 145 sk_fwrite(str.c_str(), str.size(), file); |
| 146 #endif | 146 #endif |
| 147 int count = 3; | 147 int count = 3; |
| 148 do { | 148 do { |
| 149 SkPath path; | 149 SkPath path; |
| 150 SkString spec; | 150 SkString spec; |
| 151 spec.printf("M %d,%d\n", rand.nextRangeU(30, 70), rand.nextRange
U(30, 70)); | 151 uint32_t y = rand.nextRangeU(30, 70); |
| 152 uint32_t x = rand.nextRangeU(30, 70); |
| 153 spec.printf("M %d,%d\n", x, y); |
| 152 uint32_t count = rand.nextRangeU(0, 10); | 154 uint32_t count = rand.nextRangeU(0, 10); |
| 153 for (uint32_t i = 0; i < count; ++i) { | 155 for (uint32_t i = 0; i < count; ++i) { |
| 154 spec.append(MakeRandomParsePathPiece(&rand)); | 156 spec.append(MakeRandomParsePathPiece(&rand)); |
| 155 } | 157 } |
| 156 SkAssertResult(SkParsePath::FromSVGString(spec.c_str(), &path)); | 158 SkAssertResult(SkParsePath::FromSVGString(spec.c_str(), &path)); |
| 157 paint.setColor(rand.nextU()); | 159 paint.setColor(rand.nextU()); |
| 158 canvas->save(); | 160 canvas->save(); |
| 159 canvas->clipRect(SkRect::MakeIWH(100, 100)); | 161 canvas->clipRect(SkRect::MakeIWH(100, 100)); |
| 160 canvas->drawPath(path, paint); | 162 canvas->drawPath(path, paint); |
| 161 canvas->restore(); | 163 canvas->restore(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 178 } | 180 } |
| 179 canvas->restore(); | 181 canvas->restore(); |
| 180 canvas->translate(100, 0); | 182 canvas->translate(100, 0); |
| 181 } | 183 } |
| 182 #if GENERATE_SVG_REFERENCE | 184 #if GENERATE_SVG_REFERENCE |
| 183 const char trailer[] = "</svg>\n"; | 185 const char trailer[] = "</svg>\n"; |
| 184 sk_fwrite(trailer, sizeof(trailer) - 1, file); | 186 sk_fwrite(trailer, sizeof(trailer) - 1, file); |
| 185 sk_fclose(file); | 187 sk_fclose(file); |
| 186 #endif | 188 #endif |
| 187 } | 189 } |
| OLD | NEW |