| 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 "SkSVGPaintState.h" | 10 #include "SkSVGPaintState.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 SVG_LITERAL_ATTRIBUTE(stroke-linecap, f_strokeLinecap), | 31 SVG_LITERAL_ATTRIBUTE(stroke-linecap, f_strokeLinecap), |
| 32 SVG_LITERAL_ATTRIBUTE(stroke-linejoin, f_strokeLinejoin), | 32 SVG_LITERAL_ATTRIBUTE(stroke-linejoin, f_strokeLinejoin), |
| 33 SVG_LITERAL_ATTRIBUTE(stroke-miterlimit, f_strokeMiterlimit), | 33 SVG_LITERAL_ATTRIBUTE(stroke-miterlimit, f_strokeMiterlimit), |
| 34 SVG_LITERAL_ATTRIBUTE(stroke-width, f_strokeWidth), | 34 SVG_LITERAL_ATTRIBUTE(stroke-width, f_strokeWidth), |
| 35 SVG_ATTRIBUTE(style), | 35 SVG_ATTRIBUTE(style), |
| 36 SVG_ATTRIBUTE(transform) | 36 SVG_ATTRIBUTE(transform) |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 const int SkSVGPaint::kAttributesSize = SK_ARRAY_COUNT(SkSVGPaint::gAttributes); | 39 const int SkSVGPaint::kAttributesSize = SK_ARRAY_COUNT(SkSVGPaint::gAttributes); |
| 40 | 40 |
| 41 SkSVGPaint::SkSVGPaint() : fNext(NULL) { | 41 SkSVGPaint::SkSVGPaint() : fNext(nullptr) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 SkString* SkSVGPaint::operator[](int index) { | 44 SkString* SkSVGPaint::operator[](int index) { |
| 45 SkASSERT(index >= 0); | 45 SkASSERT(index >= 0); |
| 46 SkASSERT(index < &fTerminal - &fInitial); | 46 SkASSERT(index < &fTerminal - &fInitial); |
| 47 SkASSERT(&fTerminal - &fInitial == kTerminal - kInitial); | 47 SkASSERT(&fTerminal - &fInitial == kTerminal - kInitial); |
| 48 SkString* result = &fInitial + index + 1; | 48 SkString* result = &fInitial + index + 1; |
| 49 return result; | 49 return result; |
| 50 } | 50 } |
| 51 | 51 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 74 case kStroke_Width: | 74 case kStroke_Width: |
| 75 case kTransform: | 75 case kTransform: |
| 76 attr->set(attrValue, attrLength); | 76 attr->set(attrValue, attrLength); |
| 77 return; | 77 return; |
| 78 case kStyle: { | 78 case kStyle: { |
| 79 // iterate through colon / semi-colon delimited pairs | 79 // iterate through colon / semi-colon delimited pairs |
| 80 int pairs = SkParse::Count(attrValue, ';'); | 80 int pairs = SkParse::Count(attrValue, ';'); |
| 81 const char* attrEnd = attrValue + attrLength; | 81 const char* attrEnd = attrValue + attrLength; |
| 82 do { | 82 do { |
| 83 const char* end = strchr(attrValue, ';'); | 83 const char* end = strchr(attrValue, ';'); |
| 84 if (end == NULL) | 84 if (end == nullptr) |
| 85 end = attrEnd; | 85 end = attrEnd; |
| 86 const char* delimiter = strchr(attrValue, ':'); | 86 const char* delimiter = strchr(attrValue, ':'); |
| 87 SkASSERT(delimiter != 0 && delimiter < end); | 87 SkASSERT(delimiter != 0 && delimiter < end); |
| 88 int index = parser.findAttribute(this, attrValue, (int) (delimit
er - attrValue), true); | 88 int index = parser.findAttribute(this, attrValue, (int) (delimit
er - attrValue), true); |
| 89 SkASSERT(index >= 0); | 89 SkASSERT(index >= 0); |
| 90 delimiter++; | 90 delimiter++; |
| 91 addAttribute(parser, index, delimiter, (int) (end - delimiter)); | 91 addAttribute(parser, index, delimiter, (int) (end - delimiter)); |
| 92 attrValue = end + 1; | 92 attrValue = end + 1; |
| 93 } while (--pairs); | 93 } while (--pairs); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 default: | 96 default: |
| 97 SkASSERT(0); | 97 SkASSERT(0); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool SkSVGPaint::flush(SkSVGParser& parser, bool isFlushable, bool isDef) { | 101 bool SkSVGPaint::flush(SkSVGParser& parser, bool isFlushable, bool isDef) { |
| 102 SkSVGPaint current; | 102 SkSVGPaint current; |
| 103 SkSVGPaint* walking = parser.fHead; | 103 SkSVGPaint* walking = parser.fHead; |
| 104 int index; | 104 int index; |
| 105 while (walking != NULL) { | 105 while (walking != nullptr) { |
| 106 for (index = kInitial + 1; index < kTerminal; index++) { | 106 for (index = kInitial + 1; index < kTerminal; index++) { |
| 107 SkString* lastAttr = (*walking)[index]; | 107 SkString* lastAttr = (*walking)[index]; |
| 108 if (lastAttr->size() == 0) | 108 if (lastAttr->size() == 0) |
| 109 continue; | 109 continue; |
| 110 if (current[index]->size() > 0) | 110 if (current[index]->size() > 0) |
| 111 continue; | 111 continue; |
| 112 current[index]->set(*lastAttr); | 112 current[index]->set(*lastAttr); |
| 113 } | 113 } |
| 114 walking = walking->fNext; | 114 walking = walking->fNext; |
| 115 } | 115 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 *attrPtr = gAttributes; | 188 *attrPtr = gAttributes; |
| 189 return kAttributesSize; | 189 return kAttributesSize; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void SkSVGPaint::setSave(SkSVGParser& parser) { | 192 void SkSVGPaint::setSave(SkSVGParser& parser) { |
| 193 SkTDArray<SkString*> clips; | 193 SkTDArray<SkString*> clips; |
| 194 SkSVGPaint* walking = parser.fHead; | 194 SkSVGPaint* walking = parser.fHead; |
| 195 int index; | 195 int index; |
| 196 SkMatrix sum; | 196 SkMatrix sum; |
| 197 sum.reset(); | 197 sum.reset(); |
| 198 while (walking != NULL) { | 198 while (walking != nullptr) { |
| 199 for (index = kInitial + 1; index < kTerminal; index++) { | 199 for (index = kInitial + 1; index < kTerminal; index++) { |
| 200 SkString* lastAttr = (*walking)[index]; | 200 SkString* lastAttr = (*walking)[index]; |
| 201 if (lastAttr->size() == 0) | 201 if (lastAttr->size() == 0) |
| 202 continue; | 202 continue; |
| 203 if (index == kTransform) { | 203 if (index == kTransform) { |
| 204 const char* str = lastAttr->c_str(); | 204 const char* str = lastAttr->c_str(); |
| 205 SkASSERT(strncmp(str, "matrix(", 7) == 0); | 205 SkASSERT(strncmp(str, "matrix(", 7) == 0); |
| 206 str += 6; | 206 str += 6; |
| 207 const char* strEnd = strrchr(str, ')'); | 207 const char* strEnd = strrchr(str, ')'); |
| 208 SkASSERT(strEnd != NULL); | 208 SkASSERT(strEnd != nullptr); |
| 209 SkString mat(str, strEnd - str); | 209 SkString mat(str, strEnd - str); |
| 210 SkSVGParser::ConvertToArray(mat); | 210 SkSVGParser::ConvertToArray(mat); |
| 211 SkScalar values[6]; | 211 SkScalar values[6]; |
| 212 SkParse::FindScalars(mat.c_str() + 1, values, 6); | 212 SkParse::FindScalars(mat.c_str() + 1, values, 6); |
| 213 SkMatrix matrix; | 213 SkMatrix matrix; |
| 214 matrix.reset(); | 214 matrix.reset(); |
| 215 matrix.setScaleX(values[0]); | 215 matrix.setScaleX(values[0]); |
| 216 matrix.setSkewY(values[1]); | 216 matrix.setSkewY(values[1]); |
| 217 matrix.setSkewX(values[2]); | 217 matrix.setSkewX(values[2]); |
| 218 matrix.setScaleY(values[3]); | 218 matrix.setScaleY(values[3]); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 void SkSVGPaint::Push(SkSVGPaint** head, SkSVGPaint* newRecord) { | 446 void SkSVGPaint::Push(SkSVGPaint** head, SkSVGPaint* newRecord) { |
| 447 newRecord->fNext = *head; | 447 newRecord->fNext = *head; |
| 448 *head = newRecord; | 448 *head = newRecord; |
| 449 } | 449 } |
| 450 | 450 |
| 451 void SkSVGPaint::Pop(SkSVGPaint** head) { | 451 void SkSVGPaint::Pop(SkSVGPaint** head) { |
| 452 SkSVGPaint* next = (*head)->fNext; | 452 SkSVGPaint* next = (*head)->fNext; |
| 453 *head = next; | 453 *head = next; |
| 454 } | 454 } |
| OLD | NEW |