| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 elemRegion.setPath(element.getPath(), boundsRgn); | 851 elemRegion.setPath(element.getPath(), boundsRgn); |
| 852 break; | 852 break; |
| 853 case SkClipStack::Element::kEmpty_Type: | 853 case SkClipStack::Element::kEmpty_Type: |
| 854 // | 854 // |
| 855 region->setEmpty(); | 855 region->setEmpty(); |
| 856 return; | 856 return; |
| 857 } | 857 } |
| 858 region->op(elemRegion, element.getOp()); | 858 region->op(elemRegion, element.getOp()); |
| 859 } | 859 } |
| 860 | 860 |
| 861 // This can assist with debugging the clip stack reduction code when the test be
low fails. | |
| 862 static inline void print_clip(const SkClipStack::Element& element) { | |
| 863 static const char* kOpStrs[] = { | |
| 864 "DF", | |
| 865 "IS", | |
| 866 "UN", | |
| 867 "XR", | |
| 868 "RD", | |
| 869 "RP", | |
| 870 }; | |
| 871 if (SkClipStack::Element::kEmpty_Type != element.getType()) { | |
| 872 const SkRect& bounds = element.getBounds(); | |
| 873 bool isRect = SkClipStack::Element::kRect_Type == element.getType(); | |
| 874 SkDebugf("%s %s %s [%f %f] x [%f %f]\n", | |
| 875 kOpStrs[element.getOp()], | |
| 876 (isRect ? "R" : "P"), | |
| 877 (element.isInverseFilled() ? "I" : " "), | |
| 878 bounds.fLeft, bounds.fRight, bounds.fTop, bounds.fBottom); | |
| 879 } else { | |
| 880 SkDebugf("EM\n"); | |
| 881 } | |
| 882 } | |
| 883 | |
| 884 static void test_reduced_clip_stack(skiatest::Reporter* reporter) { | 861 static void test_reduced_clip_stack(skiatest::Reporter* reporter) { |
| 885 // We construct random clip stacks, reduce them, and then rasterize both ver
sions to verify that | 862 // We construct random clip stacks, reduce them, and then rasterize both ver
sions to verify that |
| 886 // they are equal. | 863 // they are equal. |
| 887 | 864 |
| 888 // All the clip elements will be contained within these bounds. | 865 // All the clip elements will be contained within these bounds. |
| 889 static const SkRect kBounds = SkRect::MakeWH(100, 100); | 866 static const SkRect kBounds = SkRect::MakeWH(100, 100); |
| 890 | 867 |
| 891 enum { | 868 enum { |
| 892 kNumTests = 200, | 869 kNumTests = 200, |
| 893 kMinElemsPerTest = 1, | 870 kMinElemsPerTest = 1, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 test_rect_inverse_fill(reporter); | 1032 test_rect_inverse_fill(reporter); |
| 1056 test_path_replace(reporter); | 1033 test_path_replace(reporter); |
| 1057 test_quickContains(reporter); | 1034 test_quickContains(reporter); |
| 1058 #if SK_SUPPORT_GPU | 1035 #if SK_SUPPORT_GPU |
| 1059 test_reduced_clip_stack(reporter); | 1036 test_reduced_clip_stack(reporter); |
| 1060 #endif | 1037 #endif |
| 1061 } | 1038 } |
| 1062 | 1039 |
| 1063 #include "TestClassDef.h" | 1040 #include "TestClassDef.h" |
| 1064 DEFINE_TESTCLASS("ClipStack", TestClipStackClass, TestClipStack) | 1041 DEFINE_TESTCLASS("ClipStack", TestClipStackClass, TestClipStack) |
| OLD | NEW |