| 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 #if SK_SUPPORT_GPU |     9 #if SK_SUPPORT_GPU | 
|    10     #include "GrReducedClip.h" |    10     #include "GrReducedClip.h" | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   137  |   137  | 
|   138     for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) { |   138     for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) { | 
|   139         // the union op will prevent these from being fused together |   139         // the union op will prevent these from being fused together | 
|   140         stack.clipDevRect(gRects[i], SkRegion::kUnion_Op, false); |   140         stack.clipDevRect(gRects[i], SkRegion::kUnion_Op, false); | 
|   141     } |   141     } | 
|   142  |   142  | 
|   143     assert_count(reporter, stack, 4); |   143     assert_count(reporter, stack, 4); | 
|   144  |   144  | 
|   145     // bottom to top iteration |   145     // bottom to top iteration | 
|   146     { |   146     { | 
|   147         const SkClipStack::Element* element = NULL; |   147         const SkClipStack::Element* element = nullptr; | 
|   148  |   148  | 
|   149         SkClipStack::B2TIter iter(stack); |   149         SkClipStack::B2TIter iter(stack); | 
|   150         int i; |   150         int i; | 
|   151  |   151  | 
|   152         for (i = 0, element = iter.next(); element; ++i, element = iter.next()) 
      { |   152         for (i = 0, element = iter.next(); element; ++i, element = iter.next()) 
      { | 
|   153             REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == elemen
      t->getType()); |   153             REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == elemen
      t->getType()); | 
|   154             REPORTER_ASSERT(reporter, element->getRect() == gRects[i]); |   154             REPORTER_ASSERT(reporter, element->getRect() == gRects[i]); | 
|   155         } |   155         } | 
|   156  |   156  | 
|   157         SkASSERT(i == 4); |   157         SkASSERT(i == 4); | 
|   158     } |   158     } | 
|   159  |   159  | 
|   160     // top to bottom iteration |   160     // top to bottom iteration | 
|   161     { |   161     { | 
|   162         const SkClipStack::Element* element = NULL; |   162         const SkClipStack::Element* element = nullptr; | 
|   163  |   163  | 
|   164         SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart); |   164         SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart); | 
|   165         int i; |   165         int i; | 
|   166  |   166  | 
|   167         for (i = 3, element = iter.prev(); element; --i, element = iter.prev()) 
      { |   167         for (i = 3, element = iter.prev(); element; --i, element = iter.prev()) 
      { | 
|   168             REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == elemen
      t->getType()); |   168             REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == elemen
      t->getType()); | 
|   169             REPORTER_ASSERT(reporter, element->getRect() == gRects[i]); |   169             REPORTER_ASSERT(reporter, element->getRect() == gRects[i]); | 
|   170         } |   170         } | 
|   171  |   171  | 
|   172         SkASSERT(i == -1); |   172         SkASSERT(i == -1); | 
|   173     } |   173     } | 
|   174  |   174  | 
|   175     // skipToTopmost |   175     // skipToTopmost | 
|   176     { |   176     { | 
|   177         const SkClipStack::Element* element = NULL; |   177         const SkClipStack::Element* element = nullptr; | 
|   178  |   178  | 
|   179         SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); |   179         SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart); | 
|   180  |   180  | 
|   181         element = iter.skipToTopmost(SkRegion::kUnion_Op); |   181         element = iter.skipToTopmost(SkRegion::kUnion_Op); | 
|   182         REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->g
      etType()); |   182         REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->g
      etType()); | 
|   183         REPORTER_ASSERT(reporter, element->getRect() == gRects[3]); |   183         REPORTER_ASSERT(reporter, element->getRect() == gRects[3]); | 
|   184     } |   184     } | 
|   185 } |   185 } | 
|   186  |   186  | 
|   187 // Exercise the SkClipStack's getConservativeBounds computation |   187 // Exercise the SkClipStack's getConservativeBounds computation | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   376  |   376  | 
|   377         REPORTER_ASSERT(reporter, stack.isWideOpen()); |   377         REPORTER_ASSERT(reporter, stack.isWideOpen()); | 
|   378         REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmos
      tGenID()); |   378         REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmos
      tGenID()); | 
