Chromium Code Reviews| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 { | 133 { |
| 134 this->resetFields(); | 134 this->resetFields(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void SkPath::resetFields() { | 137 void SkPath::resetFields() { |
| 138 //fPathRef is assumed to have been emptied by the caller. | 138 //fPathRef is assumed to have been emptied by the caller. |
| 139 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; | 139 fLastMoveToIndex = INITIAL_LASTMOVETOINDEX_VALUE; |
| 140 fFillType = kWinding_FillType; | 140 fFillType = kWinding_FillType; |
| 141 fConvexity = kUnknown_Convexity; | 141 fConvexity = kUnknown_Convexity; |
| 142 fDirection = kUnknown_Direction; | 142 fDirection = kUnknown_Direction; |
| 143 fIsVolatile = false; | |
|
bsalomon
2014/10/23 17:54:08
I wonder if this is correct. rewind() and reset()
jvanverth1
2014/10/23 20:06:18
Done.
| |
| 143 | 144 |
| 144 // We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we | 145 // We don't touch Android's fSourcePath. It's used to track texture garbage collection, so we |
| 145 // don't want to muck with it if it's been set to something non-NULL. | 146 // don't want to muck with it if it's been set to something non-NULL. |
| 146 } | 147 } |
| 147 | 148 |
| 148 SkPath::SkPath(const SkPath& that) | 149 SkPath::SkPath(const SkPath& that) |
| 149 : fPathRef(SkRef(that.fPathRef.get())) { | 150 : fPathRef(SkRef(that.fPathRef.get())) { |
| 150 this->copyFields(that); | 151 this->copyFields(that); |
| 151 #ifdef SK_BUILD_FOR_ANDROID | 152 #ifdef SK_BUILD_FOR_ANDROID |
| 152 fSourcePath = that.fSourcePath; | 153 fSourcePath = that.fSourcePath; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 171 SkDEBUGCODE(this->validate();) | 172 SkDEBUGCODE(this->validate();) |
| 172 return *this; | 173 return *this; |
| 173 } | 174 } |
| 174 | 175 |
| 175 void SkPath::copyFields(const SkPath& that) { | 176 void SkPath::copyFields(const SkPath& that) { |
| 176 //fPathRef is assumed to have been set by the caller. | 177 //fPathRef is assumed to have been set by the caller. |
| 177 fLastMoveToIndex = that.fLastMoveToIndex; | 178 fLastMoveToIndex = that.fLastMoveToIndex; |
| 178 fFillType = that.fFillType; | 179 fFillType = that.fFillType; |
| 179 fConvexity = that.fConvexity; | 180 fConvexity = that.fConvexity; |
| 180 fDirection = that.fDirection; | 181 fDirection = that.fDirection; |
| 182 fIsVolatile = that.fIsVolatile; | |
| 181 } | 183 } |
| 182 | 184 |
| 183 bool operator==(const SkPath& a, const SkPath& b) { | 185 bool operator==(const SkPath& a, const SkPath& b) { |
| 184 // note: don't need to look at isConvex or bounds, since just comparing the | 186 // note: don't need to look at isConvex or bounds, since just comparing the |
| 185 // raw data is sufficient. | 187 // raw data is sufficient. |
| 186 return &a == &b || | 188 return &a == &b || |
| 187 (a.fFillType == b.fFillType && *a.fPathRef.get() == *b.fPathRef.get()); | 189 (a.fFillType == b.fFillType && *a.fPathRef.get() == *b.fPathRef.get()); |
| 188 } | 190 } |
| 189 | 191 |
| 190 void SkPath::swap(SkPath& that) { | 192 void SkPath::swap(SkPath& that) { |
| 191 SkASSERT(&that != NULL); | 193 SkASSERT(&that != NULL); |
| 192 | 194 |
| 193 if (this != &that) { | 195 if (this != &that) { |
| 194 fPathRef.swap(&that.fPathRef); | 196 fPathRef.swap(&that.fPathRef); |
| 195 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex); | 197 SkTSwap<int>(fLastMoveToIndex, that.fLastMoveToIndex); |
| 196 SkTSwap<uint8_t>(fFillType, that.fFillType); | 198 SkTSwap<uint8_t>(fFillType, that.fFillType); |
| 197 SkTSwap<uint8_t>(fConvexity, that.fConvexity); | 199 SkTSwap<uint8_t>(fConvexity, that.fConvexity); |
| 198 SkTSwap<uint8_t>(fDirection, that.fDirection); | 200 SkTSwap<uint8_t>(fDirection, that.fDirection); |
| 201 SkTSwap<SkBool8>(fIsVolatile, that.fIsVolatile); | |
| 199 #ifdef SK_BUILD_FOR_ANDROID | 202 #ifdef SK_BUILD_FOR_ANDROID |
| 200 SkTSwap<const SkPath*>(fSourcePath, that.fSourcePath); | 203 SkTSwap<const SkPath*>(fSourcePath, that.fSourcePath); |
| 201 #endif | 204 #endif |
| 202 } | 205 } |
| 203 } | 206 } |
| 204 | 207 |
| 205 static inline bool check_edge_against_rect(const SkPoint& p0, | 208 static inline bool check_edge_against_rect(const SkPoint& p0, |
| 206 const SkPoint& p1, | 209 const SkPoint& p1, |
| 207 const SkRect& rect, | 210 const SkRect& rect, |
| 208 SkPath::Direction dir) { | 211 SkPath::Direction dir) { |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1599 dst->swap(tmp); | 1602 dst->swap(tmp); |
| 1600 SkPathRef::Editor ed(&dst->fPathRef); | 1603 SkPathRef::Editor ed(&dst->fPathRef); |
| 1601 matrix.mapPoints(ed.points(), ed.pathRef()->countPoints()); | 1604 matrix.mapPoints(ed.points(), ed.pathRef()->countPoints()); |
| 1602 dst->fDirection = kUnknown_Direction; | 1605 dst->fDirection = kUnknown_Direction; |
| 1603 } else { | 1606 } else { |
| 1604 SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef.get(), matrix ); | 1607 SkPathRef::CreateTransformedCopy(&dst->fPathRef, *fPathRef.get(), matrix ); |
| 1605 | 1608 |
| 1606 if (this != dst) { | 1609 if (this != dst) { |
| 1607 dst->fFillType = fFillType; | 1610 dst->fFillType = fFillType; |
| 1608 dst->fConvexity = fConvexity; | 1611 dst->fConvexity = fConvexity; |
| 1612 dst->fIsVolatile = fIsVolatile; | |
| 1609 } | 1613 } |
| 1610 | 1614 |
| 1611 if (kUnknown_Direction == fDirection) { | 1615 if (kUnknown_Direction == fDirection) { |
| 1612 dst->fDirection = kUnknown_Direction; | 1616 dst->fDirection = kUnknown_Direction; |
| 1613 } else { | 1617 } else { |
| 1614 SkScalar det2x2 = | 1618 SkScalar det2x2 = |
| 1615 SkScalarMul(matrix.get(SkMatrix::kMScaleX), matrix.get(SkMatrix: :kMScaleY)) - | 1619 SkScalarMul(matrix.get(SkMatrix::kMScaleX), matrix.get(SkMatrix: :kMScaleY)) - |
| 1616 SkScalarMul(matrix.get(SkMatrix::kMSkewX), matrix.get(SkMatrix:: kMSkewY)); | 1620 SkScalarMul(matrix.get(SkMatrix::kMSkewX), matrix.get(SkMatrix:: kMSkewY)); |
| 1617 if (det2x2 < 0) { | 1621 if (det2x2 < 0) { |
| 1618 dst->fDirection = SkPath::OppositeDirection(static_cast<Directio n>(fDirection)); | 1622 dst->fDirection = SkPath::OppositeDirection(static_cast<Directio n>(fDirection)); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1992 SkRBufferWithSizeCheck buffer(storage, length); | 1996 SkRBufferWithSizeCheck buffer(storage, length); |
| 1993 | 1997 |
| 1994 int32_t packed; | 1998 int32_t packed; |
| 1995 if (!buffer.readS32(&packed)) { | 1999 if (!buffer.readS32(&packed)) { |
| 1996 return 0; | 2000 return 0; |
| 1997 } | 2001 } |
| 1998 | 2002 |
| 1999 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; | 2003 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; |
| 2000 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; | 2004 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; |
| 2001 fDirection = (packed >> kDirection_SerializationShift) & 0x3; | 2005 fDirection = (packed >> kDirection_SerializationShift) & 0x3; |
| 2006 fIsVolatile = false; // ? | |
|
bsalomon
2014/10/23 17:54:08
Should we save/restore this?
jvanverth1
2014/10/23 20:06:18
Done.
| |
| 2002 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); | 2007 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); |
| 2003 | 2008 |
| 2004 size_t sizeRead = 0; | 2009 size_t sizeRead = 0; |
| 2005 if (buffer.isValid()) { | 2010 if (buffer.isValid()) { |
| 2006 fPathRef.reset(pathRef); | 2011 fPathRef.reset(pathRef); |
| 2007 SkDEBUGCODE(this->validate();) | 2012 SkDEBUGCODE(this->validate();) |
| 2008 buffer.skipToAlign4(); | 2013 buffer.skipToAlign4(); |
| 2009 sizeRead = buffer.pos(); | 2014 sizeRead = buffer.pos(); |
| 2010 } else if (pathRef) { | 2015 } else if (pathRef) { |
| 2011 // If the buffer is not valid, pathRef should be NULL | 2016 // If the buffer is not valid, pathRef should be NULL |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2844 switch (this->getFillType()) { | 2849 switch (this->getFillType()) { |
| 2845 case SkPath::kEvenOdd_FillType: | 2850 case SkPath::kEvenOdd_FillType: |
| 2846 case SkPath::kInverseEvenOdd_FillType: | 2851 case SkPath::kInverseEvenOdd_FillType: |
| 2847 w &= 1; | 2852 w &= 1; |
| 2848 break; | 2853 break; |
| 2849 default: | 2854 default: |
| 2850 break; | 2855 break; |
| 2851 } | 2856 } |
| 2852 return SkToBool(w); | 2857 return SkToBool(w); |
| 2853 } | 2858 } |
| OLD | NEW |