| 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 "SkAnimate.h" | 10 #include "SkAnimate.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 SkDebugf("%g", SkScalarToFloat(blend[i])); | 56 SkDebugf("%g", SkScalarToFloat(blend[i])); |
| 57 } | 57 } |
| 58 SkDebugf("]\" "); | 58 SkDebugf("]\" "); |
| 59 } | 59 } |
| 60 SkDebugf("/>\n");//i assume that if it IS, we will do it separately | 60 SkDebugf("/>\n");//i assume that if it IS, we will do it separately |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 bool SkAnimate::resolveCommon(SkAnimateMaker& maker) { | 65 bool SkAnimate::resolveCommon(SkAnimateMaker& maker) { |
| 66 if (fTarget == NULL) // if NULL, recall onEndElement after apply closes and
sets target to scope | 66 if (fTarget == nullptr) // if nullptr, recall onEndElement after apply close
s and sets target to scope |
| 67 return false; | 67 return false; |
| 68 INHERITED::onEndElement(maker); | 68 INHERITED::onEndElement(maker); |
| 69 return maker.hasError() == false; | 69 return maker.hasError() == false; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void SkAnimate::onEndElement(SkAnimateMaker& maker) { | 72 void SkAnimate::onEndElement(SkAnimateMaker& maker) { |
| 73 bool resolved = resolveCommon(maker); | 73 bool resolved = resolveCommon(maker); |
| 74 if (resolved && fFieldInfo == NULL) { | 74 if (resolved && fFieldInfo == nullptr) { |
| 75 maker.setErrorNoun(field); | 75 maker.setErrorNoun(field); |
| 76 maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); | 76 maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); |
| 77 } | 77 } |
| 78 if (resolved == false || fFieldInfo == NULL) | 78 if (resolved == false || fFieldInfo == nullptr) |
| 79 return; | 79 return; |
| 80 SkDisplayTypes outType = fFieldInfo->getType(); | 80 SkDisplayTypes outType = fFieldInfo->getType(); |
| 81 if (fHasValues) { | 81 if (fHasValues) { |
| 82 SkASSERT(to.size() > 0); | 82 SkASSERT(to.size() > 0); |
| 83 fFieldInfo->setValue(maker, &fValues, 0, 0, NULL, outType, to); | 83 fFieldInfo->setValue(maker, &fValues, 0, 0, nullptr, outType, to); |
| 84 SkASSERT(0); | 84 SkASSERT(0); |
| 85 // !!! this needs to set fComponents | 85 // !!! this needs to set fComponents |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 fComponents = fFieldInfo->getCount(); | 88 fComponents = fFieldInfo->getCount(); |
| 89 if (fFieldInfo->fType == SkType_Array) { | 89 if (fFieldInfo->fType == SkType_Array) { |
| 90 SkTypedArray* array = (SkTypedArray*) fFieldInfo->memberData(fTarget); | 90 SkTypedArray* array = (SkTypedArray*) fFieldInfo->memberData(fTarget); |
| 91 int count = array->count(); | 91 int count = array->count(); |
| 92 if (count > 0) | 92 if (count > 0) |
| 93 fComponents = count; | 93 fComponents = count; |
| 94 } | 94 } |
| 95 if (outType == SkType_ARGB) { | 95 if (outType == SkType_ARGB) { |
| 96 fComponents <<= 2; // four color components | 96 fComponents <<= 2; // four color components |
| 97 outType = SkType_Float; | 97 outType = SkType_Float; |
| 98 } | 98 } |
| 99 fValues.setType(outType); | 99 fValues.setType(outType); |
| 100 if (formula.size() > 0){ | 100 if (formula.size() > 0){ |
| 101 fComponents = 1; | 101 fComponents = 1; |
| 102 from.set("0"); | 102 from.set("0"); |
| 103 to.set("dur"); | 103 to.set("dur"); |
| 104 outType = SkType_MSec; | 104 outType = SkType_MSec; |
| 105 } | 105 } |
| 106 int max = fComponents * 2; | 106 int max = fComponents * 2; |
| 107 fValues.setCount(max); | 107 fValues.setCount(max); |
| 108 memset(fValues.begin(), 0, max * sizeof(fValues.begin()[0])); | 108 memset(fValues.begin(), 0, max * sizeof(fValues.begin()[0])); |
| 109 fFieldInfo->setValue(maker, &fValues, fFieldOffset, max, this, outType, from
); | 109 fFieldInfo->setValue(maker, &fValues, fFieldOffset, max, this, outType, from
); |
| 110 fFieldInfo->setValue(maker, &fValues, fComponents + fFieldOffset, max, this,
outType, to); | 110 fFieldInfo->setValue(maker, &fValues, fComponents + fFieldOffset, max, this,
outType, to); |
| 111 } | 111 } |
| OLD | NEW |