Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "SkErrorInternals.h" | 9 #include "SkErrorInternals.h" |
| 10 #include "SkGeometry.h" | 10 #include "SkGeometry.h" |
| (...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1854 if (NULL == storage) { | 1854 if (NULL == storage) { |
| 1855 const int byteCount = sizeof(int32_t) + fPathRef->writeSize(); | 1855 const int byteCount = sizeof(int32_t) + fPathRef->writeSize(); |
| 1856 return SkAlign4(byteCount); | 1856 return SkAlign4(byteCount); |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 SkWBuffer buffer(storage); | 1859 SkWBuffer buffer(storage); |
| 1860 | 1860 |
| 1861 int32_t packed = (fConvexity << kConvexity_SerializationShift) | | 1861 int32_t packed = (fConvexity << kConvexity_SerializationShift) | |
| 1862 (fFillType << kFillType_SerializationShift) | | 1862 (fFillType << kFillType_SerializationShift) | |
| 1863 (fFirstDirection << kDirection_SerializationShift) | | 1863 (fFirstDirection << kDirection_SerializationShift) | |
| 1864 (fIsVolatile << kIsVolatile_SerializationShift); | 1864 (fIsVolatile << kIsVolatile_SerializationShift) | |
| 1865 kCurrent_Version; | |
| 1865 | 1866 |
| 1866 buffer.write32(packed); | 1867 buffer.write32(packed); |
| 1867 | 1868 |
| 1868 fPathRef->writeToBuffer(&buffer); | 1869 fPathRef->writeToBuffer(&buffer); |
| 1869 | 1870 |
| 1870 buffer.padToAlign4(); | 1871 buffer.padToAlign4(); |
| 1871 return buffer.pos(); | 1872 return buffer.pos(); |
| 1872 } | 1873 } |
| 1873 | 1874 |
| 1874 size_t SkPath::readFromMemory(const void* storage, size_t length) { | 1875 size_t SkPath::readFromMemory(const void* storage, size_t length) { |
| 1875 SkRBufferWithSizeCheck buffer(storage, length); | 1876 SkRBufferWithSizeCheck buffer(storage, length); |
| 1876 | 1877 |
| 1877 int32_t packed; | 1878 int32_t packed; |
| 1878 if (!buffer.readS32(&packed)) { | 1879 if (!buffer.readS32(&packed)) { |
| 1879 return 0; | 1880 return 0; |
| 1880 } | 1881 } |
| 1881 | 1882 |
| 1883 unsigned version = packed & 0xFF; | |
| 1884 | |
| 1882 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; | 1885 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; |
| 1883 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; | 1886 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; |
| 1884 fFirstDirection = (packed >> kDirection_SerializationShift) & 0x3; | 1887 fFirstDirection = (packed >> kDirection_SerializationShift) & 0x3; |
|
egdaniel
2015/06/11 21:12:27
style wise do you want this sitting here or as an
| |
| 1885 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; | 1888 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; |
| 1886 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); | 1889 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); |
| 1887 | 1890 |
| 1891 if (version < kPathPrivFirstDirection_Version) { | |
| 1892 switch (fFirstDirection) { // old values | |
| 1893 case 0: | |
| 1894 fFirstDirection = SkPathPriv::kUnknown_FirstDirection; | |
| 1895 break; | |
| 1896 case 1: | |
| 1897 fFirstDirection = SkPathPriv::kCW_FirstDirection; | |
| 1898 break; | |
| 1899 case 2: | |
| 1900 fFirstDirection = SkPathPriv::kCCW_FirstDirection; | |
| 1901 break; | |
| 1902 default: | |
| 1903 SkASSERT(false); | |
| 1904 } | |
| 1905 } | |
| 1906 | |
| 1888 size_t sizeRead = 0; | 1907 size_t sizeRead = 0; |
| 1889 if (buffer.isValid()) { | 1908 if (buffer.isValid()) { |
| 1890 fPathRef.reset(pathRef); | 1909 fPathRef.reset(pathRef); |
| 1891 SkDEBUGCODE(this->validate();) | 1910 SkDEBUGCODE(this->validate();) |
| 1892 buffer.skipToAlign4(); | 1911 buffer.skipToAlign4(); |
| 1893 sizeRead = buffer.pos(); | 1912 sizeRead = buffer.pos(); |
| 1894 } else if (pathRef) { | 1913 } else if (pathRef) { |
| 1895 // If the buffer is not valid, pathRef should be NULL | 1914 // If the buffer is not valid, pathRef should be NULL |
| 1896 sk_throw(); | 1915 sk_throw(); |
| 1897 } | 1916 } |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2787 switch (this->getFillType()) { | 2806 switch (this->getFillType()) { |
| 2788 case SkPath::kEvenOdd_FillType: | 2807 case SkPath::kEvenOdd_FillType: |
| 2789 case SkPath::kInverseEvenOdd_FillType: | 2808 case SkPath::kInverseEvenOdd_FillType: |
| 2790 w &= 1; | 2809 w &= 1; |
| 2791 break; | 2810 break; |
| 2792 default: | 2811 default: |
| 2793 break; | 2812 break; |
| 2794 } | 2813 } |
| 2795 return SkToBool(w); | 2814 return SkToBool(w); |
| 2796 } | 2815 } |
| OLD | NEW |