OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBlurMask.h" | 8 #include "SkBlurMask.h" |
9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
10 #include "SkBlurDrawLooper.h" | 10 #include "SkBlurDrawLooper.h" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 SkRRect rr = SkRRect::MakeRectXY(r, 10, 10); | 567 SkRRect rr = SkRRect::MakeRectXY(r, 10, 10); |
568 | 568 |
569 SkPaint p; | 569 SkPaint p; |
570 p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.01f)); | 570 p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.01f)); |
571 | 571 |
572 canvas->drawRRect(rr, p); | 572 canvas->drawRRect(rr, p); |
573 } | 573 } |
574 | 574 |
575 #endif | 575 #endif |
576 | 576 |
| 577 |
| 578 DEF_TEST(BlurredRRectNinePatchComputation, reporter) { |
| 579 const SkRect r = SkRect::MakeXYWH(10, 10, 100, 100); |
| 580 |
| 581 bool ninePatchable; |
| 582 SkRRect rrectToDraw; |
| 583 SkISize size; |
| 584 SkScalar xs[4], ys[4]; |
| 585 int numXs, numYs; |
| 586 |
| 587 // not nine-patchable |
| 588 { |
| 589 SkVector radii[4] = { { 100, 100 }, { 0, 0 }, { 100, 100 }, { 0, 0 } }; |
| 590 |
| 591 SkRRect rr; |
| 592 rr.setRectRadii(r, radii); |
| 593 |
| 594 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r
rectToDraw, &size, |
| 595 xs, &numXs,
ys, &numYs); |
| 596 REPORTER_ASSERT(reporter, !ninePatchable); |
| 597 } |
| 598 |
| 599 // simple circular |
| 600 { |
| 601 SkRRect rr; |
| 602 rr.setRectXY(r, 10, 10); |
| 603 |
| 604 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r
rectToDraw, &size, |
| 605 xs, &numXs,
ys, &numYs); |
| 606 REPORTER_ASSERT(reporter, ninePatchable); |
| 607 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth)
, 57.0f)); |
| 608 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight
), 57.0)); |
| 609 REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs); |
| 610 for (int i = 0; i < numXs; ++i) { |
| 611 REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f); |
| 612 } |
| 613 for (int i = 0; i < numYs; ++i) { |
| 614 REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f); |
| 615 } |
| 616 } |
| 617 |
| 618 // simple elliptical |
| 619 { |
| 620 SkRRect rr; |
| 621 rr.setRectXY(r, 2, 10); |
| 622 |
| 623 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r
rectToDraw, &size, |
| 624 xs, &numXs,
ys, &numYs); |
| 625 REPORTER_ASSERT(reporter, ninePatchable); |
| 626 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth)
, 41.0f)); |
| 627 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight
), 57.0)); |
| 628 REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs); |
| 629 for (int i = 0; i < numXs; ++i) { |
| 630 REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f); |
| 631 } |
| 632 for (int i = 0; i < numYs; ++i) { |
| 633 REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f); |
| 634 } |
| 635 } |
| 636 |
| 637 } |
| 638 |
577 ////////////////////////////////////////////////////////////////////////////////
/////////// | 639 ////////////////////////////////////////////////////////////////////////////////
/////////// |
OLD | NEW |