ScaleToSidesTest.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2016 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "src/core/SkScaleToSides.h"
  8. #include "tests/Test.h"
  9. #include <algorithm>
  10. DEF_TEST(ScaleToSides, reporter) {
  11. double interestingValues[] = {
  12. // From sample app - PathFuzzer
  13. 260.01662826538085938,
  14. 63.61007690429687500,
  15. 795.98901367187500000,
  16. 217.71697616577148438,
  17. 686.15960693359375000,
  18. 556.57641601562500000,
  19. // From skp bitbucket
  20. 111.60000228881836,
  21. 55.800003051757813,
  22. 0.99999996581812677920,
  23. 0.0,
  24. 0.5,
  25. 1.0,
  26. 2.0,
  27. 3.0,
  28. 33.0,
  29. 33554430.0,
  30. 33554431.0,
  31. 33554464.0,
  32. 333333332.0,
  33. 333333333.0,
  34. 333333334.0,
  35. FLT_MAX,
  36. FLT_EPSILON,
  37. FLT_MIN
  38. };
  39. int numInterestingValues = (int)SK_ARRAY_COUNT(interestingValues);
  40. for (int s = 0; s <= numInterestingValues; s++) {
  41. for (int i = 0; i < numInterestingValues; i++) {
  42. for (int j = 0; j < numInterestingValues; j++) {
  43. for (int k = 0; k < numInterestingValues; k++) {
  44. float radius1 = (float)interestingValues[i];
  45. float radius2 = (float)interestingValues[j];
  46. double width = interestingValues[k];
  47. double scale = sk_ieee_double_divide(width, (double)radius1 + (double)radius2);
  48. if (width > 0.0) {
  49. if (s != 0) {
  50. scale = std::min(scale, interestingValues[s-1]);
  51. }
  52. if (scale < 1.0 && scale > 0.0) {
  53. SkScaleToSides::AdjustRadii(width, scale, &radius1, &radius2);
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }