| 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 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 | 1093 |
| 1094 bool SkRegion::op(const SkRegion& rgna, const SkRegion& rgnb, Op op) { | 1094 bool SkRegion::op(const SkRegion& rgna, const SkRegion& rgnb, Op op) { |
| 1095 SkDEBUGCODE(this->validate();) | 1095 SkDEBUGCODE(this->validate();) |
| 1096 return SkRegion::Oper(rgna, rgnb, op, this); | 1096 return SkRegion::Oper(rgna, rgnb, op, this); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 /////////////////////////////////////////////////////////////////////////////// | 1099 /////////////////////////////////////////////////////////////////////////////// |
| 1100 | 1100 |
| 1101 #include "SkBuffer.h" | 1101 #include "SkBuffer.h" |
| 1102 | 1102 |
| 1103 uint32_t SkRegion::writeToMemory(void* storage) const { | 1103 size_t SkRegion::writeToMemory(void* storage) const { |
| 1104 if (NULL == storage) { | 1104 if (NULL == storage) { |
| 1105 uint32_t size = sizeof(int32_t); // -1 (empty), 0 (rect), runCount | 1105 size_t size = sizeof(int32_t); // -1 (empty), 0 (rect), runCount |
| 1106 if (!this->isEmpty()) { | 1106 if (!this->isEmpty()) { |
| 1107 size += sizeof(fBounds); | 1107 size += sizeof(fBounds); |
| 1108 if (this->isComplex()) { | 1108 if (this->isComplex()) { |
| 1109 size += 2 * sizeof(int32_t); // ySpanCount + intervalCount | 1109 size += 2 * sizeof(int32_t); // ySpanCount + intervalCount |
| 1110 size += fRunHead->fRunCount * sizeof(RunType); | 1110 size += fRunHead->fRunCount * sizeof(RunType); |
| 1111 } | 1111 } |
| 1112 } | 1112 } |
| 1113 return size; | 1113 return size; |
| 1114 } | 1114 } |
| 1115 | 1115 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 buffer.pos(); |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 uint32_t SkRegion::readFromMemory(const void* storage) { | 1136 size_t SkRegion::readFromMemory(const void* storage, size_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 size_t sizeRead = 0; |
| 1154 return buffer.pos(); | 1154 if (buffer.isValid()) { |
| 1155 this->swap(tmp); |
| 1156 sizeRead = 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 |