| 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 #include "SkRect.h" | 9 #include "SkRect.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 void SkRect::toQuad(SkPoint quad[4]) const { | 39 void SkRect::toQuad(SkPoint quad[4]) const { |
| 40 SkASSERT(quad); | 40 SkASSERT(quad); |
| 41 | 41 |
| 42 quad[0].set(fLeft, fTop); | 42 quad[0].set(fLeft, fTop); |
| 43 quad[1].set(fRight, fTop); | 43 quad[1].set(fRight, fTop); |
| 44 quad[2].set(fRight, fBottom); | 44 quad[2].set(fRight, fBottom); |
| 45 quad[3].set(fLeft, fBottom); | 45 quad[3].set(fLeft, fBottom); |
| 46 } | 46 } |
| 47 | 47 |
| 48 //#include "Sk2x.h" | 48 #include "SkNx.h" |
| 49 #include "Sk4x.h" | |
| 50 | 49 |
| 51 static inline bool is_finite(const Sk4f& value) { | 50 static inline bool is_finite(const Sk4s& value) { |
| 52 Sk4i finite = value * Sk4f(0) == Sk4f(0); | 51 Sk4i finite = value * Sk4s(0) == Sk4s(0); |
| 53 return finite.allTrue(); | 52 return finite.allTrue(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool SkRect::setBoundsCheck(const SkPoint pts[], int count) { | 55 bool SkRect::setBoundsCheck(const SkPoint pts[], int count) { |
| 57 SkASSERT((pts && count > 0) || count == 0); | 56 SkASSERT((pts && count > 0) || count == 0); |
| 58 | 57 |
| 59 bool isFinite = true; | 58 bool isFinite = true; |
| 60 | 59 |
| 61 if (count <= 0) { | 60 if (count <= 0) { |
| 62 sk_bzero(this, sizeof(SkRect)); | 61 sk_bzero(this, sizeof(SkRect)); |
| 63 } else { | 62 } else { |
| 64 Sk4f min, max, accum; | 63 Sk4s min, max, accum; |
| 65 | 64 |
| 66 if (count & 1) { | 65 if (count & 1) { |
| 67 min = Sk4f(pts[0].fX, pts[0].fY, pts[0].fX, pts[0].fY); | 66 min = Sk4s(pts[0].fX, pts[0].fY, pts[0].fX, pts[0].fY); |
| 68 pts += 1; | 67 pts += 1; |
| 69 count -= 1; | 68 count -= 1; |
| 70 } else { | 69 } else { |
| 71 min = Sk4f::Load(&pts[0].fX); | 70 min = Sk4s::Load(&pts[0].fX); |
| 72 pts += 2; | 71 pts += 2; |
| 73 count -= 2; | 72 count -= 2; |
| 74 } | 73 } |
| 75 accum = max = min; | 74 accum = max = min; |
| 76 accum *= Sk4f(0); | 75 accum *= Sk4s(0); |
| 77 | 76 |
| 78 count >>= 1; | 77 count >>= 1; |
| 79 for (int i = 0; i < count; ++i) { | 78 for (int i = 0; i < count; ++i) { |
| 80 Sk4f xy = Sk4f::Load(&pts->fX); | 79 Sk4s xy = Sk4s::Load(&pts->fX); |
| 81 accum *= xy; | 80 accum *= xy; |
| 82 min = Sk4f::Min(min, xy); | 81 min = Sk4s::Min(min, xy); |
| 83 max = Sk4f::Max(max, xy); | 82 max = Sk4s::Max(max, xy); |
| 84 pts += 2; | 83 pts += 2; |
| 85 } | 84 } |
| 86 | 85 |
| 87 /** | 86 /** |
| 88 * With some trickery, we may be able to use Min/Max to also propogate
non-finites, | 87 * With some trickery, we may be able to use Min/Max to also propogate
non-finites, |
| 89 * in which case we could eliminate accum entirely, and just check min
and max for | 88 * in which case we could eliminate accum entirely, and just check min
and max for |
| 90 * "is_finite". | 89 * "is_finite". |
| 91 */ | 90 */ |
| 92 if (is_finite(accum)) { | 91 if (is_finite(accum)) { |
| 93 float minArray[4], maxArray[4]; | 92 float minArray[4], maxArray[4]; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 SkString strL, strT, strR, strB; | 168 SkString strL, strT, strR, strB; |
| 170 SkAppendScalarDec(&strL, fLeft); | 169 SkAppendScalarDec(&strL, fLeft); |
| 171 SkAppendScalarDec(&strT, fTop); | 170 SkAppendScalarDec(&strT, fTop); |
| 172 SkAppendScalarDec(&strR, fRight); | 171 SkAppendScalarDec(&strR, fRight); |
| 173 SkAppendScalarDec(&strB, fBottom); | 172 SkAppendScalarDec(&strB, fBottom); |
| 174 line.printf("SkRect::MakeLTRB(%s, %s, %s, %s);", | 173 line.printf("SkRect::MakeLTRB(%s, %s, %s, %s);", |
| 175 strL.c_str(), strT.c_str(), strR.c_str(), strB.c_str()); | 174 strL.c_str(), strT.c_str(), strR.c_str(), strB.c_str()); |
| 176 } | 175 } |
| 177 SkDebugf("%s\n", line.c_str()); | 176 SkDebugf("%s\n", line.c_str()); |
| 178 } | 177 } |
| OLD | NEW |