| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrReducedClip.h" | 10 #include "GrReducedClip.h" |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 | 813 |
| 814 // We want to test inverse fills. However, they are quite rare in practice s
o don't over do it. | 814 // We want to test inverse fills. However, they are quite rare in practice s
o don't over do it. |
| 815 static const SkScalar kFractionInverted = SK_Scalar1 / kMaxElemsPerTest; | 815 static const SkScalar kFractionInverted = SK_Scalar1 / kMaxElemsPerTest; |
| 816 | 816 |
| 817 static const AddElementFunc kElementFuncs[] = { | 817 static const AddElementFunc kElementFuncs[] = { |
| 818 add_rect, | 818 add_rect, |
| 819 add_round_rect, | 819 add_round_rect, |
| 820 add_oval, | 820 add_oval, |
| 821 }; | 821 }; |
| 822 | 822 |
| 823 SkRandom r; | 823 SkMWCRandom r; |
| 824 | 824 |
| 825 for (int i = 0; i < kNumTests; ++i) { | 825 for (int i = 0; i < kNumTests; ++i) { |
| 826 // Randomly generate a clip stack. | 826 // Randomly generate a clip stack. |
| 827 SkClipStack stack; | 827 SkClipStack stack; |
| 828 int numElems = r.nextRangeU(kMinElemsPerTest, kMaxElemsPerTest); | 828 int numElems = r.nextRangeU(kMinElemsPerTest, kMaxElemsPerTest); |
| 829 for (int e = 0; e < numElems; ++e) { | 829 for (int e = 0; e < numElems; ++e) { |
| 830 SkRegion::Op op = kOps[r.nextULessThan(SK_ARRAY_COUNT(kOps))]; | 830 SkRegion::Op op = kOps[r.nextULessThan(SK_ARRAY_COUNT(kOps))]; |
| 831 if (op == SkRegion::kReplace_Op) { | 831 if (op == SkRegion::kReplace_Op) { |
| 832 if (r.nextU() % kReplaceDiv) { | 832 if (r.nextU() % kReplaceDiv) { |
| 833 --e; | 833 --e; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 857 SkRect inflatedBounds = kBounds; | 857 SkRect inflatedBounds = kBounds; |
| 858 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); | 858 inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); |
| 859 SkIRect inflatedIBounds; | 859 SkIRect inflatedIBounds; |
| 860 inflatedBounds.roundOut(&inflatedIBounds); | 860 inflatedBounds.roundOut(&inflatedIBounds); |
| 861 | 861 |
| 862 typedef GrReducedClip::ElementList ElementList; | 862 typedef GrReducedClip::ElementList ElementList; |
| 863 // Get the reduced version of the stack. | 863 // Get the reduced version of the stack. |
| 864 ElementList reducedClips; | 864 ElementList reducedClips; |
| 865 | 865 |
| 866 GrReducedClip::InitialState initial; | 866 GrReducedClip::InitialState initial; |
| 867 SkIRect tBounds; | 867 SkIRect tBounds(inflatedIBounds); |
| 868 SkIRect* tightBounds = r.nextBool() ? &tBounds : NULL; | 868 SkIRect* tightBounds = r.nextBool() ? &tBounds : NULL; |
| 869 GrReducedClip::ReduceClipStack(stack, | 869 GrReducedClip::ReduceClipStack(stack, |
| 870 inflatedIBounds, | 870 inflatedIBounds, |
| 871 &reducedClips, | 871 &reducedClips, |
| 872 &initial, | 872 &initial, |
| 873 tightBounds); | 873 tightBounds); |
| 874 | 874 |
| 875 // Build a new clip stack based on the reduced clip elements | 875 // Build a new clip stack based on the reduced clip elements |
| 876 SkClipStack reducedStack; | 876 SkClipStack reducedStack; |
| 877 if (GrReducedClip::kAllOut_InitialState == initial) { | 877 if (GrReducedClip::kAllOut_InitialState == initial) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 test_rect_merging(reporter); | 952 test_rect_merging(reporter); |
| 953 test_rect_inverse_fill(reporter); | 953 test_rect_inverse_fill(reporter); |
| 954 test_quickContains(reporter); | 954 test_quickContains(reporter); |
| 955 #if SK_SUPPORT_GPU | 955 #if SK_SUPPORT_GPU |
| 956 test_reduced_clip_stack(reporter); | 956 test_reduced_clip_stack(reporter); |
| 957 #endif | 957 #endif |
| 958 } | 958 } |
| 959 | 959 |
| 960 #include "TestClassDef.h" | 960 #include "TestClassDef.h" |
| 961 DEFINE_TESTCLASS("ClipStack", TestClipStackClass, TestClipStack) | 961 DEFINE_TESTCLASS("ClipStack", TestClipStackClass, TestClipStack) |
| OLD | NEW |