OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 8 |
9 | 9 |
10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2954 | 2954 |
2955 SkScalar cross = SkScalarMul(x1 - x0, y - pts[0].fY) - | 2955 SkScalar cross = SkScalarMul(x1 - x0, y - pts[0].fY) - |
2956 SkScalarMul(dy, x - pts[0].fX); | 2956 SkScalarMul(dy, x - pts[0].fX); |
2957 | 2957 |
2958 if (SkScalarSignAsInt(cross) == dir) { | 2958 if (SkScalarSignAsInt(cross) == dir) { |
2959 dir = 0; | 2959 dir = 0; |
2960 } | 2960 } |
2961 return dir; | 2961 return dir; |
2962 } | 2962 } |
2963 | 2963 |
2964 static bool contains_inclusive(const SkRect& r, SkScalar x, SkScalar y) { | |
robertphillips
2013/10/30 17:18:48
shouldn't that be "<= r.fBottom"?
reed1
2013/10/30 17:38:53
doh! good catch. done.
| |
2965 return r.fLeft <= x && x <= r.fRight && r.fTop <= y && y < r.fBottom; | |
2966 } | |
2967 | |
2964 bool SkPath::contains(SkScalar x, SkScalar y) const { | 2968 bool SkPath::contains(SkScalar x, SkScalar y) const { |
2965 bool isInverse = this->isInverseFillType(); | 2969 bool isInverse = this->isInverseFillType(); |
2966 if (this->isEmpty()) { | 2970 if (this->isEmpty()) { |
2967 return isInverse; | 2971 return isInverse; |
2968 } | 2972 } |
2969 | 2973 |
2970 const SkRect& bounds = this->getBounds(); | 2974 if (!contains_inclusive(this->getBounds(), x, y)) { |
2971 if (!bounds.contains(x, y)) { | |
2972 return isInverse; | 2975 return isInverse; |
2973 } | 2976 } |
2974 | 2977 |
2975 SkPath::Iter iter(*this, true); | 2978 SkPath::Iter iter(*this, true); |
2976 bool done = false; | 2979 bool done = false; |
2977 int w = 0; | 2980 int w = 0; |
2978 do { | 2981 do { |
2979 SkPoint pts[4]; | 2982 SkPoint pts[4]; |
2980 switch (iter.next(pts, false)) { | 2983 switch (iter.next(pts, false)) { |
2981 case SkPath::kMove_Verb: | 2984 case SkPath::kMove_Verb: |
(...skipping 20 matching lines...) Expand all Loading... | |
3002 switch (this->getFillType()) { | 3005 switch (this->getFillType()) { |
3003 case SkPath::kEvenOdd_FillType: | 3006 case SkPath::kEvenOdd_FillType: |
3004 case SkPath::kInverseEvenOdd_FillType: | 3007 case SkPath::kInverseEvenOdd_FillType: |
3005 w &= 1; | 3008 w &= 1; |
3006 break; | 3009 break; |
3007 default: | 3010 default: |
3008 break; | 3011 break; |
3009 } | 3012 } |
3010 return SkToBool(w); | 3013 return SkToBool(w); |
3011 } | 3014 } |
OLD | NEW |