OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "PathOpsExtendedTest.h" | 8 #include "PathOpsExtendedTest.h" |
9 #include "PathOpsThreadedCommon.h" | 9 #include "PathOpsThreadedCommon.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 largerWidth = 4; | 175 largerWidth = 4; |
176 } | 176 } |
177 SkScalar largerHeight = larger.height(); | 177 SkScalar largerHeight = larger.height(); |
178 if (largerHeight < 4) { | 178 if (largerHeight < 4) { |
179 largerHeight = 4; | 179 largerHeight = 4; |
180 } | 180 } |
181 SkScalar hScale = (bitWidth - 2) / largerWidth; | 181 SkScalar hScale = (bitWidth - 2) / largerWidth; |
182 SkScalar vScale = (bitHeight - 2) / largerHeight; | 182 SkScalar vScale = (bitHeight - 2) / largerHeight; |
183 scale.reset(); | 183 scale.reset(); |
184 scale.preScale(hScale, vScale); | 184 scale.preScale(hScale, vScale); |
| 185 larger.fLeft *= hScale; |
| 186 larger.fRight *= hScale; |
| 187 larger.fTop *= vScale; |
| 188 larger.fBottom *= vScale; |
| 189 SkScalar dx = -16000 > larger.fLeft ? -16000 - larger.fLeft |
| 190 : 16000 < larger.fRight ? 16000 - larger.fRight : 0; |
| 191 SkScalar dy = -16000 > larger.fTop ? -16000 - larger.fTop |
| 192 : 16000 < larger.fBottom ? 16000 - larger.fBottom : 0; |
| 193 scale.postTranslate(dx, dy); |
185 } | 194 } |
186 | 195 |
187 static int pathsDrawTheSame(SkBitmap& bits, const SkPath& scaledOne, const SkPat
h& scaledTwo, | 196 static int pathsDrawTheSame(SkBitmap& bits, const SkPath& scaledOne, const SkPat
h& scaledTwo, |
188 int& error2x2) { | 197 int& error2x2) { |
189 if (bits.width() == 0) { | 198 if (bits.width() == 0) { |
190 bits.allocN32Pixels(bitWidth * 2, bitHeight); | 199 bits.allocN32Pixels(bitWidth * 2, bitHeight); |
191 } | 200 } |
192 SkCanvas canvas(bits); | 201 SkCanvas canvas(bits); |
193 canvas.drawColor(SK_ColorWHITE); | 202 canvas.drawColor(SK_ColorWHITE); |
194 SkPaint paint; | 203 SkPaint paint; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 312 } |
304 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", | 313 SkDebugf("static void %s%d%s(skiatest::Reporter* reporter, const char* filen
ame) {\n", |
305 testName, gTestNo, opSuffixes[shapeOp]); | 314 testName, gTestNo, opSuffixes[shapeOp]); |
306 *gTestOp.append() = shapeOp; | 315 *gTestOp.append() = shapeOp; |
307 ++gTestNo; | 316 ++gTestNo; |
308 SkDebugf(" SkPath path, pathB;\n"); | 317 SkDebugf(" SkPath path, pathB;\n"); |
309 SkPathOpsDebug::ShowOnePath(a, "path", false); | 318 SkPathOpsDebug::ShowOnePath(a, "path", false); |
310 SkPathOpsDebug::ShowOnePath(b, "pathB", false); | 319 SkPathOpsDebug::ShowOnePath(b, "pathB", false); |
311 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); | 320 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh
apeOp]); |
312 SkDebugf("}\n"); | 321 SkDebugf("}\n"); |
313 drawAsciiPaths(scaledOne, scaledTwo, false); | 322 drawAsciiPaths(scaledOne, scaledTwo, true); |
314 } | 323 } |
315 | 324 |
316 void ShowTestArray(const char* testName) { | 325 void ShowTestArray(const char* testName) { |
317 if (!testName) { | 326 if (!testName) { |
318 testName = "xOp"; | 327 testName = "xOp"; |
319 } | 328 } |
320 for (int x = gTestFirst; x < gTestNo; ++x) { | 329 for (int x = gTestFirst; x < gTestNo; ++x) { |
321 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); | 330 SkDebugf(" TEST(%s%d%s),\n", testName, x, opSuffixes[gTestOp[x - gTes
tFirst]]); |
322 } | 331 } |
323 } | 332 } |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 if (foundSkip && tests[index].fun != firstTest) { | 681 if (foundSkip && tests[index].fun != firstTest) { |
673 SkDebugf(" %s,\n", tests[index].str); | 682 SkDebugf(" %s,\n", tests[index].str); |
674 } | 683 } |
675 if (tests[index].fun == stopTest || index == last) { | 684 if (tests[index].fun == stopTest || index == last) { |
676 break; | 685 break; |
677 } | 686 } |
678 index += reverse ? -1 : 1; | 687 index += reverse ? -1 : 1; |
679 } while (true); | 688 } while (true); |
680 #endif | 689 #endif |
681 } | 690 } |
OLD | NEW |