| 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 "SkRegionPriv.h" | 10 #include "SkRegionPriv.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 SkRgnBuilder::~SkRgnBuilder() { | 101 SkRgnBuilder::~SkRgnBuilder() { |
| 102 sk_free(fStorage); | 102 sk_free(fStorage); |
| 103 } | 103 } |
| 104 | 104 |
| 105 bool SkRgnBuilder::init(int maxHeight, int maxTransitions, bool pathIsInverse) { | 105 bool SkRgnBuilder::init(int maxHeight, int maxTransitions, bool pathIsInverse) { |
| 106 if ((maxHeight | maxTransitions) < 0) { | 106 if ((maxHeight | maxTransitions) < 0) { |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 | 109 |
| 110 Sk64 count, size; |
| 111 |
| 110 if (pathIsInverse) { | 112 if (pathIsInverse) { |
| 111 // allow for additional X transitions to "invert" each scanline | 113 // allow for additional X transitions to "invert" each scanline |
| 112 // [ L' ... normal transitions ... R' ] | 114 // [ L' ... normal transitions ... R' ] |
| 113 // | 115 // |
| 114 maxTransitions += 2; | 116 maxTransitions += 2; |
| 115 } | 117 } |
| 116 | 118 |
| 117 // compute the count with +1 and +3 slop for the working buffer | 119 // compute the count with +1 and +3 slop for the working buffer |
| 118 int64_t count = sk_64_mul(maxHeight + 1, 3 + maxTransitions); | 120 count.setMul(maxHeight + 1, 3 + maxTransitions); |
| 119 | 121 |
| 120 if (pathIsInverse) { | 122 if (pathIsInverse) { |
| 121 // allow for two "empty" rows for the top and bottom | 123 // allow for two "empty" rows for the top and bottom |
| 122 // [ Y, 1, L, R, S] == 5 (*2 for top and bottom) | 124 // [ Y, 1, L, R, S] == 5 (*2 for top and bottom) |
| 123 count += 10; | 125 count.add(10); |
| 124 } | 126 } |
| 125 | 127 |
| 126 if (count < 0 || !sk_64_isS32(count)) { | 128 if (!count.is32() || count.isNeg()) { |
| 127 return false; | 129 return false; |
| 128 } | 130 } |
| 129 fStorageCount = sk_64_asS32(count); | 131 fStorageCount = count.get32(); |
| 130 | 132 |
| 131 int64_t size = sk_64_mul(fStorageCount, sizeof(SkRegion::RunType)); | 133 size.setMul(fStorageCount, sizeof(SkRegion::RunType)); |
| 132 if (size < 0 || !sk_64_isS32(size)) { | 134 if (!size.is32() || size.isNeg()) { |
| 133 return false; | 135 return false; |
| 134 } | 136 } |
| 135 | 137 |
| 136 fStorage = (SkRegion::RunType*)sk_malloc_flags(sk_64_asS32(size), 0); | 138 fStorage = (SkRegion::RunType*)sk_malloc_flags(size.get32(), 0); |
| 137 if (NULL == fStorage) { | 139 if (NULL == fStorage) { |
| 138 return false; | 140 return false; |
| 139 } | 141 } |
| 140 | 142 |
| 141 fCurrScanline = NULL; // signal empty collection | 143 fCurrScanline = NULL; // signal empty collection |
| 142 fPrevScanline = NULL; // signal first scanline | 144 fPrevScanline = NULL; // signal first scanline |
| 143 return true; | 145 return true; |
| 144 } | 146 } |
| 145 | 147 |
| 146 void SkRgnBuilder::blitH(int x, int y, int width) { | 148 void SkRgnBuilder::blitH(int x, int y, int width) { |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 #endif | 508 #endif |
| 507 | 509 |
| 508 path->incReserve(count << 1); | 510 path->incReserve(count << 1); |
| 509 do { | 511 do { |
| 510 SkASSERT(count > 1); | 512 SkASSERT(count > 1); |
| 511 count -= extract_path(start, stop, path); | 513 count -= extract_path(start, stop, path); |
| 512 } while (count > 0); | 514 } while (count > 0); |
| 513 | 515 |
| 514 return true; | 516 return true; |
| 515 } | 517 } |
| OLD | NEW |