| 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 "SkOnce.h" |    9 #include "SkOnce.h" | 
|   10 #include "SkPath.h" |   10 #include "SkPath.h" | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  105  |  105  | 
|  106 SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer |  106 SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer | 
|  107 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O |  107 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O | 
|  108                                    , bool newFormat, int32_t oldPacked |  108                                    , bool newFormat, int32_t oldPacked | 
|  109 #endif |  109 #endif | 
|  110     ) { |  110     ) { | 
|  111     SkPathRef* ref = SkNEW(SkPathRef); |  111     SkPathRef* ref = SkNEW(SkPathRef); | 
|  112 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O |  112 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O | 
|  113     if (newFormat) { |  113     if (newFormat) { | 
|  114 #endif |  114 #endif | 
|  115         int32_t packed = buffer->readU32(); |  115         int32_t packed; | 
 |  116         if (!buffer->readS32(&packed)) { | 
 |  117             SkDELETE(ref); | 
 |  118             return NULL; | 
 |  119         } | 
|  116  |  120  | 
|  117         ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1; |  121         ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1; | 
|  118 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O |  122 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
     O | 
|  119     } else { |  123     } else { | 
|  120         ref->fIsFinite = (oldPacked >> SkPath::kOldIsFinite_SerializationShift) 
     & 1; |  124         ref->fIsFinite = (oldPacked >> SkPath::kOldIsFinite_SerializationShift) 
     & 1; | 
|  121     } |  125     } | 
|  122 #endif |  126 #endif | 
|  123  |  127  | 
|  124     ref->fGenerationID = buffer->readU32(); |  128     int32_t verbCount, pointCount, conicCount; | 
|  125     int32_t verbCount = buffer->readS32(); |  129     if (!buffer->readU32(&(ref->fGenerationID)) || | 
|  126     int32_t pointCount = buffer->readS32(); |  130         !buffer->readS32(&verbCount) || | 
|  127     int32_t conicCount = buffer->readS32(); |  131         !buffer->readS32(&pointCount) || | 
 |  132         !buffer->readS32(&conicCount)) { | 
 |  133         SkDELETE(ref); | 
 |  134         return NULL; | 
 |  135     } | 
 |  136  | 
|  128     ref->resetToSize(verbCount, pointCount, conicCount); |  137     ref->resetToSize(verbCount, pointCount, conicCount); | 
|  129  |  | 
|  130     SkASSERT(verbCount == ref->countVerbs()); |  138     SkASSERT(verbCount == ref->countVerbs()); | 
|  131     SkASSERT(pointCount == ref->countPoints()); |  139     SkASSERT(pointCount == ref->countPoints()); | 
|  132     SkASSERT(conicCount == ref->fConicWeights.count()); |  140     SkASSERT(conicCount == ref->fConicWeights.count()); | 
|  133     buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)); |  141  | 
|  134     buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)); |  142     if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) || | 
|  135     buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)); |  143         !buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) || | 
|  136     buffer->read(&ref->fBounds, sizeof(SkRect)); |  144         !buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar))
      || | 
 |  145         !buffer->read(&ref->fBounds, sizeof(SkRect))) { | 
 |  146         SkDELETE(ref); | 
 |  147         return NULL; | 
 |  148     } | 
|  137     ref->fBoundsIsDirty = false; |  149     ref->fBoundsIsDirty = false; | 
|  138     return ref; |  150     return ref; | 
|  139 } |  151 } | 
|  140  |  152  | 
|  141 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { |  153 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { | 
|  142     if ((*pathRef)->unique()) { |  154     if ((*pathRef)->unique()) { | 
|  143         SkDEBUGCODE((*pathRef)->validate();) |  155         SkDEBUGCODE((*pathRef)->validate();) | 
|  144         (*pathRef)->fBoundsIsDirty = true;  // this also invalidates fIsFinite |  156         (*pathRef)->fBoundsIsDirty = true;  // this also invalidates fIsFinite | 
|  145         (*pathRef)->fVerbCnt = 0; |  157         (*pathRef)->fVerbCnt = 0; | 
|  146         (*pathRef)->fPointCnt = 0; |  158         (*pathRef)->fPointCnt = 0; | 
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  330                      fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); |  342                      fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); | 
|  331             if (!fPoints[i].isFinite()) { |  343             if (!fPoints[i].isFinite()) { | 
|  332                 isFinite = false; |  344                 isFinite = false; | 
|  333             } |  345             } | 
|  334         } |  346         } | 
|  335         SkASSERT(SkToBool(fIsFinite) == isFinite); |  347         SkASSERT(SkToBool(fIsFinite) == isFinite); | 
|  336     } |  348     } | 
|  337 #endif |  349 #endif | 
|  338 } |  350 } | 
|  339 #endif |  351 #endif | 
| OLD | NEW |