|   379     } |   379     } | 
|   380 } |   380 } | 
|   381  |   381  | 
|   382 static int count(const SkClipStack& stack) { |   382 static int count(const SkClipStack& stack) { | 
|   383  |   383  | 
|   384     SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart); |   384     SkClipStack::Iter iter(stack, SkClipStack::Iter::kTop_IterStart); | 
|   385  |   385  | 
|   386     const SkClipStack::Element* element = NULL; |   386     const SkClipStack::Element* element = nullptr; | 
|   387     int count = 0; |   387     int count = 0; | 
|   388  |   388  | 
|   389     for (element = iter.prev(); element; element = iter.prev(), ++count) { |   389     for (element = iter.prev(); element; element = iter.prev(), ++count) { | 
|   390         ; |   390         ; | 
|   391     } |   391     } | 
|   392  |   392  | 
|   393     return count; |   393     return count; | 
|   394 } |   394 } | 
|   395  |   395  | 
|   396 static void test_rect_inverse_fill(skiatest::Reporter* reporter) { |   396 static void test_rect_inverse_fill(skiatest::Reporter* reporter) { | 
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   957         inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); |   957         inflatedBounds.outset(kBounds.width() / 2, kBounds.height() / 2); | 
|   958         SkIRect inflatedIBounds; |   958         SkIRect inflatedIBounds; | 
|   959         inflatedBounds.roundOut(&inflatedIBounds); |   959         inflatedBounds.roundOut(&inflatedIBounds); | 
|   960  |   960  | 
|   961         typedef GrReducedClip::ElementList ElementList; |   961         typedef GrReducedClip::ElementList ElementList; | 
|   962         // Get the reduced version of the stack. |   962         // Get the reduced version of the stack. | 
|   963         ElementList reducedClips; |   963         ElementList reducedClips; | 
|   964         int32_t reducedGenID; |   964         int32_t reducedGenID; | 
|   965         GrReducedClip::InitialState initial; |   965         GrReducedClip::InitialState initial; | 
|   966         SkIRect tBounds(inflatedIBounds); |   966         SkIRect tBounds(inflatedIBounds); | 
|   967         SkIRect* tightBounds = r.nextBool() ? &tBounds : NULL; |   967         SkIRect* tightBounds = r.nextBool() ? &tBounds : nullptr; | 
|   968         GrReducedClip::ReduceClipStack(stack, |   968         GrReducedClip::ReduceClipStack(stack, | 
|   969                                        inflatedIBounds, |   969                                        inflatedIBounds, | 
|   970                                        &reducedClips, |   970                                        &reducedClips, | 
|   971                                        &reducedGenID, |   971                                        &reducedGenID, | 
|   972                                        &initial, |   972                                        &initial, | 
|   973                                        tightBounds); |   973                                        tightBounds); | 
|   974  |   974  | 
|   975         REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedGenID); |   975         REPORTER_ASSERT(reporter, SkClipStack::kInvalidGenID != reducedGenID); | 
|   976  |   976  | 
|   977         // Build a new clip stack based on the reduced clip elements |   977         // Build a new clip stack based on the reduced clip elements | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1122             GrReducedClip::ElementList reducedClips; |  1122             GrReducedClip::ElementList reducedClips; | 
|  1123             int32_t reducedGenID; |  1123             int32_t reducedGenID; | 
|  1124             GrReducedClip::InitialState initial; |  1124             GrReducedClip::InitialState initial; | 
|  1125             SkIRect tightBounds; |  1125             SkIRect tightBounds; | 
|  1126  |  1126  | 
|  1127             GrReducedClip::ReduceClipStack(stack, |  1127             GrReducedClip::ReduceClipStack(stack, | 
|  1128                                            testCases[i].testBounds, |  1128                                            testCases[i].testBounds, | 
|  1129                                            &reducedClips, |  1129                                            &reducedClips, | 
|  1130                                            &reducedGenID, |  1130                                            &reducedGenID, | 
|  1131                                            &initial, |  1131                                            &initial, | 
|  1132                                            testCases[i].tighterBounds.isEmpty() 
      ? NULL : &tightBounds); |  1132                                            testCases[i].tighterBounds.isEmpty() 
      ? nullptr : &tightBounds); | 
|  1133  |  1133  | 
|  1134             REPORTER_ASSERT(reporter, reducedClips.count() == testCases[i].reduc
      edClipCount); |  1134             REPORTER_ASSERT(reporter, reducedClips.count() == testCases[i].reduc
      edClipCount); | 
|  1135             SkASSERT(reducedClips.count() == testCases[i].reducedClipCount); |  1135             SkASSERT(reducedClips.count() == testCases[i].reducedClipCount); | 
|  1136             REPORTER_ASSERT(reporter, reducedGenID == testCases[i].reducedGenID)
      ; |  1136             REPORTER_ASSERT(reporter, reducedGenID == testCases[i].reducedGenID)
      ; | 
|  1137             SkASSERT(reducedGenID == testCases[i].reducedGenID); |  1137             SkASSERT(reducedGenID == testCases[i].reducedGenID); | 
|  1138             REPORTER_ASSERT(reporter, initial == testCases[i].initialState); |  1138             REPORTER_ASSERT(reporter, initial == testCases[i].initialState); | 
|  1139             SkASSERT(initial == testCases[i].initialState); |  1139             SkASSERT(initial == testCases[i].initialState); | 
|  1140             if (!testCases[i].tighterBounds.isEmpty()) { |  1140             if (!testCases[i].tighterBounds.isEmpty()) { | 
|  1141                 REPORTER_ASSERT(reporter, tightBounds == testCases[i].tighterBou
      nds); |  1141                 REPORTER_ASSERT(reporter, tightBounds == testCases[i].tighterBou
      nds); | 
|  1142                 SkASSERT(tightBounds == testCases[i].tighterBounds); |  1142                 SkASSERT(tightBounds == testCases[i].tighterBounds); | 
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1212     test_rect_replace(reporter); |  1212     test_rect_replace(reporter); | 
|  1213     test_rect_inverse_fill(reporter); |  1213     test_rect_inverse_fill(reporter); | 
|  1214     test_path_replace(reporter); |  1214     test_path_replace(reporter); | 
|  1215     test_quickContains(reporter); |  1215     test_quickContains(reporter); | 
|  1216 #if SK_SUPPORT_GPU |  1216 #if SK_SUPPORT_GPU | 
|  1217     test_reduced_clip_stack(reporter); |  1217     test_reduced_clip_stack(reporter); | 
|  1218     test_reduced_clip_stack_genid(reporter); |  1218     test_reduced_clip_stack_genid(reporter); | 
|  1219     test_reduced_clip_stack_no_aa_crash(reporter); |  1219     test_reduced_clip_stack_no_aa_crash(reporter); | 
|  1220 #endif |  1220 #endif | 
|  1221 } |  1221 } | 
| OLD | NEW |