Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: src/core/SkPath.cpp

Issue 1702393002: add last move to serialized path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkCubicClipper.h" 9 #include "SkCubicClipper.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 /////////////////////////////////////////////////////////////////////////////// 1958 ///////////////////////////////////////////////////////////////////////////////
1959 1959
1960 /* 1960 /*
1961 Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]] 1961 Format in compressed buffer: [ptCount, verbCount, pts[], verbs[]]
1962 */ 1962 */
1963 1963
1964 size_t SkPath::writeToMemory(void* storage) const { 1964 size_t SkPath::writeToMemory(void* storage) const {
1965 SkDEBUGCODE(this->validate();) 1965 SkDEBUGCODE(this->validate();)
1966 1966
1967 if (nullptr == storage) { 1967 if (nullptr == storage) {
1968 const int byteCount = sizeof(int32_t) + fPathRef->writeSize(); 1968 const int byteCount = sizeof(int32_t) * 2 + fPathRef->writeSize();
1969 return SkAlign4(byteCount); 1969 return SkAlign4(byteCount);
1970 } 1970 }
1971 1971
1972 SkWBuffer buffer(storage); 1972 SkWBuffer buffer(storage);
1973 1973
1974 int32_t packed = (fConvexity << kConvexity_SerializationShift) | 1974 int32_t packed = (fConvexity << kConvexity_SerializationShift) |
1975 (fFillType << kFillType_SerializationShift) | 1975 (fFillType << kFillType_SerializationShift) |
1976 (fFirstDirection << kDirection_SerializationShift) | 1976 (fFirstDirection << kDirection_SerializationShift) |
1977 (fIsVolatile << kIsVolatile_SerializationShift) | 1977 (fIsVolatile << kIsVolatile_SerializationShift) |
1978 kCurrent_Version; 1978 kCurrent_Version;
1979 1979
1980 buffer.write32(packed); 1980 buffer.write32(packed);
1981 buffer.write32(fLastMoveToIndex);
1981 1982
1982 fPathRef->writeToBuffer(&buffer); 1983 fPathRef->writeToBuffer(&buffer);
1983 1984
1984 buffer.padToAlign4(); 1985 buffer.padToAlign4();
1985 return buffer.pos(); 1986 return buffer.pos();
1986 } 1987 }
1987 1988
1988 size_t SkPath::readFromMemory(const void* storage, size_t length) { 1989 size_t SkPath::readFromMemory(const void* storage, size_t length) {
1989 SkRBufferWithSizeCheck buffer(storage, length); 1990 SkRBufferWithSizeCheck buffer(storage, length);
1990 1991
1991 int32_t packed; 1992 int32_t packed;
1992 if (!buffer.readS32(&packed)) { 1993 if (!buffer.readS32(&packed)) {
1993 return 0; 1994 return 0;
1994 } 1995 }
1995 1996
1996 unsigned version = packed & 0xFF; 1997 unsigned version = packed & 0xFF;
1998 if (version >= kPathPrivLastMoveToIndex_Version && !buffer.readS32(&fLastMov eToIndex)) {
1999 return 0;
2000 }
1997 2001
1998 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; 2002 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF;
1999 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; 2003 fFillType = (packed >> kFillType_SerializationShift) & 0xFF;
2000 uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3; 2004 uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3;
2001 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; 2005 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1;
2002 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); 2006 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer);
2003 if (!pathRef) { 2007 if (!pathRef) {
2004 return 0; 2008 return 0;
2005 } 2009 }
2006 2010
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 } 3179 }
3176 } while (!done); 3180 } while (!done);
3177 return SkToBool(tangents.count()) ^ isInverse; 3181 return SkToBool(tangents.count()) ^ isInverse;
3178 } 3182 }
3179 3183
3180 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, 3184 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2,
3181 SkScalar w, SkPoint pts[], int pow2) { 3185 SkScalar w, SkPoint pts[], int pow2) {
3182 const SkConic conic(p0, p1, p2, w); 3186 const SkConic conic(p0, p1, p2, w);
3183 return conic.chopIntoQuadsPOW2(pts, pow2); 3187 return conic.chopIntoQuadsPOW2(pts, pow2);
3184 } 3188 }
OLDNEW
« no previous file with comments | « include/core/SkPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698