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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 SkScalar hScale = (bitWidth - 2) / largerWidth; | 283 SkScalar hScale = (bitWidth - 2) / largerWidth; |
284 SkScalar vScale = (bitHeight - 2) / largerHeight; | 284 SkScalar vScale = (bitHeight - 2) / largerHeight; |
285 scale.reset(); | 285 scale.reset(); |
286 scale.preScale(hScale, vScale); | 286 scale.preScale(hScale, vScale); |
287 } | 287 } |
288 | 288 |
289 static int pathsDrawTheSame(SkBitmap& bits, const SkPath& scaledOne, const SkPat
h& scaledTwo, | 289 static int pathsDrawTheSame(SkBitmap& bits, const SkPath& scaledOne, const SkPat
h& scaledTwo, |
290 int& error2x2) { | 290 int& error2x2) { |
291 if (bits.width() == 0) { | 291 if (bits.width() == 0) { |
292 bits.setConfig(SkBitmap::kARGB_8888_Config, bitWidth * 2, bitHeight); | 292 bits.allocN32Pixels(bitWidth * 2, bitHeight); |
293 bits.allocPixels(); | |
294 } | 293 } |
295 SkCanvas canvas(bits); | 294 SkCanvas canvas(bits); |
296 canvas.drawColor(SK_ColorWHITE); | 295 canvas.drawColor(SK_ColorWHITE); |
297 SkPaint paint; | 296 SkPaint paint; |
298 canvas.save(); | 297 canvas.save(); |
299 const SkRect& bounds1 = scaledOne.getBounds(); | 298 const SkRect& bounds1 = scaledOne.getBounds(); |
300 canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1); | 299 canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1); |
301 canvas.drawPath(scaledOne, paint); | 300 canvas.drawPath(scaledOne, paint); |
302 canvas.restore(); | 301 canvas.restore(); |
303 canvas.save(); | 302 canvas.save(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 SkBitmap bits; | 347 SkBitmap bits; |
349 char out[256]; | 348 char out[256]; |
350 int bitWidth = SkScalarCeilToInt(larger.width()) + 2; | 349 int bitWidth = SkScalarCeilToInt(larger.width()) + 2; |
351 if (bitWidth * 2 + 1 >= (int) sizeof(out)) { | 350 if (bitWidth * 2 + 1 >= (int) sizeof(out)) { |
352 return false; | 351 return false; |
353 } | 352 } |
354 int bitHeight = SkScalarCeilToInt(larger.height()) + 2; | 353 int bitHeight = SkScalarCeilToInt(larger.height()) + 2; |
355 if (bitHeight >= (int) sizeof(out)) { | 354 if (bitHeight >= (int) sizeof(out)) { |
356 return false; | 355 return false; |
357 } | 356 } |
358 bits.setConfig(SkBitmap::kARGB_8888_Config, bitWidth * 2, bitHeight); | 357 bits.allocN32Pixels(bitWidth * 2, bitHeight); |
359 bits.allocPixels(); | |
360 SkCanvas canvas(bits); | 358 SkCanvas canvas(bits); |
361 canvas.drawColor(SK_ColorWHITE); | 359 canvas.drawColor(SK_ColorWHITE); |
362 SkPaint paint; | 360 SkPaint paint; |
363 canvas.save(); | 361 canvas.save(); |
364 canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1); | 362 canvas.translate(-bounds1.fLeft + 1, -bounds1.fTop + 1); |
365 canvas.drawPath(one, paint); | 363 canvas.drawPath(one, paint); |
366 canvas.restore(); | 364 canvas.restore(); |
367 canvas.save(); | 365 canvas.save(); |
368 canvas.translate(-bounds1.fLeft + 1 + bitWidth, -bounds1.fTop + 1); | 366 canvas.translate(-bounds1.fLeft + 1 + bitWidth, -bounds1.fTop + 1); |
369 canvas.drawPath(two, paint); | 367 canvas.drawPath(two, paint); |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } | 710 } |
713 if (tests[index].fun == stopTest) { | 711 if (tests[index].fun == stopTest) { |
714 SkDebugf("lastTest\n"); | 712 SkDebugf("lastTest\n"); |
715 } | 713 } |
716 if (index == last) { | 714 if (index == last) { |
717 break; | 715 break; |
718 } | 716 } |
719 index += reverse ? -1 : 1; | 717 index += reverse ? -1 : 1; |
720 } while (true); | 718 } while (true); |
721 } | 719 } |
OLD | NEW |