OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 float alwaysCheck[] = { | 484 float alwaysCheck[] = { |
485 0.0f, -0.0f, 1.0f, -1.0f, SK_ScalarPI, 0.1f, FLT_MIN, FLT_MAX, | 485 0.0f, -0.0f, 1.0f, -1.0f, SK_ScalarPI, 0.1f, FLT_MIN, FLT_MAX, |
486 -FLT_MIN, -FLT_MAX, FLT_MIN / 16.0f, -FLT_MIN / 16.0f, | 486 -FLT_MIN, -FLT_MAX, FLT_MIN / 16.0f, -FLT_MIN / 16.0f, |
487 SK_FloatNaN, SK_FloatInfinity, SK_FloatNegativeInfinity, | 487 SK_FloatNaN, SK_FloatInfinity, SK_FloatNegativeInfinity, |
488 -FLT_MIN / 8388608.0 | 488 -FLT_MIN / 8388608.0 |
489 }; | 489 }; |
490 for (float inputFloat: alwaysCheck) { | 490 for (float inputFloat: alwaysCheck) { |
491 check_pdf_scalar_serialization(reporter, inputFloat); | 491 check_pdf_scalar_serialization(reporter, inputFloat); |
492 } | 492 } |
493 } | 493 } |
| 494 |
| 495 // Test SkPDFUtils:: for accuracy. |
| 496 DEF_TEST(PDFPrimitives_Color, reporter) { |
| 497 char buffer[5]; |
| 498 for (int i = 0; i < 256; ++i) { |
| 499 size_t len = SkPDFUtils::ColorToDecimal(i, buffer); |
| 500 REPORTER_ASSERT(reporter, len == strlen(buffer)); |
| 501 float f; |
| 502 REPORTER_ASSERT(reporter, 1 == sscanf(buffer, "%f", &f)); |
| 503 int roundTrip = (int)(0.5 + f * 255); |
| 504 REPORTER_ASSERT(reporter, roundTrip == i); |
| 505 } |
| 506 } |
OLD | NEW |