OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "SkAtomics.h" | 9 #include "SkAtomics.h" |
10 #include "SkRegionPriv.h" | 10 #include "SkRegionPriv.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 while (!iter.done()) { | 189 while (!iter.done()) { |
190 count++; | 190 count++; |
191 iter.next(); | 191 iter.next(); |
192 } | 192 } |
193 // 4 ints, up to 10 digits each plus sign, 3 commas, '(', ')', SkRegion() an
d '\0' | 193 // 4 ints, up to 10 digits each plus sign, 3 commas, '(', ')', SkRegion() an
d '\0' |
194 const int max = (count*((11*4)+5))+11+1; | 194 const int max = (count*((11*4)+5))+11+1; |
195 char* result = (char*)sk_malloc_throw(max); | 195 char* result = (char*)sk_malloc_throw(max); |
196 if (result == nullptr) { | 196 if (result == nullptr) { |
197 return nullptr; | 197 return nullptr; |
198 } | 198 } |
199 count = sprintf(result, "SkRegion("); | 199 count = snprintf(result, max, "SkRegion("); |
200 iter.reset(*this); | 200 iter.reset(*this); |
201 while (!iter.done()) { | 201 while (!iter.done()) { |
202 const SkIRect& r = iter.rect(); | 202 const SkIRect& r = iter.rect(); |
203 count += sprintf(result+count, "(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRigh
t, r.fBottom); | 203 count += snprintf(result+count, max - count, |
| 204 "(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRight, r.fBottom); |
204 iter.next(); | 205 iter.next(); |
205 } | 206 } |
206 count += sprintf(result+count, ")"); | 207 count += snprintf(result+count, max - count, ")"); |
207 return result; | 208 return result; |
208 } | 209 } |
209 #endif | 210 #endif |
210 | 211 |
211 /////////////////////////////////////////////////////////////////////////////// | 212 /////////////////////////////////////////////////////////////////////////////// |
212 | 213 |
213 int SkRegion::count_runtype_values(int* itop, int* ibot) const { | 214 int SkRegion::count_runtype_values(int* itop, int* ibot) const { |
214 int maxT; | 215 int maxT; |
215 | 216 |
216 if (this->isRect()) { | 217 if (this->isRect()) { |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 bool SkRegion::debugSetRuns(const RunType runs[], int count) { | 1471 bool SkRegion::debugSetRuns(const RunType runs[], int count) { |
1471 // we need to make a copy, since the real method may modify the array, and | 1472 // we need to make a copy, since the real method may modify the array, and |
1472 // so it cannot be const. | 1473 // so it cannot be const. |
1473 | 1474 |
1474 SkAutoTArray<RunType> storage(count); | 1475 SkAutoTArray<RunType> storage(count); |
1475 memcpy(storage.get(), runs, count * sizeof(RunType)); | 1476 memcpy(storage.get(), runs, count * sizeof(RunType)); |
1476 return this->setRuns(storage.get(), count); | 1477 return this->setRuns(storage.get(), count); |
1477 } | 1478 } |
1478 | 1479 |
1479 #endif | 1480 #endif |
OLD | NEW |