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 "Test.h" | 8 #include "Test.h" |
9 #include "SkClipStack.h" | 9 #include "SkClipStack.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 | 999 |
1000 bool invert = r.nextBiasedBool(kFractionInverted); | 1000 bool invert = r.nextBiasedBool(kFractionInverted); |
1001 | 1001 |
1002 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack, | 1002 kElementFuncs[r.nextULessThan(SK_ARRAY_COUNT(kElementFuncs))](rect,
invert, op, &stack, |
1003 doAA); | 1003 doAA); |
1004 if (doSave) { | 1004 if (doSave) { |
1005 stack.save(); | 1005 stack.save(); |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
| 1009 // Get the reduced version of the stack. |
1009 SkRect queryBounds = kBounds; | 1010 SkRect queryBounds = kBounds; |
1010 queryBounds.outset(kBounds.width() / 2, kBounds.height() / 2); | 1011 queryBounds.outset(kBounds.width() / 2, kBounds.height() / 2); |
| 1012 const GrReducedClip reduced(stack, queryBounds); |
1011 | 1013 |
1012 // Get the reduced version of the stack. | 1014 REPORTER_ASSERT_MESSAGE(reporter, SkClipStack::kInvalidGenID != reduced.
genID(), |
1013 ElementList reducedClips; | |
1014 int32_t reducedGenID; | |
1015 SkIRect clipIBounds; | |
1016 bool requiresAA; | |
1017 InitialState initial = GrReducedClip::ReduceClipStack(stack, | |
1018 queryBounds, | |
1019 &reducedClips, | |
1020 &reducedGenID, | |
1021 &clipIBounds, | |
1022 &requiresAA); | |
1023 | |
1024 REPORTER_ASSERT_MESSAGE(reporter, SkClipStack::kInvalidGenID != reducedG
enID, | |
1025 testCase.c_str()); | 1015 testCase.c_str()); |
1026 | 1016 |
1027 if (!reducedClips.isEmpty()) { | 1017 if (!reduced.elements().isEmpty()) { |
1028 SkRect stackBounds; | 1018 SkRect stackBounds; |
1029 SkClipStack::BoundsType stackBoundsType; | 1019 SkClipStack::BoundsType stackBoundsType; |
1030 stack.getBounds(&stackBounds, &stackBoundsType); | 1020 stack.getBounds(&stackBounds, &stackBoundsType); |
1031 if (SkClipStack::kNormal_BoundsType == stackBoundsType) { | 1021 if (SkClipStack::kNormal_BoundsType == stackBoundsType) { |
1032 // Unless GrReducedClip starts doing some heroic tightening of t
he clip bounds, this | 1022 // Unless GrReducedClip starts doing some heroic tightening of t
he clip bounds, this |
1033 // will be true since the stack bounds are completely contained
inside the query. | 1023 // will be true since the stack bounds are completely contained
inside the query. |
1034 REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(clipIBoun
ds, stackBounds), | 1024 REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(reduced.i
Bounds(), stackBounds), |
1035 testCase.c_str()); | 1025 testCase.c_str()); |
1036 } | 1026 } |
1037 REPORTER_ASSERT_MESSAGE(reporter, requiresAA == doAA, testCase.c_str
()); | 1027 REPORTER_ASSERT_MESSAGE(reporter, reduced.requiresAA() == doAA, test
Case.c_str()); |
1038 } | 1028 } |
1039 | 1029 |
1040 // Build a new clip stack based on the reduced clip elements | 1030 // Build a new clip stack based on the reduced clip elements |
1041 SkClipStack reducedStack; | 1031 SkClipStack reducedStack; |
1042 if (GrReducedClip::kAllOut_InitialState == initial) { | 1032 if (GrReducedClip::InitialState::kAllOut == reduced.initialState()) { |
1043 // whether the result is bounded or not, the whole plane should star
t outside the clip. | 1033 // whether the result is bounded or not, the whole plane should star
t outside the clip. |
1044 reducedStack.clipEmpty(); | 1034 reducedStack.clipEmpty(); |
1045 } | 1035 } |
1046 for (ElementList::Iter iter = reducedClips.headIter(); iter.get(); iter.
next()) { | 1036 for (ElementList::Iter iter(reduced.elements()); iter.get(); iter.next()
) { |
1047 add_elem_to_stack(*iter.get(), &reducedStack); | 1037 add_elem_to_stack(*iter.get(), &reducedStack); |
1048 } | 1038 } |
1049 | 1039 |
1050 // GrReducedClipStack assumes that the final result is clipped to the re
turned bounds | 1040 // GrReducedClipStack assumes that the final result is clipped to the re
turned bounds |
1051 reducedStack.clipDevRect(clipIBounds, SkRegion::kIntersect_Op); | 1041 reducedStack.clipDevRect(reduced.iBounds(), SkRegion::kIntersect_Op); |
1052 stack.clipDevRect(clipIBounds, SkRegion::kIntersect_Op); | 1042 stack.clipDevRect(reduced.iBounds(), SkRegion::kIntersect_Op); |
1053 | 1043 |
1054 // convert both the original stack and reduced stack to SkRegions and se
e if they're equal | 1044 // convert both the original stack and reduced stack to SkRegions and se
e if they're equal |
1055 SkRegion region; | 1045 SkRegion region; |
1056 set_region_to_stack(stack, clipIBounds, ®ion); | 1046 set_region_to_stack(stack, reduced.iBounds(), ®ion); |
1057 | 1047 |
1058 SkRegion reducedRegion; | 1048 SkRegion reducedRegion; |
1059 set_region_to_stack(reducedStack, clipIBounds, &reducedRegion); | 1049 set_region_to_stack(reducedStack, reduced.iBounds(), &reducedRegion); |
1060 | 1050 |
1061 REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_st
r()); | 1051 REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_st
r()); |
1062 } | 1052 } |
1063 } | 1053 } |
1064 | 1054 |
1065 #ifdef SK_BUILD_FOR_WIN | 1055 #ifdef SK_BUILD_FOR_WIN |
1066 #define SUPPRESS_VISIBILITY_WARNING | 1056 #define SUPPRESS_VISIBILITY_WARNING |
1067 #else | 1057 #else |
1068 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) | 1058 #define SUPPRESS_VISIBILITY_WARNING __attribute__((visibility("hidden"))) |
1069 #endif | 1059 #endif |
1070 | 1060 |
1071 static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { | 1061 static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) { |
1072 { | 1062 { |
1073 SkClipStack stack; | 1063 SkClipStack stack; |
1074 stack.clipDevRect(SkRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_O
p, true); | 1064 stack.clipDevRect(SkRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_O
p, true); |
1075 stack.clipDevRect(SkRect::MakeXYWH(0, 0, SkScalar(50.3), SkScalar(50.3))
, SkRegion::kReplace_Op, true); | 1065 stack.clipDevRect(SkRect::MakeXYWH(0, 0, SkScalar(50.3), SkScalar(50.3))
, SkRegion::kReplace_Op, true); |
1076 SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100); | 1066 SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100); |
1077 | 1067 |
1078 ElementList reducedClips; | 1068 const GrReducedClip reduced(stack, bounds); |
1079 int32_t reducedGenID; | |
1080 SkIRect tightBounds; | |
1081 bool requiresAA; | |
1082 | 1069 |
1083 GrReducedClip::ReduceClipStack(stack, | 1070 REPORTER_ASSERT(reporter, reduced.elements().count() == 1); |
1084 bounds, | |
1085 &reducedClips, | |
1086 &reducedGenID, | |
1087 &tightBounds, | |
1088 &requiresAA); | |
1089 | |
1090 REPORTER_ASSERT(reporter, reducedClips.count() == 1); | |
1091 // Clips will be cached based on the generation id. Make sure the gen id
is valid. | 1071 // Clips will be cached based on the generation id. Make sure the gen id
is valid. |
1092 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedGenID); | 1072 REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reduced.genID())
; |
1093 } | 1073 } |
1094 { | 1074 { |
1095 SkClipStack stack; | 1075 SkClipStack stack; |
1096 | 1076 |
1097 // Create a clip with following 25.3, 25.3 boxes which are 25 apart: | 1077 // Create a clip with following 25.3, 25.3 boxes which are 25 apart: |
1098 // A B | 1078 // A B |
1099 // C D | 1079 // C D |
1100 | 1080 |
1101 stack.clipDevRect(SkRect::MakeXYWH(0, 0, SkScalar(25.3), SkScalar(25.3))
, SkRegion::kReplace_Op, true); | 1081 stack.clipDevRect(SkRect::MakeXYWH(0, 0, SkScalar(25.3), SkScalar(25.3))
, SkRegion::kReplace_Op, true); |
1102 int32_t genIDA = stack.getTopmostGenID(); | 1082 int32_t genIDA = stack.getTopmostGenID(); |
(...skipping 19 matching lines...) Expand all Loading... |
1122 | 1102 |
1123 // Not passing in tighter bounds is tested for consistency. | 1103 // Not passing in tighter bounds is tested for consistency. |
1124 static const struct SUPPRESS_VISIBILITY_WARNING { | 1104 static const struct SUPPRESS_VISIBILITY_WARNING { |
1125 SkRect testBounds; | 1105 SkRect testBounds; |
1126 int reducedClipCount; | 1106 int reducedClipCount; |
1127 int32_t reducedGenID; | 1107 int32_t reducedGenID; |
1128 InitialState initialState; | 1108 InitialState initialState; |
1129 SkIRect clipIRect; | 1109 SkIRect clipIRect; |
1130 // parameter. | 1110 // parameter. |
1131 } testCases[] = { | 1111 } testCases[] = { |
| 1112 |
1132 // Rect A. | 1113 // Rect A. |
1133 { XYWH(0, 0, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip:
:kAllIn_InitialState, IXYWH(0, 0, 25, 25) }, | 1114 { XYWH(0, 0, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip:
:InitialState::kAllIn, IXYWH(0, 0, 25, 25) }, |
1134 { XYWH(0.1f, 0.1f, 25.1f, 25.1f), 0, SkClipStack::kWideOpenGenID, Gr
ReducedClip::kAllIn_InitialState, IXYWH(0, 0, 26, 26) }, | 1115 { XYWH(0.1f, 0.1f, 25.1f, 25.1f), 0, SkClipStack::kWideOpenGenID, Gr
ReducedClip::InitialState::kAllIn, IXYWH(0, 0, 26, 26) }, |
1135 { XYWH(0, 0, 27, 27), 1, genIDA, GrReducedClip::kAllOut_InitialState
, IXYWH(0, 0, 27, 27)}, | 1116 { XYWH(0, 0, 27, 27), 1, genIDA, GrReducedClip::InitialState::kAllOu
t, IXYWH(0, 0, 27, 27)}, |
1136 | 1117 |
1137 // Rect B. | 1118 // Rect B. |
1138 { XYWH(50, 0, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip
::kAllIn_InitialState, IXYWH(50, 0, 25, 25) }, | 1119 { XYWH(50, 0, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip
::InitialState::kAllIn, IXYWH(50, 0, 25, 25) }, |
1139 { XYWH(50, 0, 25.3f, 25.3f), 0, SkClipStack::kWideOpenGenID, GrReduc
edClip::kAllIn_InitialState, IXYWH(50, 0, 26, 26) }, | 1120 { XYWH(50, 0, 25.3f, 25.3f), 0, SkClipStack::kWideOpenGenID, GrReduc
edClip::InitialState::kAllIn, IXYWH(50, 0, 26, 26) }, |
1140 { XYWH(50, 0, 27, 27), 1, genIDB, GrReducedClip::kAllOut_InitialStat
e, IXYWH(50, 0, 26, 27) }, | 1121 { XYWH(50, 0, 27, 27), 1, genIDB, GrReducedClip::InitialState::kAllO
ut, IXYWH(50, 0, 26, 27) }, |
1141 | 1122 |
1142 // Rect C. | 1123 // Rect C. |
1143 { XYWH(0, 50, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip
::kAllIn_InitialState, IXYWH(0, 50, 25, 25) }, | 1124 { XYWH(0, 50, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedClip
::InitialState::kAllIn, IXYWH(0, 50, 25, 25) }, |
1144 { XYWH(0.2f, 50.1f, 25.1f, 25.2f), 0, SkClipStack::kWideOpenGenID, G
rReducedClip::kAllIn_InitialState, IXYWH(0, 50, 26, 26) }, | 1125 { XYWH(0.2f, 50.1f, 25.1f, 25.2f), 0, SkClipStack::kWideOpenGenID, G
rReducedClip::InitialState::kAllIn, IXYWH(0, 50, 26, 26) }, |
1145 { XYWH(0, 50, 27, 27), 1, genIDC, GrReducedClip::kAllOut_InitialStat
e, IXYWH(0, 50, 27, 26) }, | 1126 { XYWH(0, 50, 27, 27), 1, genIDC, GrReducedClip::InitialState::kAllO
ut, IXYWH(0, 50, 27, 26) }, |
1146 | 1127 |
1147 // Rect D. | 1128 // Rect D. |
1148 { XYWH(50, 50, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedCli
p::kAllIn_InitialState, IXYWH(50, 50, 25, 25)}, | 1129 { XYWH(50, 50, 25, 25), 0, SkClipStack::kWideOpenGenID, GrReducedCli
p::InitialState::kAllIn, IXYWH(50, 50, 25, 25)}, |
1149 { XYWH(50.3f, 50.3f, 25, 25), 0, SkClipStack::kWideOpenGenID, GrRedu
cedClip::kAllIn_InitialState, IXYWH(50, 50, 26, 26)}, | 1130 { XYWH(50.3f, 50.3f, 25, 25), 0, SkClipStack::kWideOpenGenID, GrRedu
cedClip::InitialState::kAllIn, IXYWH(50, 50, 26, 26)}, |
1150 { XYWH(50, 50, 27, 27), 1, genIDD, GrReducedClip::kAllOut_InitialSta
te, IXYWH(50, 50, 26, 26)}, | 1131 { XYWH(50, 50, 27, 27), 1, genIDD, GrReducedClip::InitialState::kAll
Out, IXYWH(50, 50, 26, 26)}, |
1151 | 1132 |
1152 // Other tests: | 1133 // Other tests: |
1153 { XYWH(0, 0, 100, 100), 4, genIDD, GrReducedClip::kAllOut_InitialSta
te, stackBounds }, | 1134 { XYWH(0, 0, 100, 100), 4, genIDD, GrReducedClip::InitialState::kAll
Out, stackBounds }, |
1154 | 1135 |
1155 // Rect in the middle, touches none. | 1136 // Rect in the middle, touches none. |
1156 { XYWH(26, 26, 24, 24), 0, SkClipStack::kEmptyGenID, GrReducedClip::
kAllOut_InitialState, IXYWH(26, 26, 24, 24) }, | 1137 { XYWH(26, 26, 24, 24), 0, SkClipStack::kEmptyGenID, GrReducedClip::
InitialState::kAllOut, IXYWH(26, 26, 24, 24) }, |
1157 | 1138 |
1158 // Rect in the middle, touches all the rects. GenID is the last rect
. | 1139 // Rect in the middle, touches all the rects. GenID is the last rect
. |
1159 { XYWH(24, 24, 27, 27), 4, genIDD, GrReducedClip::kAllOut_InitialSta
te, IXYWH(24, 24, 27, 27) }, | 1140 { XYWH(24, 24, 27, 27), 4, genIDD, GrReducedClip::InitialState::kAll
Out, IXYWH(24, 24, 27, 27) }, |
1160 }; | 1141 }; |
1161 | 1142 |
1162 #undef XYWH | 1143 #undef XYWH |
1163 #undef IXYWH | 1144 #undef IXYWH |
1164 | 1145 |
1165 for (size_t i = 0; i < SK_ARRAY_COUNT(testCases); ++i) { | 1146 for (size_t i = 0; i < SK_ARRAY_COUNT(testCases); ++i) { |
1166 ElementList reducedClips; | 1147 const GrReducedClip reduced(stack, testCases[i].testBounds); |
1167 int32_t reducedGenID; | 1148 REPORTER_ASSERT(reporter, reduced.elements().count() == testCases[i]
.reducedClipCount); |
1168 SkIRect clipIRect; | 1149 SkASSERT(reduced.elements().count() == testCases[i].reducedClipCount
); |
1169 bool requiresAA; | 1150 REPORTER_ASSERT(reporter, reduced.genID() == testCases[i].reducedGen
ID); |
1170 | 1151 SkASSERT(reduced.genID() == testCases[i].reducedGenID); |
1171 InitialState initial = GrReducedClip::ReduceClipStack(stack, | 1152 REPORTER_ASSERT(reporter, reduced.initialState() == testCases[i].ini
tialState); |
1172 testCases[i].t
estBounds, | 1153 SkASSERT(reduced.initialState() == testCases[i].initialState); |
1173 &reducedClips, | 1154 REPORTER_ASSERT(reporter, reduced.iBounds() == testCases[i].clipIRec
t); |
1174 &reducedGenID, | 1155 SkASSERT(reduced.iBounds() == testCases[i].clipIRect); |
1175 &clipIRect, | |
1176 &requiresAA); | |
1177 | |
1178 REPORTER_ASSERT(reporter, reducedClips.count() == testCases[i].reduc
edClipCount); | |
1179 SkASSERT(reducedClips.count() == testCases[i].reducedClipCount); | |
1180 REPORTER_ASSERT(reporter, reducedGenID == testCases[i].reducedGenID)
; | |
1181 SkASSERT(reducedGenID == testCases[i].reducedGenID); | |
1182 REPORTER_ASSERT(reporter, initial == testCases[i].initialState); | |
1183 SkASSERT(initial == testCases[i].initialState); | |
1184 REPORTER_ASSERT(reporter, clipIRect == testCases[i].clipIRect); | |
1185 SkASSERT(clipIRect == testCases[i].clipIRect); | |
1186 } | 1156 } |
1187 } | 1157 } |
1188 } | 1158 } |
1189 | 1159 |
1190 static void test_reduced_clip_stack_no_aa_crash(skiatest::Reporter* reporter) { | 1160 static void test_reduced_clip_stack_no_aa_crash(skiatest::Reporter* reporter) { |
1191 SkClipStack stack; | 1161 SkClipStack stack; |
1192 stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_Op); | 1162 stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 100, 100), SkRegion::kReplace_Op); |
1193 stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 50, 50), SkRegion::kReplace_Op); | 1163 stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 50, 50), SkRegion::kReplace_Op); |
1194 SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100); | 1164 SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100); |
1195 | 1165 |
1196 ElementList reducedClips; | |
1197 int32_t reducedGenID; | |
1198 SkIRect tightBounds; | |
1199 bool requiresAA; | |
1200 | |
1201 // At the time, this would crash. | 1166 // At the time, this would crash. |
1202 GrReducedClip::ReduceClipStack(stack, | 1167 const GrReducedClip reduced(stack, bounds); |
1203 bounds, | 1168 REPORTER_ASSERT(reporter, reduced.elements().isEmpty()); |
1204 &reducedClips, | |
1205 &reducedGenID, | |
1206 &tightBounds, | |
1207 &requiresAA); | |
1208 | |
1209 REPORTER_ASSERT(reporter, 0 == reducedClips.count()); | |
1210 } | 1169 } |
1211 | 1170 |
1212 enum class ClipMethod { | 1171 enum class ClipMethod { |
1213 kSkipDraw, | 1172 kSkipDraw, |
1214 kIgnoreClip, | 1173 kIgnoreClip, |
1215 kScissor, | 1174 kScissor, |
1216 kAAElements | 1175 kAAElements |
1217 }; | 1176 }; |
1218 | 1177 |
1219 static void test_aa_query(skiatest::Reporter* reporter, const SkString& testName
, | 1178 static void test_aa_query(skiatest::Reporter* reporter, const SkString& testName
, |
1220 const SkClipStack& stack, const SkMatrix& queryXform, | 1179 const SkClipStack& stack, const SkMatrix& queryXform, |
1221 const SkRect& preXformQuery, ClipMethod expectedMethod
, | 1180 const SkRect& preXformQuery, ClipMethod expectedMethod
, |
1222 int numExpectedElems = 0) { | 1181 int numExpectedElems = 0) { |
1223 ElementList reducedElems; | |
1224 int32_t reducedGenID; | |
1225 SkIRect clipIBounds; | |
1226 bool requiresAA; | |
1227 | |
1228 SkRect queryBounds; | 1182 SkRect queryBounds; |
1229 queryXform.mapRect(&queryBounds, preXformQuery); | 1183 queryXform.mapRect(&queryBounds, preXformQuery); |
1230 | 1184 const GrReducedClip reduced(stack, queryBounds); |
1231 InitialState initialState = GrReducedClip::ReduceClipStack(stack, | |
1232 queryBounds, | |
1233 &reducedElems, | |
1234 &reducedGenID, | |
1235 &clipIBounds, | |
1236 &requiresAA); | |
1237 | 1185 |
1238 SkClipStack::BoundsType stackBoundsType; | 1186 SkClipStack::BoundsType stackBoundsType; |
1239 SkRect stackBounds; | 1187 SkRect stackBounds; |
1240 stack.getBounds(&stackBounds, &stackBoundsType); | 1188 stack.getBounds(&stackBounds, &stackBoundsType); |
1241 | 1189 |
1242 switch (expectedMethod) { | 1190 switch (expectedMethod) { |
1243 case ClipMethod::kSkipDraw: | 1191 case ClipMethod::kSkipDraw: |
1244 SkASSERT(0 == numExpectedElems); | 1192 SkASSERT(0 == numExpectedElems); |
1245 REPORTER_ASSERT_MESSAGE(reporter, reducedElems.isEmpty(), testName.c
_str()); | 1193 REPORTER_ASSERT_MESSAGE(reporter, reduced.elements().isEmpty(), test
Name.c_str()); |
1246 REPORTER_ASSERT_MESSAGE(reporter, GrReducedClip::kAllOut_InitialStat
e == initialState, | 1194 REPORTER_ASSERT_MESSAGE(reporter, |
| 1195 GrReducedClip::InitialState::kAllOut == redu
ced.initialState(), |
1247 testName.c_str()); | 1196 testName.c_str()); |
1248 return; | 1197 return; |
1249 case ClipMethod::kIgnoreClip: | 1198 case ClipMethod::kIgnoreClip: |
1250 SkASSERT(0 == numExpectedElems); | 1199 SkASSERT(0 == numExpectedElems); |
1251 REPORTER_ASSERT_MESSAGE(reporter, reducedElems.isEmpty(), testName.c
_str()); | 1200 REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(reduced.iBoun
ds(), queryBounds), |
1252 REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(clipIBounds,
queryBounds), | |
1253 testName.c_str()); | 1201 testName.c_str()); |
1254 REPORTER_ASSERT_MESSAGE(reporter, GrReducedClip::kAllIn_InitialState
== initialState, | 1202 REPORTER_ASSERT_MESSAGE(reporter, reduced.elements().isEmpty(), test
Name.c_str()); |
| 1203 REPORTER_ASSERT_MESSAGE(reporter, |
| 1204 GrReducedClip::InitialState::kAllIn == reduc
ed.initialState(), |
1255 testName.c_str()); | 1205 testName.c_str()); |
1256 return; | 1206 return; |
1257 case ClipMethod::kScissor: { | 1207 case ClipMethod::kScissor: { |
1258 SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType); | 1208 SkASSERT(SkClipStack::kNormal_BoundsType == stackBoundsType); |
1259 SkASSERT(0 == numExpectedElems); | 1209 SkASSERT(0 == numExpectedElems); |
1260 SkIRect expectedScissor; | 1210 SkIRect expectedScissor; |
1261 stackBounds.round(&expectedScissor); | 1211 stackBounds.round(&expectedScissor); |
1262 REPORTER_ASSERT_MESSAGE(reporter, reducedElems.isEmpty(), testName.c
_str()); | 1212 REPORTER_ASSERT_MESSAGE(reporter, reduced.elements().isEmpty(), test
Name.c_str()); |
1263 REPORTER_ASSERT_MESSAGE(reporter, expectedScissor == clipIBounds, te
stName.c_str()); | 1213 REPORTER_ASSERT_MESSAGE(reporter, expectedScissor == reduced.iBounds
(), |
1264 REPORTER_ASSERT_MESSAGE(reporter, GrReducedClip::kAllIn_InitialState
== initialState, | 1214 testName.c_str()); |
| 1215 REPORTER_ASSERT_MESSAGE(reporter, |
| 1216 GrReducedClip::InitialState::kAllIn == reduc
ed.initialState(), |
1265 testName.c_str()); | 1217 testName.c_str()); |
1266 return; | 1218 return; |
1267 } | 1219 } |
1268 case ClipMethod::kAAElements: { | 1220 case ClipMethod::kAAElements: { |
1269 SkIRect expectedClipIBounds = GrClip::GetPixelIBounds(queryBounds); | 1221 SkIRect expectedClipIBounds = GrClip::GetPixelIBounds(queryBounds); |
1270 if (SkClipStack::kNormal_BoundsType == stackBoundsType) { | 1222 if (SkClipStack::kNormal_BoundsType == stackBoundsType) { |
1271 SkAssertResult(expectedClipIBounds.intersect(GrClip::GetPixelIBo
unds(stackBounds))); | 1223 SkAssertResult(expectedClipIBounds.intersect(GrClip::GetPixelIBo
unds(stackBounds))); |
1272 } | 1224 } |
1273 REPORTER_ASSERT_MESSAGE(reporter, numExpectedElems == reducedElems.c
ount(), | 1225 REPORTER_ASSERT_MESSAGE(reporter, numExpectedElems == reduced.elemen
ts().count(), |
1274 testName.c_str()); | 1226 testName.c_str()); |
1275 REPORTER_ASSERT_MESSAGE(reporter, expectedClipIBounds == clipIBounds
, testName.c_str()); | 1227 REPORTER_ASSERT_MESSAGE(reporter, expectedClipIBounds == reduced.iBo
unds(), |
1276 REPORTER_ASSERT_MESSAGE(reporter, requiresAA == !reducedElems.isEmpt
y(), | 1228 testName.c_str()); |
| 1229 REPORTER_ASSERT_MESSAGE(reporter, reduced.requiresAA() == !reduced.e
lements().isEmpty(), |
1277 testName.c_str()); | 1230 testName.c_str()); |
1278 break; | 1231 break; |
1279 } | 1232 } |
1280 } | 1233 } |
1281 } | 1234 } |
1282 | 1235 |
1283 static void test_reduced_clip_stack_aa(skiatest::Reporter* reporter) { | 1236 static void test_reduced_clip_stack_aa(skiatest::Reporter* reporter) { |
1284 constexpr SkScalar IL = 2, IT = 1, IR = 6, IB = 7; // Pixel aligned
rect. | 1237 constexpr SkScalar IL = 2, IT = 1, IR = 6, IB = 7; // Pixel aligned
rect. |
1285 constexpr SkScalar L = 2.2f, T = 1.7f, R = 5.8f, B = 7.3f; // Generic rect. | 1238 constexpr SkScalar L = 2.2f, T = 1.7f, R = 5.8f, B = 7.3f; // Generic rect. |
1286 constexpr SkScalar l = 3.3f, t = 2.8f, r = 4.7f, b = 6.2f; // Small rect con
tained in R. | 1239 constexpr SkScalar l = 3.3f, t = 2.8f, r = 4.7f, b = 6.2f; // Small rect con
tained in R. |
(...skipping 12 matching lines...) Expand all Loading... |
1299 SkString name; | 1252 SkString name; |
1300 SkRandom rand; | 1253 SkRandom rand; |
1301 | 1254 |
1302 for (int i = 0; i < kNumIters; ++i) { | 1255 for (int i = 0; i < kNumIters; ++i) { |
1303 // Pixel-aligned rect (iior=true). | 1256 // Pixel-aligned rect (iior=true). |
1304 name.printf("Pixel-aligned rect test, iter %i", i); | 1257 name.printf("Pixel-aligned rect test, iter %i", i); |
1305 SkClipStack stack; | 1258 SkClipStack stack; |
1306 stack.clipDevRect(alignedRect, SkRegion::kIntersect_Op, true); | 1259 stack.clipDevRect(alignedRect, SkRegion::kIntersect_Op, true); |
1307 test_aa_query(reporter, name, stack, m, {IL, IT, IR, IB}, ClipMethod::kI
gnoreClip); | 1260 test_aa_query(reporter, name, stack, m, {IL, IT, IR, IB}, ClipMethod::kI
gnoreClip); |
1308 test_aa_query(reporter, name, stack, m, {IL, IT-1, IR, IT}, ClipMethod::
kSkipDraw); | 1261 test_aa_query(reporter, name, stack, m, {IL, IT-1, IR, IT}, ClipMethod::
kSkipDraw); |
1309 test_aa_query(reporter, name, stack, m, {IL, IT, IR, IB}, ClipMethod::kS
cissor); | 1262 test_aa_query(reporter, name, stack, m, {IL, IT-2, IR, IB}, ClipMethod::
kScissor); |
1310 test_aa_query(reporter, name, stack, m, {IL, IT+2, IR, IB-3}, ClipMethod
::kScissor); | |
1311 | 1263 |
1312 // Rect (iior=true). | 1264 // Rect (iior=true). |
1313 name.printf("Rect test, iter %i", i); | 1265 name.printf("Rect test, iter %i", i); |
1314 stack.reset(); | 1266 stack.reset(); |
1315 stack.clipDevRect(rect, SkRegion::kIntersect_Op, true); | 1267 stack.clipDevRect(rect, SkRegion::kIntersect_Op, true); |
1316 test_aa_query(reporter, name, stack, m, {L, T, R, B}, ClipMethod::kIgno
reClip); | 1268 test_aa_query(reporter, name, stack, m, {L, T, R, B}, ClipMethod::kIgno
reClip); |
1317 test_aa_query(reporter, name, stack, m, {L-.1f, T, L, B}, ClipMethod::kS
kipDraw); | 1269 test_aa_query(reporter, name, stack, m, {L-.1f, T, L, B}, ClipMethod::kS
kipDraw); |
1318 test_aa_query(reporter, name, stack, m, {L-.1f, T, L+.1f, B}, ClipMethod
::kAAElements, 1); | 1270 test_aa_query(reporter, name, stack, m, {L-.1f, T, L+.1f, B}, ClipMethod
::kAAElements, 1); |
1319 | 1271 |
1320 // Difference rect (iior=false, inside-out bounds). | 1272 // Difference rect (iior=false, inside-out bounds). |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 test_path_replace(reporter); | 1366 test_path_replace(reporter); |
1415 test_quickContains(reporter); | 1367 test_quickContains(reporter); |
1416 test_invfill_diff_bug(reporter); | 1368 test_invfill_diff_bug(reporter); |
1417 #if SK_SUPPORT_GPU | 1369 #if SK_SUPPORT_GPU |
1418 test_reduced_clip_stack(reporter); | 1370 test_reduced_clip_stack(reporter); |
1419 test_reduced_clip_stack_genid(reporter); | 1371 test_reduced_clip_stack_genid(reporter); |
1420 test_reduced_clip_stack_no_aa_crash(reporter); | 1372 test_reduced_clip_stack_no_aa_crash(reporter); |
1421 test_reduced_clip_stack_aa(reporter); | 1373 test_reduced_clip_stack_aa(reporter); |
1422 #endif | 1374 #endif |
1423 } | 1375 } |
OLD | NEW |