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 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 buffer.write32(isRect ? 0 : fRunHead->fRunCount); | 1123 buffer.write32(isRect ? 0 : fRunHead->fRunCount); |
1124 buffer.write(&fBounds, sizeof(fBounds)); | 1124 buffer.write(&fBounds, sizeof(fBounds)); |
1125 | 1125 |
1126 if (!isRect) { | 1126 if (!isRect) { |
1127 buffer.write32(fRunHead->getYSpanCount()); | 1127 buffer.write32(fRunHead->getYSpanCount()); |
1128 buffer.write32(fRunHead->getIntervalCount()); | 1128 buffer.write32(fRunHead->getIntervalCount()); |
1129 buffer.write(fRunHead->readonly_runs(), | 1129 buffer.write(fRunHead->readonly_runs(), |
1130 fRunHead->fRunCount * sizeof(RunType)); | 1130 fRunHead->fRunCount * sizeof(RunType)); |
1131 } | 1131 } |
1132 } | 1132 } |
1133 return buffer.pos(); | 1133 return SkToU32(buffer.pos()); |
1134 } | 1134 } |
1135 | 1135 |
1136 uint32_t SkRegion::readFromMemory(const void* storage) { | 1136 uint32_t SkRegion::readFromMemory(const void* storage, uint32_t length) { |
1137 SkRBuffer buffer(storage); | 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 count = buffer.readS32(); |
1142 if (count >= 0) { | 1142 if (count >= 0) { |
1143 buffer.read(&tmp.fBounds, sizeof(tmp.fBounds)); | 1143 buffer.read(&tmp.fBounds, sizeof(tmp.fBounds)); |
1144 if (count == 0) { | 1144 if (count == 0) { |
1145 tmp.fRunHead = SkRegion_gRectRunHeadPtr; | 1145 tmp.fRunHead = SkRegion_gRectRunHeadPtr; |
1146 } else { | 1146 } else { |
1147 int32_t ySpanCount = buffer.readS32(); | 1147 int32_t ySpanCount = buffer.readS32(); |
1148 int32_t intervalCount = buffer.readS32(); | 1148 int32_t intervalCount = buffer.readS32(); |
1149 tmp.allocateRuns(count, ySpanCount, intervalCount); | 1149 tmp.allocateRuns(count, ySpanCount, intervalCount); |
1150 buffer.read(tmp.fRunHead->writable_runs(), count * sizeof(RunType)); | 1150 buffer.read(tmp.fRunHead->writable_runs(), count * sizeof(RunType)); |
1151 } | 1151 } |
1152 } | 1152 } |
1153 this->swap(tmp); | 1153 uint32_t sizeRead = 0; |
1154 return buffer.pos(); | 1154 if (buffer.isValid()) { |
| 1155 this->swap(tmp); |
| 1156 sizeRead = SkToU32(buffer.pos()); |
| 1157 } |
| 1158 return sizeRead; |
1155 } | 1159 } |
1156 | 1160 |
1157 /////////////////////////////////////////////////////////////////////////////// | 1161 /////////////////////////////////////////////////////////////////////////////// |
1158 | 1162 |
1159 const SkRegion& SkRegion::GetEmptyRegion() { | 1163 const SkRegion& SkRegion::GetEmptyRegion() { |
1160 static SkRegion gEmpty; | 1164 static SkRegion gEmpty; |
1161 return gEmpty; | 1165 return gEmpty; |
1162 } | 1166 } |
1163 | 1167 |
1164 /////////////////////////////////////////////////////////////////////////////// | 1168 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 bool SkRegion::debugSetRuns(const RunType runs[], int count) { | 1477 bool SkRegion::debugSetRuns(const RunType runs[], int count) { |
1474 // we need to make a copy, since the real method may modify the array, and | 1478 // we need to make a copy, since the real method may modify the array, and |
1475 // so it cannot be const. | 1479 // so it cannot be const. |
1476 | 1480 |
1477 SkAutoTArray<RunType> storage(count); | 1481 SkAutoTArray<RunType> storage(count); |
1478 memcpy(storage.get(), runs, count * sizeof(RunType)); | 1482 memcpy(storage.get(), runs, count * sizeof(RunType)); |
1479 return this->setRuns(storage.get(), count); | 1483 return this->setRuns(storage.get(), count); |
1480 } | 1484 } |
1481 | 1485 |
1482 #endif | 1486 #endif |
OLD | NEW |