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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 size_t SkRegion::readFromMemory(const void* storage, size_t length) { | 1129 size_t SkRegion::readFromMemory(const void* storage, size_t length) { |
1130 SkRBufferWithSizeCheck buffer(storage, length); | 1130 SkRBufferWithSizeCheck buffer(storage, length); |
1131 SkRegion tmp; | 1131 SkRegion tmp; |
1132 int32_t count; | 1132 int32_t count; |
1133 | 1133 |
1134 if (buffer.readS32(&count) && (count >= 0) && buffer.read(&tmp.fBounds, size
of(tmp.fBounds))) { | 1134 if (buffer.readS32(&count) && (count >= 0) && buffer.read(&tmp.fBounds, size
of(tmp.fBounds))) { |
1135 if (count == 0) { | 1135 if (count == 0) { |
1136 tmp.fRunHead = SkRegion_gRectRunHeadPtr; | 1136 tmp.fRunHead = SkRegion_gRectRunHeadPtr; |
1137 } else { | 1137 } else { |
1138 int32_t ySpanCount, intervalCount; | 1138 int32_t ySpanCount, intervalCount; |
1139 if (buffer.readS32(&ySpanCount) && buffer.readS32(&intervalCount)) { | 1139 if (buffer.readS32(&ySpanCount) && buffer.readS32(&intervalCount) && |
| 1140 intervalCount > 1) { |
1140 tmp.allocateRuns(count, ySpanCount, intervalCount); | 1141 tmp.allocateRuns(count, ySpanCount, intervalCount); |
1141 buffer.read(tmp.fRunHead->writable_runs(), count * sizeof(RunTyp
e)); | 1142 buffer.read(tmp.fRunHead->writable_runs(), count * sizeof(RunTyp
e)); |
1142 } | 1143 } |
1143 } | 1144 } |
1144 } | 1145 } |
1145 size_t sizeRead = 0; | 1146 size_t sizeRead = 0; |
1146 if (buffer.isValid()) { | 1147 if (buffer.isValid()) { |
1147 this->swap(tmp); | 1148 this->swap(tmp); |
1148 sizeRead = buffer.pos(); | 1149 sizeRead = buffer.pos(); |
1149 } | 1150 } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 bool SkRegion::debugSetRuns(const RunType runs[], int count) { | 1470 bool SkRegion::debugSetRuns(const RunType runs[], int count) { |
1470 // we need to make a copy, since the real method may modify the array, and | 1471 // we need to make a copy, since the real method may modify the array, and |
1471 // so it cannot be const. | 1472 // so it cannot be const. |
1472 | 1473 |
1473 SkAutoTArray<RunType> storage(count); | 1474 SkAutoTArray<RunType> storage(count); |
1474 memcpy(storage.get(), runs, count * sizeof(RunType)); | 1475 memcpy(storage.get(), runs, count * sizeof(RunType)); |
1475 return this->setRuns(storage.get(), count); | 1476 return this->setRuns(storage.get(), count); |
1476 } | 1477 } |
1477 | 1478 |
1478 #endif | 1479 #endif |
OLD | NEW |