OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 #include "SkBuffer.h" | 8 #include "SkBuffer.h" |
9 #include "SkFlattenableBuffers.h" | |
9 #include "SkOnce.h" | 10 #include "SkOnce.h" |
10 #include "SkPath.h" | 11 #include "SkPath.h" |
11 #include "SkPathRef.h" | 12 #include "SkPathRef.h" |
12 | 13 |
13 SK_DEFINE_INST_COUNT(SkPathRef); | 14 SK_DEFINE_INST_COUNT(SkPathRef); |
14 | 15 |
15 ////////////////////////////////////////////////////////////////////////////// | 16 ////////////////////////////////////////////////////////////////////////////// |
16 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, | 17 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef, |
17 int incReserveVerbs, | 18 int incReserveVerbs, |
18 int incReservePoints) | 19 int incReservePoints) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 SkASSERT(pointCount == ref->countPoints()); | 132 SkASSERT(pointCount == ref->countPoints()); |
132 SkASSERT(conicCount == ref->fConicWeights.count()); | 133 SkASSERT(conicCount == ref->fConicWeights.count()); |
133 buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)); | 134 buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)); |
134 buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)); | 135 buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)); |
135 buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)); | 136 buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)); |
136 buffer->read(&ref->fBounds, sizeof(SkRect)); | 137 buffer->read(&ref->fBounds, sizeof(SkRect)); |
137 ref->fBoundsIsDirty = false; | 138 ref->fBoundsIsDirty = false; |
138 return ref; | 139 return ref; |
139 } | 140 } |
140 | 141 |
142 uint32_t SkPathRef::SizeToRead(SkFlattenableReadBuffer& buffer | |
143 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O | |
144 , bool newFormat | |
145 #endif | |
146 ) { | |
147 uint32_t size = 4 * sizeof(uint32_t) + // fGenerationID, verbCount, pointCou nt, conicCount | |
148 sizeof(SkRect); // fBounds | |
149 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O | |
150 if (newFormat) { | |
151 #endif | |
152 size += sizeof(uint32_t); | |
153 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO O | |
154 } | |
155 #endif | |
156 | |
157 // TODO: Figure out a way to read verbCount, pointCount, conicCount without | |
158 // the buffer's peek forward (while making sure we can read these valu es) | |
sugoi1
2013/10/24 19:51:39
This isn't completed yet. I need some suggestions.
| |
159 | |
160 return size; | |
161 } | |
162 | |
141 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { | 163 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { |
142 if ((*pathRef)->unique()) { | 164 if ((*pathRef)->unique()) { |
143 SkDEBUGCODE((*pathRef)->validate();) | 165 SkDEBUGCODE((*pathRef)->validate();) |
144 (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite | 166 (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite |
145 (*pathRef)->fVerbCnt = 0; | 167 (*pathRef)->fVerbCnt = 0; |
146 (*pathRef)->fPointCnt = 0; | 168 (*pathRef)->fPointCnt = 0; |
147 (*pathRef)->fFreeSpace = (*pathRef)->currSize(); | 169 (*pathRef)->fFreeSpace = (*pathRef)->currSize(); |
148 (*pathRef)->fGenerationID = 0; | 170 (*pathRef)->fGenerationID = 0; |
149 (*pathRef)->fConicWeights.rewind(); | 171 (*pathRef)->fConicWeights.rewind(); |
150 SkDEBUGCODE((*pathRef)->validate();) | 172 SkDEBUGCODE((*pathRef)->validate();) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); | 351 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); |
330 if (!fPoints[i].isFinite()) { | 352 if (!fPoints[i].isFinite()) { |
331 isFinite = false; | 353 isFinite = false; |
332 } | 354 } |
333 } | 355 } |
334 SkASSERT(SkToBool(fIsFinite) == isFinite); | 356 SkASSERT(SkToBool(fIsFinite) == isFinite); |
335 } | 357 } |
336 #endif | 358 #endif |
337 } | 359 } |
338 #endif | 360 #endif |
OLD | NEW |