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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkClipStack.h" | 10 #include "SkClipStack.h" |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 855 } |
856 | 856 |
857 // but is converted to device space here | 857 // but is converted to device space here |
858 temp.offset(SkIntToScalar(offsetX), SkIntToScalar(offsetY)); | 858 temp.offset(SkIntToScalar(offsetX), SkIntToScalar(offsetY)); |
859 | 859 |
860 if (!devBounds->intersect(temp)) { | 860 if (!devBounds->intersect(temp)) { |
861 devBounds->setEmpty(); | 861 devBounds->setEmpty(); |
862 } | 862 } |
863 } | 863 } |
864 | 864 |
| 865 bool SkClipStack::isRRect(const SkRect& bounds, SkRRect* rrect, bool* aa) const
{ |
| 866 // We limit to 5 elements. This means the back element will be bounds checke
d at most 4 times if |
| 867 // it is an rrect. |
| 868 int cnt = fDeque.count(); |
| 869 if (!cnt || cnt > 5) { |
| 870 return false; |
| 871 } |
| 872 const Element* back = static_cast<const Element*>(fDeque.back()); |
| 873 if (back->getType() != SkClipStack::Element::kRect_Type && |
| 874 back->getType() != SkClipStack::Element::kRRect_Type) { |
| 875 return false; |
| 876 } |
| 877 if (back->getOp() == SkRegion::kReplace_Op) { |
| 878 *rrect = back->asRRect(); |
| 879 *aa = back->isAA(); |
| 880 return true; |
| 881 } |
| 882 |
| 883 if (back->getOp() == SkRegion::kIntersect_Op) { |
| 884 SkRect backBounds; |
| 885 if (!backBounds.intersect(bounds, back->asRRect().rect())) { |
| 886 return false; |
| 887 } |
| 888 if (cnt > 1) { |
| 889 SkDeque::Iter iter(fDeque, SkDeque::Iter::kBack_IterStart); |
| 890 SkAssertResult(static_cast<const Element*>(iter.prev()) == back); |
| 891 while (const Element* prior = (const Element*)iter.prev()) { |
| 892 if ((prior->getOp() != SkRegion::kIntersect_Op && |
| 893 prior->getOp() != SkRegion::kReplace_Op) || |
| 894 !prior->contains(backBounds)) { |
| 895 return false; |
| 896 } |
| 897 if (prior->getOp() == SkRegion::kReplace_Op) { |
| 898 break; |
| 899 } |
| 900 } |
| 901 } |
| 902 *rrect = back->asRRect(); |
| 903 *aa = back->isAA(); |
| 904 return true; |
| 905 } |
| 906 return false; |
| 907 } |
| 908 |
865 int32_t SkClipStack::GetNextGenID() { | 909 int32_t SkClipStack::GetNextGenID() { |
866 // TODO: handle overflow. | 910 // TODO: handle overflow. |
867 return sk_atomic_inc(&gGenID); | 911 return sk_atomic_inc(&gGenID); |
868 } | 912 } |
869 | 913 |
870 int32_t SkClipStack::getTopmostGenID() const { | 914 int32_t SkClipStack::getTopmostGenID() const { |
871 if (fDeque.empty()) { | 915 if (fDeque.empty()) { |
872 return kWideOpenGenID; | 916 return kWideOpenGenID; |
873 } | 917 } |
874 | 918 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 | 976 |
933 void SkClipStack::dump() const { | 977 void SkClipStack::dump() const { |
934 B2TIter iter(*this); | 978 B2TIter iter(*this); |
935 const Element* e; | 979 const Element* e; |
936 while ((e = iter.next())) { | 980 while ((e = iter.next())) { |
937 e->dump(); | 981 e->dump(); |
938 SkDebugf("\n"); | 982 SkDebugf("\n"); |
939 } | 983 } |
940 } | 984 } |
941 #endif | 985 #endif |
OLD | NEW |