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 "SkBuffer.h" | 10 #include "SkBuffer.h" |
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 #endif | 2106 #endif |
2107 | 2107 |
2108 buffer.write32(packed); | 2108 buffer.write32(packed); |
2109 | 2109 |
2110 fPathRef->writeToBuffer(&buffer); | 2110 fPathRef->writeToBuffer(&buffer); |
2111 | 2111 |
2112 buffer.padToAlign4(); | 2112 buffer.padToAlign4(); |
2113 return SkToU32(buffer.pos()); | 2113 return SkToU32(buffer.pos()); |
2114 } | 2114 } |
2115 | 2115 |
2116 uint32_t SkPath::readFromMemory(const void* storage) { | 2116 uint32_t SkPath::readFromMemory(const void* storage, uint32_t length) { |
2117 SkRBuffer buffer(storage); | 2117 SkRBufferWithSizeCheck buffer(storage, length); |
2118 | 2118 |
2119 uint32_t packed = buffer.readS32(); | 2119 uint32_t packed = buffer.readS32(); |
2120 fIsOval = (packed >> kIsOval_SerializationShift) & 1; | 2120 fIsOval = (packed >> kIsOval_SerializationShift) & 1; |
2121 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; | 2121 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; |
2122 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; | 2122 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; |
2123 fSegmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF; | 2123 fSegmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF; |
2124 fDirection = (packed >> kDirection_SerializationShift) & 0x3; | 2124 fDirection = (packed >> kDirection_SerializationShift) & 0x3; |
2125 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
O | 2125 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
O |
2126 bool newFormat = (packed >> kNewFormat_SerializationShift) & 1; | 2126 bool newFormat = (packed >> kNewFormat_SerializationShift) & 1; |
2127 #endif | 2127 #endif |
2128 | 2128 |
2129 fPathRef.reset(SkPathRef::CreateFromBuffer(&buffer | 2129 fPathRef.reset(SkPathRef::CreateFromBuffer(&buffer |
2130 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
O | 2130 #ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TO
O |
2131 , newFormat, packed) | 2131 , newFormat, packed |
2132 #endif | 2132 #endif |
2133 ); | 2133 )); |
2134 | 2134 |
2135 buffer.skipToAlign4(); | 2135 buffer.skipToAlign4(); |
2136 | 2136 |
2137 GEN_ID_INC; | 2137 GEN_ID_INC; |
2138 | 2138 |
2139 SkDEBUGCODE(this->validate();) | 2139 SkDEBUGCODE(this->validate();) |
2140 return SkToU32(buffer.pos()); | 2140 return buffer.isValid() ? SkToU32(buffer.pos()) : 0; |
2141 } | 2141 } |
2142 | 2142 |
2143 /////////////////////////////////////////////////////////////////////////////// | 2143 /////////////////////////////////////////////////////////////////////////////// |
2144 | 2144 |
2145 #include "SkString.h" | 2145 #include "SkString.h" |
2146 | 2146 |
2147 static void append_scalar(SkString* str, SkScalar value) { | 2147 static void append_scalar(SkString* str, SkScalar value) { |
2148 SkString tmp; | 2148 SkString tmp; |
2149 tmp.printf("%g", value); | 2149 tmp.printf("%g", value); |
2150 if (tmp.contains('.')) { | 2150 if (tmp.contains('.')) { |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3002 switch (this->getFillType()) { | 3002 switch (this->getFillType()) { |
3003 case SkPath::kEvenOdd_FillType: | 3003 case SkPath::kEvenOdd_FillType: |
3004 case SkPath::kInverseEvenOdd_FillType: | 3004 case SkPath::kInverseEvenOdd_FillType: |
3005 w &= 1; | 3005 w &= 1; |
3006 break; | 3006 break; |
3007 default: | 3007 default: |
3008 break; | 3008 break; |
3009 } | 3009 } |
3010 return SkToBool(w); | 3010 return SkToBool(w); |
3011 } | 3011 } |
OLD | NEW |