Chromium Code Reviews| 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 #define SK_USE_INLINE_MEMEQ32 | |
| 15 | |
| 16 static bool sk_memeq32(const int32_t* SK_RESTRICT a, const int32_t* SK_RESTRICT b, int count) { | |
| 17 #ifdef SK_USE_INLINE_MEMEQ32 | |
| 18 #if 0 | |
|
Tom Hudson
2014/06/20 18:50:05
Nit: would we want to replace 10 lines of dead cod
mtklein
2014/06/20 19:20:38
We _could_ write this with SSE or Neon, and SSE wo
| |
| 19 const int count4 = count >> 2; | |
| 20 for (int i = 0; i < count4; ++i) { | |
| 21 if ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3])) { | |
| 22 return false; | |
| 23 } | |
| 24 a += 4; | |
| 25 b += 4; | |
| 26 } | |
| 27 count &= 3; | |
| 28 #endif | |
| 29 for (int i = 0; i < count; ++i) { | |
| 30 if (a[i] != b[i]) { | |
| 31 return false; | |
| 32 } | |
| 33 } | |
| 34 return true; | |
| 35 #else | |
| 36 return !memcmp(a, b, count << 2); | |
|
Tom Hudson
2014/06/20 18:50:05
Nit: * sizeof(int32_t) is a little more intelligib
| |
| 37 #endif | |
| 38 } | |
| 39 | |
| 16 class SkRgnBuilder : public SkBlitter { | 40 class SkRgnBuilder : public SkBlitter { |
| 17 public: | 41 public: |
| 18 SkRgnBuilder(); | 42 SkRgnBuilder(); |
| 19 virtual ~SkRgnBuilder(); | 43 virtual ~SkRgnBuilder(); |
| 20 | 44 |
| 21 // returns true if it could allocate the working storage needed | 45 // returns true if it could allocate the working storage needed |
| 22 bool init(int maxHeight, int maxTransitions, bool pathIsInverse); | 46 bool init(int maxHeight, int maxTransitions, bool pathIsInverse); |
| 23 | 47 |
| 24 void done() { | 48 void done() { |
| 25 if (fCurrScanline != NULL) { | 49 if (fCurrScanline != NULL) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // points at next avialable x[] in fCurrScanline | 104 // points at next avialable x[] in fCurrScanline |
| 81 SkRegion::RunType* fCurrXPtr; | 105 SkRegion::RunType* fCurrXPtr; |
| 82 SkRegion::RunType fTop; // first Y value | 106 SkRegion::RunType fTop; // first Y value |
| 83 | 107 |
| 84 int fStorageCount; | 108 int fStorageCount; |
| 85 | 109 |
| 86 bool collapsWithPrev() { | 110 bool collapsWithPrev() { |
| 87 if (fPrevScanline != NULL && | 111 if (fPrevScanline != NULL && |
| 88 fPrevScanline->fLastY + 1 == fCurrScanline->fLastY && | 112 fPrevScanline->fLastY + 1 == fCurrScanline->fLastY && |
| 89 fPrevScanline->fXCount == fCurrScanline->fXCount && | 113 fPrevScanline->fXCount == fCurrScanline->fXCount && |
| 90 !memcmp(fPrevScanline->firstX(), | 114 sk_memeq32(fPrevScanline->firstX(), fCurrScanline->firstX(), fCurrSc anline->fXCount)) |
| 91 fCurrScanline->firstX(), | |
| 92 fCurrScanline->fXCount * sizeof(SkRegion::RunType))) | |
| 93 { | 115 { |
| 94 // update the height of fPrevScanline | 116 // update the height of fPrevScanline |
| 95 fPrevScanline->fLastY = fCurrScanline->fLastY; | 117 fPrevScanline->fLastY = fCurrScanline->fLastY; |
| 96 return true; | 118 return true; |
| 97 } | 119 } |
| 98 return false; | 120 return false; |
| 99 } | 121 } |
| 100 }; | 122 }; |
| 101 | 123 |
| 102 SkRgnBuilder::SkRgnBuilder() | 124 SkRgnBuilder::SkRgnBuilder() |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 #endif | 533 #endif |
| 512 | 534 |
| 513 path->incReserve(count << 1); | 535 path->incReserve(count << 1); |
| 514 do { | 536 do { |
| 515 SkASSERT(count > 1); | 537 SkASSERT(count > 1); |
| 516 count -= extract_path(start, stop, path); | 538 count -= extract_path(start, stop, path); |
| 517 } while (count > 0); | 539 } while (count > 0); |
| 518 | 540 |
| 519 return true; | 541 return true; |
| 520 } | 542 } |
| OLD | NEW |