OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #include "SkRegionPriv.h" | 8 #include "SkRegionPriv.h" |
11 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
12 #include "SkScan.h" | 10 #include "SkScan.h" |
13 #include "SkTDArray.h" | 11 #include "SkTDArray.h" |
14 #include "SkPath.h" | 12 #include "SkPath.h" |
15 | 13 |
| 14 // The rgnbuilder caller *seems* to pass short counts, possible often seens earl
y failure, so |
| 15 // we may not want to promote this to a "std" routine just yet. |
| 16 static bool sk_memeq32(const int32_t* SK_RESTRICT a, const int32_t* SK_RESTRICT
b, int count) { |
| 17 for (int i = 0; i < count; ++i) { |
| 18 if (a[i] != b[i]) { |
| 19 return false; |
| 20 } |
| 21 } |
| 22 return true; |
| 23 } |
| 24 |
16 class SkRgnBuilder : public SkBlitter { | 25 class SkRgnBuilder : public SkBlitter { |
17 public: | 26 public: |
18 SkRgnBuilder(); | 27 SkRgnBuilder(); |
19 virtual ~SkRgnBuilder(); | 28 virtual ~SkRgnBuilder(); |
20 | 29 |
21 // returns true if it could allocate the working storage needed | 30 // returns true if it could allocate the working storage needed |
22 bool init(int maxHeight, int maxTransitions, bool pathIsInverse); | 31 bool init(int maxHeight, int maxTransitions, bool pathIsInverse); |
23 | 32 |
24 void done() { | 33 void done() { |
25 if (fCurrScanline != NULL) { | 34 if (fCurrScanline != NULL) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // points at next avialable x[] in fCurrScanline | 89 // points at next avialable x[] in fCurrScanline |
81 SkRegion::RunType* fCurrXPtr; | 90 SkRegion::RunType* fCurrXPtr; |
82 SkRegion::RunType fTop; // first Y value | 91 SkRegion::RunType fTop; // first Y value |
83 | 92 |
84 int fStorageCount; | 93 int fStorageCount; |
85 | 94 |
86 bool collapsWithPrev() { | 95 bool collapsWithPrev() { |
87 if (fPrevScanline != NULL && | 96 if (fPrevScanline != NULL && |
88 fPrevScanline->fLastY + 1 == fCurrScanline->fLastY && | 97 fPrevScanline->fLastY + 1 == fCurrScanline->fLastY && |
89 fPrevScanline->fXCount == fCurrScanline->fXCount && | 98 fPrevScanline->fXCount == fCurrScanline->fXCount && |
90 !memcmp(fPrevScanline->firstX(), | 99 sk_memeq32(fPrevScanline->firstX(), fCurrScanline->firstX(), fCurrSc
anline->fXCount)) |
91 fCurrScanline->firstX(), | |
92 fCurrScanline->fXCount * sizeof(SkRegion::RunType))) | |
93 { | 100 { |
94 // update the height of fPrevScanline | 101 // update the height of fPrevScanline |
95 fPrevScanline->fLastY = fCurrScanline->fLastY; | 102 fPrevScanline->fLastY = fCurrScanline->fLastY; |
96 return true; | 103 return true; |
97 } | 104 } |
98 return false; | 105 return false; |
99 } | 106 } |
100 }; | 107 }; |
101 | 108 |
102 SkRgnBuilder::SkRgnBuilder() | 109 SkRgnBuilder::SkRgnBuilder() |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 #endif | 518 #endif |
512 | 519 |
513 path->incReserve(count << 1); | 520 path->incReserve(count << 1); |
514 do { | 521 do { |
515 SkASSERT(count > 1); | 522 SkASSERT(count > 1); |
516 count -= extract_path(start, stop, path); | 523 count -= extract_path(start, stop, path); |
517 } while (count > 0); | 524 } while (count > 0); |
518 | 525 |
519 return true; | 526 return true; |
520 } | 527 } |
OLD | NEW |