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