| OLD | NEW |
| (Empty) |
| 1 /* libs/graphics/animator/SkDisplayTypes.cpp | |
| 2 ** | |
| 3 ** Copyright 2006, The Android Open Source Project | |
| 4 ** | |
| 5 ** Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 ** you may not use this file except in compliance with the License. | |
| 7 ** You may obtain a copy of the License at | |
| 8 ** | |
| 9 ** http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 ** | |
| 11 ** Unless required by applicable law or agreed to in writing, software | |
| 12 ** distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 ** See the License for the specific language governing permissions and | |
| 15 ** limitations under the License. | |
| 16 */ | |
| 17 | |
| 18 #include "SkDisplayTypes.h" | |
| 19 #include "SkAnimateBase.h" | |
| 20 | |
| 21 bool SkDisplayDepend::canContainDependents() const { | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 void SkDisplayDepend::dirty() { | |
| 26 SkDisplayable** last = fDependents.end(); | |
| 27 for (SkDisplayable** depPtr = fDependents.begin(); depPtr < last; depPtr++)
{ | |
| 28 SkAnimateBase* animate = (SkAnimateBase* ) *depPtr; | |
| 29 animate->setChanged(true); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 // Boolean | |
| 34 #if SK_USE_CONDENSED_INFO == 0 | |
| 35 | |
| 36 const SkMemberInfo SkDisplayBoolean::fInfo[] = { | |
| 37 SK_MEMBER(value, Boolean) | |
| 38 }; | |
| 39 | |
| 40 #endif | |
| 41 | |
| 42 DEFINE_GET_MEMBER(SkDisplayBoolean); | |
| 43 | |
| 44 SkDisplayBoolean::SkDisplayBoolean() : value(false) { | |
| 45 } | |
| 46 | |
| 47 #ifdef SK_DUMP_ENABLED | |
| 48 void SkDisplayBoolean::dump(SkAnimateMaker* maker){ | |
| 49 dumpBase(maker); | |
| 50 SkDebugf("value=\"%s\" />\n", value ? "true" : "false"); | |
| 51 } | |
| 52 #endif | |
| 53 | |
| 54 // int32_t | |
| 55 #if SK_USE_CONDENSED_INFO == 0 | |
| 56 | |
| 57 const SkMemberInfo SkDisplayInt::fInfo[] = { | |
| 58 SK_MEMBER(value, Int) | |
| 59 }; | |
| 60 | |
| 61 #endif | |
| 62 | |
| 63 DEFINE_GET_MEMBER(SkDisplayInt); | |
| 64 | |
| 65 SkDisplayInt::SkDisplayInt() : value(0) { | |
| 66 } | |
| 67 | |
| 68 #ifdef SK_DUMP_ENABLED | |
| 69 void SkDisplayInt::dump(SkAnimateMaker* maker){ | |
| 70 dumpBase(maker); | |
| 71 SkDebugf("value=\"%d\" />\n", value); | |
| 72 } | |
| 73 #endif | |
| 74 | |
| 75 // SkScalar | |
| 76 #if SK_USE_CONDENSED_INFO == 0 | |
| 77 | |
| 78 const SkMemberInfo SkDisplayFloat::fInfo[] = { | |
| 79 SK_MEMBER(value, Float) | |
| 80 }; | |
| 81 | |
| 82 #endif | |
| 83 | |
| 84 DEFINE_GET_MEMBER(SkDisplayFloat); | |
| 85 | |
| 86 SkDisplayFloat::SkDisplayFloat() : value(0) { | |
| 87 } | |
| 88 | |
| 89 #ifdef SK_DUMP_ENABLED | |
| 90 void SkDisplayFloat::dump(SkAnimateMaker* maker) { | |
| 91 dumpBase(maker); | |
| 92 #ifdef SK_CAN_USE_FLOAT | |
| 93 SkDebugf("value=\"%g\" />\n", SkScalarToFloat(value)); | |
| 94 #else | |
| 95 SkDebugf("value=\"%x\" />\n", value); | |
| 96 #endif | |
| 97 } | |
| 98 #endif | |
| 99 | |
| 100 // SkString | |
| 101 enum SkDisplayString_Functions { | |
| 102 SK_FUNCTION(slice) | |
| 103 }; | |
| 104 | |
| 105 enum SkDisplayString_Properties { | |
| 106 SK_PROPERTY(length) | |
| 107 }; | |
| 108 | |
| 109 const SkFunctionParamType SkDisplayString::fFunctionParameters[] = { | |
| 110 (SkFunctionParamType) SkType_Int, // slice | |
| 111 (SkFunctionParamType) SkType_Int, | |
| 112 (SkFunctionParamType) 0 | |
| 113 }; | |
| 114 | |
| 115 #if SK_USE_CONDENSED_INFO == 0 | |
| 116 | |
| 117 const SkMemberInfo SkDisplayString::fInfo[] = { | |
| 118 SK_MEMBER_PROPERTY(length, Int), | |
| 119 SK_MEMBER_FUNCTION(slice, String), | |
| 120 SK_MEMBER(value, String) | |
| 121 }; | |
| 122 | |
| 123 #endif | |
| 124 | |
| 125 DEFINE_GET_MEMBER(SkDisplayString); | |
| 126 | |
| 127 SkDisplayString::SkDisplayString() { | |
| 128 } | |
| 129 | |
| 130 SkDisplayString::SkDisplayString(SkString& copyFrom) : value(copyFrom) { | |
| 131 } | |
| 132 | |
| 133 void SkDisplayString::executeFunction(SkDisplayable* target, int index, | |
| 134 SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type, | |
| 135 SkScriptValue* scriptValue) { | |
| 136 if (scriptValue == NULL) | |
| 137 return; | |
| 138 SkASSERT(target == this); | |
| 139 switch (index) { | |
| 140 case SK_FUNCTION(slice): | |
| 141 scriptValue->fType = SkType_String; | |
| 142 SkASSERT(parameters[0].fType == SkType_Int); | |
| 143 int start = parameters[0].fOperand.fS32; | |
| 144 if (start < 0) | |
| 145 start = (int) (value.size() - start); | |
| 146 int end = (int) value.size(); | |
| 147 if (parameters.count() > 1) { | |
| 148 SkASSERT(parameters[1].fType == SkType_Int); | |
| 149 end = parameters[1].fOperand.fS32; | |
| 150 } | |
| 151 //if (end >= 0 && end < (int) value.size()) | |
| 152 if (end >= 0 && end <= (int) value.size()) | |
| 153 scriptValue->fOperand.fString = new SkString(&value.c_str()[star
t], end - start); | |
| 154 else | |
| 155 scriptValue->fOperand.fString = new SkString(value); | |
| 156 break; | |
| 157 } | |
| 158 } | |
| 159 | |
| 160 const SkFunctionParamType* SkDisplayString::getFunctionsParameters() { | |
| 161 return fFunctionParameters; | |
| 162 } | |
| 163 | |
| 164 bool SkDisplayString::getProperty(int index, SkScriptValue* scriptValue) const { | |
| 165 switch (index) { | |
| 166 case SK_PROPERTY(length): | |
| 167 scriptValue->fType = SkType_Int; | |
| 168 scriptValue->fOperand.fS32 = (int32_t) value.size(); | |
| 169 break; | |
| 170 default: | |
| 171 SkASSERT(0); | |
| 172 return false; | |
| 173 } | |
| 174 return true; | |
| 175 } | |
| 176 | |
| 177 | |
| 178 // SkArray | |
| 179 #if 0 // !!! reason enough to qualify enum with class name or move typedArray
into its own file | |
| 180 enum SkDisplayArray_Properties { | |
| 181 SK_PROPERTY(length) | |
| 182 }; | |
| 183 #endif | |
| 184 | |
| 185 #if SK_USE_CONDENSED_INFO == 0 | |
| 186 | |
| 187 const SkMemberInfo SkDisplayArray::fInfo[] = { | |
| 188 SK_MEMBER_PROPERTY(length, Int), | |
| 189 SK_MEMBER_ARRAY(values, Unknown) | |
| 190 }; | |
| 191 | |
| 192 #endif | |
| 193 | |
| 194 DEFINE_GET_MEMBER(SkDisplayArray); | |
| 195 | |
| 196 SkDisplayArray::SkDisplayArray() { | |
| 197 } | |
| 198 | |
| 199 SkDisplayArray::SkDisplayArray(SkTypedArray& copyFrom) : values(copyFrom) { | |
| 200 | |
| 201 } | |
| 202 | |
| 203 SkDisplayArray::~SkDisplayArray() { | |
| 204 if (values.getType() == SkType_String) { | |
| 205 for (int index = 0; index < values.count(); index++) | |
| 206 delete values[index].fString; | |
| 207 return; | |
| 208 } | |
| 209 if (values.getType() == SkType_Array) { | |
| 210 for (int index = 0; index < values.count(); index++) | |
| 211 delete values[index].fArray; | |
| 212 } | |
| 213 } | |
| 214 | |
| 215 bool SkDisplayArray::getProperty(int index, SkScriptValue* value) const { | |
| 216 switch (index) { | |
| 217 case SK_PROPERTY(length): | |
| 218 value->fType = SkType_Int; | |
| 219 value->fOperand.fS32 = values.count(); | |
| 220 break; | |
| 221 default: | |
| 222 SkASSERT(0); | |
| 223 return false; | |
| 224 } | |
| 225 return true; | |
| 226 } | |
| 227 | |
| 228 | |
| 229 | |
| OLD | NEW |