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 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 } else if (NULL != pathRef) { | 2104 } else if (NULL != pathRef) { |
2105 // If the buffer is not valid, pathRef should be NULL | 2105 // If the buffer is not valid, pathRef should be NULL |
2106 sk_throw(); | 2106 sk_throw(); |
2107 } | 2107 } |
2108 return sizeRead; | 2108 return sizeRead; |
2109 } | 2109 } |
2110 | 2110 |
2111 /////////////////////////////////////////////////////////////////////////////// | 2111 /////////////////////////////////////////////////////////////////////////////// |
2112 | 2112 |
2113 #include "SkString.h" | 2113 #include "SkString.h" |
| 2114 #include "SkStream.h" |
2114 | 2115 |
2115 static void append_scalar(SkString* str, SkScalar value) { | 2116 static void append_scalar(SkString* str, SkScalar value) { |
2116 SkString tmp; | 2117 SkString tmp; |
2117 tmp.printf("%g", value); | 2118 tmp.printf("%g", value); |
2118 if (tmp.contains('.')) { | 2119 if (tmp.contains('.')) { |
2119 tmp.appendUnichar('f'); | 2120 tmp.appendUnichar('f'); |
2120 } | 2121 } |
2121 str->append(tmp); | 2122 str->append(tmp); |
2122 } | 2123 } |
2123 | 2124 |
(...skipping 11 matching lines...) Expand all Loading... |
2135 str->append(", "); | 2136 str->append(", "); |
2136 } | 2137 } |
2137 } | 2138 } |
2138 if (conicWeight >= 0) { | 2139 if (conicWeight >= 0) { |
2139 str->append(", "); | 2140 str->append(", "); |
2140 append_scalar(str, conicWeight); | 2141 append_scalar(str, conicWeight); |
2141 } | 2142 } |
2142 str->append(");\n"); | 2143 str->append(");\n"); |
2143 } | 2144 } |
2144 | 2145 |
2145 void SkPath::dump(bool forceClose, const char title[]) const { | 2146 void SkPath::dump(SkWStream* wStream, bool forceClose) const { |
2146 Iter iter(*this, forceClose); | 2147 Iter iter(*this, forceClose); |
2147 SkPoint pts[4]; | 2148 SkPoint pts[4]; |
2148 Verb verb; | 2149 Verb verb; |
2149 | 2150 |
2150 SkDebugf("path: forceClose=%s %s\n", forceClose ? "true" : "false", | 2151 if (!wStream) { |
2151 title ? title : ""); | 2152 SkDebugf("path: forceClose=%s\n", forceClose ? "true" : "false"); |
2152 | 2153 } |
2153 SkString builder; | 2154 SkString builder; |
2154 | 2155 |
2155 while ((verb = iter.next(pts, false)) != kDone_Verb) { | 2156 while ((verb = iter.next(pts, false)) != kDone_Verb) { |
2156 switch (verb) { | 2157 switch (verb) { |
2157 case kMove_Verb: | 2158 case kMove_Verb: |
2158 append_params(&builder, "path.moveTo", &pts[0], 1); | 2159 append_params(&builder, "path.moveTo", &pts[0], 1); |
2159 break; | 2160 break; |
2160 case kLine_Verb: | 2161 case kLine_Verb: |
2161 append_params(&builder, "path.lineTo", &pts[1], 1); | 2162 append_params(&builder, "path.lineTo", &pts[1], 1); |
2162 break; | 2163 break; |
2163 case kQuad_Verb: | 2164 case kQuad_Verb: |
2164 append_params(&builder, "path.quadTo", &pts[1], 2); | 2165 append_params(&builder, "path.quadTo", &pts[1], 2); |
2165 break; | 2166 break; |
2166 case kConic_Verb: | 2167 case kConic_Verb: |
2167 append_params(&builder, "path.conicTo", &pts[1], 2, iter.conicWe
ight()); | 2168 append_params(&builder, "path.conicTo", &pts[1], 2, iter.conicWe
ight()); |
2168 break; | 2169 break; |
2169 case kCubic_Verb: | 2170 case kCubic_Verb: |
2170 append_params(&builder, "path.cubicTo", &pts[1], 3); | 2171 append_params(&builder, "path.cubicTo", &pts[1], 3); |
2171 break; | 2172 break; |
2172 case kClose_Verb: | 2173 case kClose_Verb: |
2173 builder.append("path.close();"); | 2174 builder.append("path.close();\n"); |
2174 break; | 2175 break; |
2175 default: | 2176 default: |
2176 SkDebugf(" path: UNKNOWN VERB %d, aborting dump...\n", verb); | 2177 SkDebugf(" path: UNKNOWN VERB %d, aborting dump...\n", verb); |
2177 verb = kDone_Verb; // stop the loop | 2178 verb = kDone_Verb; // stop the loop |
2178 break; | 2179 break; |
2179 } | 2180 } |
2180 } | 2181 } |
2181 SkDebugf("%s\n", builder.c_str()); | 2182 if (wStream) { |
| 2183 wStream->writeText(builder.c_str()); |
| 2184 } else { |
| 2185 SkDebugf("%s", builder.c_str()); |
| 2186 } |
2182 } | 2187 } |
2183 | 2188 |
2184 void SkPath::dump() const { | 2189 void SkPath::dump() const { |
2185 this->dump(false); | 2190 this->dump(NULL, false); |
2186 } | 2191 } |
2187 | 2192 |
2188 #ifdef SK_DEBUG | 2193 #ifdef SK_DEBUG |
2189 void SkPath::validate() const { | 2194 void SkPath::validate() const { |
2190 SkASSERT(this != NULL); | 2195 SkASSERT(this != NULL); |
2191 SkASSERT((fFillType & ~3) == 0); | 2196 SkASSERT((fFillType & ~3) == 0); |
2192 | 2197 |
2193 #ifdef SK_DEBUG_PATH | 2198 #ifdef SK_DEBUG_PATH |
2194 if (!fBoundsIsDirty) { | 2199 if (!fBoundsIsDirty) { |
2195 SkRect bounds; | 2200 SkRect bounds; |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2883 switch (this->getFillType()) { | 2888 switch (this->getFillType()) { |
2884 case SkPath::kEvenOdd_FillType: | 2889 case SkPath::kEvenOdd_FillType: |
2885 case SkPath::kInverseEvenOdd_FillType: | 2890 case SkPath::kInverseEvenOdd_FillType: |
2886 w &= 1; | 2891 w &= 1; |
2887 break; | 2892 break; |
2888 default: | 2893 default: |
2889 break; | 2894 break; |
2890 } | 2895 } |
2891 return SkToBool(w); | 2896 return SkToBool(w); |
2892 } | 2897 } |
OLD | NEW |