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 "SkCubicClipper.h" | 9 #include "SkCubicClipper.h" |
| 10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1902 return 0; | 1902 return 0; |
| 1903 } | 1903 } |
| 1904 | 1904 |
| 1905 unsigned version = packed & 0xFF; | 1905 unsigned version = packed & 0xFF; |
| 1906 | 1906 |
| 1907 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; | 1907 fConvexity = (packed >> kConvexity_SerializationShift) & 0xFF; |
| 1908 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; | 1908 fFillType = (packed >> kFillType_SerializationShift) & 0xFF; |
| 1909 uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3; | 1909 uint8_t dir = (packed >> kDirection_SerializationShift) & 0x3; |
| 1910 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; | 1910 fIsVolatile = (packed >> kIsVolatile_SerializationShift) & 0x1; |
| 1911 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); | 1911 SkPathRef* pathRef = SkPathRef::CreateFromBuffer(&buffer); |
| 1912 if (!pathRef) { | |
| 1913 return 0; | |
| 1914 } | |
| 1915 | |
| 1916 if (!buffer.isValid()) { | |
| 1917 // If the buffer is not valid, pathRef should be nullptr. | |
|
reed1
2016/01/13 20:27:11
why are we throwing, instead of just returning, as
ajuma
2016/01/13 20:47:54
Looking at where this originated (https://coderevi
reed1
2016/01/13 21:05:47
Lets not add code in places that can never be reac
ajuma
2016/01/13 21:11:41
Removed the check.
| |
| 1918 sk_throw(); | |
| 1919 } | |
| 1920 | |
| 1921 fPathRef.reset(pathRef); | |
| 1922 SkDEBUGCODE(this->validate();) | |
| 1923 buffer.skipToAlign4(); | |
| 1912 | 1924 |
| 1913 // compatibility check | 1925 // compatibility check |
| 1914 if (version < kPathPrivFirstDirection_Version) { | 1926 if (version < kPathPrivFirstDirection_Version) { |
| 1915 switch (dir) { // old values | 1927 switch (dir) { // old values |
| 1916 case 0: | 1928 case 0: |
| 1917 fFirstDirection = SkPathPriv::kUnknown_FirstDirection; | 1929 fFirstDirection = SkPathPriv::kUnknown_FirstDirection; |
| 1918 break; | 1930 break; |
| 1919 case 1: | 1931 case 1: |
| 1920 fFirstDirection = SkPathPriv::kCW_FirstDirection; | 1932 fFirstDirection = SkPathPriv::kCW_FirstDirection; |
| 1921 break; | 1933 break; |
| 1922 case 2: | 1934 case 2: |
| 1923 fFirstDirection = SkPathPriv::kCCW_FirstDirection; | 1935 fFirstDirection = SkPathPriv::kCCW_FirstDirection; |
| 1924 break; | 1936 break; |
| 1925 default: | 1937 default: |
| 1926 SkASSERT(false); | 1938 SkASSERT(false); |
| 1927 } | 1939 } |
| 1928 } else { | 1940 } else { |
| 1929 fFirstDirection = dir; | 1941 fFirstDirection = dir; |
| 1930 } | 1942 } |
| 1931 | 1943 |
| 1932 size_t sizeRead = 0; | 1944 return buffer.pos(); |
| 1933 if (buffer.isValid()) { | |
| 1934 fPathRef.reset(pathRef); | |
| 1935 SkDEBUGCODE(this->validate();) | |
| 1936 buffer.skipToAlign4(); | |
| 1937 sizeRead = buffer.pos(); | |
| 1938 } else if (pathRef) { | |
| 1939 // If the buffer is not valid, pathRef should be nullptr | |
| 1940 sk_throw(); | |
| 1941 } | |
| 1942 return sizeRead; | |
| 1943 } | 1945 } |
| 1944 | 1946 |
| 1945 /////////////////////////////////////////////////////////////////////////////// | 1947 /////////////////////////////////////////////////////////////////////////////// |
| 1946 | 1948 |
| 1947 #include "SkStringUtils.h" | 1949 #include "SkStringUtils.h" |
| 1948 #include "SkStream.h" | 1950 #include "SkStream.h" |
| 1949 | 1951 |
| 1950 static void append_params(SkString* str, const char label[], const SkPoint pts[] , | 1952 static void append_params(SkString* str, const char label[], const SkPoint pts[] , |
| 1951 int count, SkScalarAsStringType strType, SkScalar coni cWeight = -1) { | 1953 int count, SkScalarAsStringType strType, SkScalar coni cWeight = -1) { |
| 1952 str->append(label); | 1954 str->append(label); |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3087 } | 3089 } |
| 3088 } while (!done); | 3090 } while (!done); |
| 3089 return SkToBool(tangents.count()) ^ isInverse; | 3091 return SkToBool(tangents.count()) ^ isInverse; |
| 3090 } | 3092 } |
| 3091 | 3093 |
| 3092 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, | 3094 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, |
| 3093 SkScalar w, SkPoint pts[], int pow2) { | 3095 SkScalar w, SkPoint pts[], int pow2) { |
| 3094 const SkConic conic(p0, p1, p2, w); | 3096 const SkConic conic(p0, p1, p2, w); |
| 3095 return conic.chopIntoQuadsPOW2(pts, pow2); | 3097 return conic.chopIntoQuadsPOW2(pts, pow2); |
| 3096 } | 3098 } |
| OLD | NEW |