Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #include "SkDisplayable.h" |
michael@0 | 11 | #include "SkDisplayApply.h" |
michael@0 | 12 | #include "SkParse.h" |
michael@0 | 13 | #ifdef SK_DEBUG |
michael@0 | 14 | #include "SkDisplayList.h" |
michael@0 | 15 | #endif |
michael@0 | 16 | #include "SkDisplayTypes.h" |
michael@0 | 17 | |
michael@0 | 18 | #ifdef SK_FIND_LEAKS |
michael@0 | 19 | // int SkDisplayable::fAllocationCount; |
michael@0 | 20 | SkTDDisplayableArray SkDisplayable::fAllocations; |
michael@0 | 21 | #endif |
michael@0 | 22 | |
michael@0 | 23 | #ifdef SK_DEBUG |
michael@0 | 24 | SkDisplayable::SkDisplayable() { |
michael@0 | 25 | id = _id.c_str(); |
michael@0 | 26 | #ifdef SK_FIND_LEAKS |
michael@0 | 27 | // fAllocationCount++; |
michael@0 | 28 | *fAllocations.append() = this; |
michael@0 | 29 | #endif |
michael@0 | 30 | } |
michael@0 | 31 | #endif |
michael@0 | 32 | |
michael@0 | 33 | SkDisplayable::~SkDisplayable() { |
michael@0 | 34 | #ifdef SK_FIND_LEAKS |
michael@0 | 35 | // fAllocationCount--; |
michael@0 | 36 | int index = fAllocations.find(this); |
michael@0 | 37 | SkASSERT(index >= 0); |
michael@0 | 38 | fAllocations.remove(index); |
michael@0 | 39 | #endif |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | bool SkDisplayable::addChild(SkAnimateMaker& , SkDisplayable* child) { |
michael@0 | 43 | return false; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | //void SkDisplayable::apply(SkAnimateMaker& , const SkMemberInfo* , |
michael@0 | 47 | // SkDisplayable* , SkScalar [], int count) { |
michael@0 | 48 | // SkASSERT(0); |
michael@0 | 49 | //} |
michael@0 | 50 | |
michael@0 | 51 | bool SkDisplayable::canContainDependents() const { |
michael@0 | 52 | return false; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | bool SkDisplayable::childrenNeedDisposing() const { |
michael@0 | 56 | return false; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void SkDisplayable::clearBounder() { |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | bool SkDisplayable::contains(SkDisplayable* ) { |
michael@0 | 63 | return false; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | SkDisplayable* SkDisplayable::contains(const SkString& ) { |
michael@0 | 67 | return NULL; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | SkDisplayable* SkDisplayable::deepCopy(SkAnimateMaker* maker) { |
michael@0 | 71 | SkDisplayTypes type = getType(); |
michael@0 | 72 | if (type == SkType_Unknown) { |
michael@0 | 73 | SkASSERT(0); |
michael@0 | 74 | return NULL; |
michael@0 | 75 | } |
michael@0 | 76 | SkDisplayable* copy = SkDisplayType::CreateInstance(maker, type); |
michael@0 | 77 | int index = -1; |
michael@0 | 78 | int propIndex = 0; |
michael@0 | 79 | const SkMemberInfo* info; |
michael@0 | 80 | do { |
michael@0 | 81 | info = copy->getMember(++index); |
michael@0 | 82 | if (info == NULL) |
michael@0 | 83 | break; |
michael@0 | 84 | if (info->fType == SkType_MemberProperty) { |
michael@0 | 85 | SkScriptValue value; |
michael@0 | 86 | if (getProperty(propIndex, &value)) |
michael@0 | 87 | copy->setProperty(propIndex, value); |
michael@0 | 88 | propIndex++; |
michael@0 | 89 | continue; |
michael@0 | 90 | } |
michael@0 | 91 | if (info->fType == SkType_MemberFunction) |
michael@0 | 92 | continue; |
michael@0 | 93 | if (info->fType == SkType_Array) { |
michael@0 | 94 | SkTDOperandArray* array = (SkTDOperandArray*) info->memberData(this); |
michael@0 | 95 | int arrayCount; |
michael@0 | 96 | if (array == NULL || (arrayCount = array->count()) == 0) |
michael@0 | 97 | continue; |
michael@0 | 98 | SkTDOperandArray* copyArray = (SkTDOperandArray*) info->memberData(copy); |
michael@0 | 99 | copyArray->setCount(arrayCount); |
michael@0 | 100 | SkDisplayTypes elementType; |
michael@0 | 101 | if (type == SkType_Array) { |
michael@0 | 102 | SkDisplayArray* dispArray = (SkDisplayArray*) this; |
michael@0 | 103 | elementType = dispArray->values.getType(); |
michael@0 | 104 | } else |
michael@0 | 105 | elementType = info->arrayType(); |
michael@0 | 106 | size_t elementSize = SkMemberInfo::GetSize(elementType); |
michael@0 | 107 | size_t byteSize = elementSize * arrayCount; |
michael@0 | 108 | memcpy(copyArray->begin(), array->begin(), byteSize); |
michael@0 | 109 | continue; |
michael@0 | 110 | } |
michael@0 | 111 | if (SkDisplayType::IsDisplayable(maker, info->fType)) { |
michael@0 | 112 | SkDisplayable** displayable = (SkDisplayable**) info->memberData(this); |
michael@0 | 113 | if (*displayable == NULL || *displayable == (SkDisplayable*) -1) |
michael@0 | 114 | continue; |
michael@0 | 115 | SkDisplayable* deeper = (*displayable)->deepCopy(maker); |
michael@0 | 116 | info->setMemberData(copy, deeper, sizeof(deeper)); |
michael@0 | 117 | continue; |
michael@0 | 118 | } |
michael@0 | 119 | if (info->fType == SkType_String || info->fType == SkType_DynamicString) { |
michael@0 | 120 | SkString* string; |
michael@0 | 121 | info->getString(this, &string); |
michael@0 | 122 | info->setString(copy, string); |
michael@0 | 123 | continue; |
michael@0 | 124 | } |
michael@0 | 125 | void* data = info->memberData(this); |
michael@0 | 126 | size_t size = SkMemberInfo::GetSize(info->fType); |
michael@0 | 127 | info->setMemberData(copy, data, size); |
michael@0 | 128 | } while (true); |
michael@0 | 129 | copy->dirty(); |
michael@0 | 130 | return copy; |
michael@0 | 131 | } |
michael@0 | 132 | |
michael@0 | 133 | void SkDisplayable::dirty() { |
michael@0 | 134 | } |
michael@0 | 135 | |
michael@0 | 136 | #ifdef SK_DUMP_ENABLED |
michael@0 | 137 | void SkDisplayable::dump(SkAnimateMaker* maker) { |
michael@0 | 138 | dumpBase(maker); |
michael@0 | 139 | #if SK_USE_CONDENSED_INFO == 0 |
michael@0 | 140 | this->dumpAttrs(maker); |
michael@0 | 141 | this->dumpChildren(maker); |
michael@0 | 142 | #endif |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | void SkDisplayable::dumpAttrs(SkAnimateMaker* maker) { |
michael@0 | 146 | SkDisplayTypes type = getType(); |
michael@0 | 147 | if (type == SkType_Unknown) { |
michael@0 | 148 | //SkDebugf("/>\n"); |
michael@0 | 149 | return; |
michael@0 | 150 | } |
michael@0 | 151 | SkDisplayable* blankCopy = SkDisplayType::CreateInstance(maker, type); |
michael@0 | 152 | |
michael@0 | 153 | int index = -1; |
michael@0 | 154 | int propIndex = 0; |
michael@0 | 155 | const SkMemberInfo* info; |
michael@0 | 156 | const SkMemberInfo* blankInfo; |
michael@0 | 157 | SkScriptValue value; |
michael@0 | 158 | SkScriptValue blankValue; |
michael@0 | 159 | SkOperand values[2]; |
michael@0 | 160 | SkOperand blankValues[2]; |
michael@0 | 161 | do { |
michael@0 | 162 | info = this->getMember(++index); |
michael@0 | 163 | if (NULL == info) { |
michael@0 | 164 | //SkDebugf("\n"); |
michael@0 | 165 | break; |
michael@0 | 166 | } |
michael@0 | 167 | if (SkType_MemberProperty == info->fType) { |
michael@0 | 168 | if (getProperty(propIndex, &value)) { |
michael@0 | 169 | blankCopy->getProperty(propIndex, &blankValue); |
michael@0 | 170 | //last two are dummies |
michael@0 | 171 | dumpValues(info, value.fType, value.fOperand, blankValue.fOperand, value.fOperand, blankValue.fOperand); |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | propIndex++; |
michael@0 | 175 | continue; |
michael@0 | 176 | } |
michael@0 | 177 | if (SkDisplayType::IsDisplayable(maker, info->fType)) { |
michael@0 | 178 | continue; |
michael@0 | 179 | } |
michael@0 | 180 | |
michael@0 | 181 | if (info->fType == SkType_MemberFunction) |
michael@0 | 182 | continue; |
michael@0 | 183 | |
michael@0 | 184 | |
michael@0 | 185 | if (info->fType == SkType_Array) { |
michael@0 | 186 | SkTDOperandArray* array = (SkTDOperandArray*) info->memberData(this); |
michael@0 | 187 | int arrayCount; |
michael@0 | 188 | if (array == NULL || (arrayCount = array->count()) == 0) |
michael@0 | 189 | continue; |
michael@0 | 190 | SkDisplayTypes elementType; |
michael@0 | 191 | if (type == SkType_Array) { |
michael@0 | 192 | SkDisplayArray* dispArray = (SkDisplayArray*) this; |
michael@0 | 193 | elementType = dispArray->values.getType(); |
michael@0 | 194 | } else |
michael@0 | 195 | elementType = info->arrayType(); |
michael@0 | 196 | bool firstElem = true; |
michael@0 | 197 | SkDebugf("%s=\"[", info->fName); |
michael@0 | 198 | for (SkOperand* op = array->begin(); op < array->end(); op++) { |
michael@0 | 199 | if (!firstElem) SkDebugf(","); |
michael@0 | 200 | switch (elementType) { |
michael@0 | 201 | case SkType_Displayable: |
michael@0 | 202 | SkDebugf("%s", op->fDisplayable->id); |
michael@0 | 203 | break; |
michael@0 | 204 | case SkType_Int: |
michael@0 | 205 | SkDebugf("%d", op->fS32); |
michael@0 | 206 | break; |
michael@0 | 207 | case SkType_Float: |
michael@0 | 208 | SkDebugf("%g", SkScalarToFloat(op->fScalar)); |
michael@0 | 209 | break; |
michael@0 | 210 | case SkType_String: |
michael@0 | 211 | case SkType_DynamicString: |
michael@0 | 212 | SkDebugf("%s", op->fString->c_str()); |
michael@0 | 213 | break; |
michael@0 | 214 | default: |
michael@0 | 215 | break; |
michael@0 | 216 | } |
michael@0 | 217 | firstElem = false; |
michael@0 | 218 | } |
michael@0 | 219 | SkDebugf("]\" "); |
michael@0 | 220 | continue; |
michael@0 | 221 | } |
michael@0 | 222 | |
michael@0 | 223 | if (info->fType == SkType_String || info->fType == SkType_DynamicString) { |
michael@0 | 224 | SkString* string; |
michael@0 | 225 | info->getString(this, &string); |
michael@0 | 226 | if (string->isEmpty() == false) |
michael@0 | 227 | SkDebugf("%s=\"%s\"\t", info->fName, string->c_str()); |
michael@0 | 228 | continue; |
michael@0 | 229 | } |
michael@0 | 230 | |
michael@0 | 231 | |
michael@0 | 232 | blankInfo = blankCopy->getMember(index); |
michael@0 | 233 | int i = info->fCount; |
michael@0 | 234 | info->getValue(this, values, i); |
michael@0 | 235 | blankInfo->getValue(blankCopy, blankValues, i); |
michael@0 | 236 | dumpValues(info, info->fType, values[0], blankValues[0], values[1], blankValues[1]); |
michael@0 | 237 | } while (true); |
michael@0 | 238 | delete blankCopy; |
michael@0 | 239 | } |
michael@0 | 240 | |
michael@0 | 241 | void SkDisplayable::dumpBase(SkAnimateMaker* maker) { |
michael@0 | 242 | SkDisplayTypes type = getType(); |
michael@0 | 243 | const char* elementName = "(unknown)"; |
michael@0 | 244 | if (type != SkType_Unknown && type != SkType_Screenplay) |
michael@0 | 245 | elementName = SkDisplayType::GetName(maker, type); |
michael@0 | 246 | SkDebugf("%*s", SkDisplayList::fIndent, ""); |
michael@0 | 247 | if (SkDisplayList::fDumpIndex != 0 && SkDisplayList::fIndent == 0) |
michael@0 | 248 | SkDebugf("%d: ", SkDisplayList::fDumpIndex); |
michael@0 | 249 | SkDebugf("<%s ", elementName); |
michael@0 | 250 | if (strcmp(id,"") != 0) |
michael@0 | 251 | SkDebugf("id=\"%s\" ", id); |
michael@0 | 252 | } |
michael@0 | 253 | |
michael@0 | 254 | void SkDisplayable::dumpChildren(SkAnimateMaker* maker, bool closedAngle) { |
michael@0 | 255 | |
michael@0 | 256 | int index = -1; |
michael@0 | 257 | const SkMemberInfo* info; |
michael@0 | 258 | index = -1; |
michael@0 | 259 | SkDisplayList::fIndent += 4; |
michael@0 | 260 | do { |
michael@0 | 261 | info = this->getMember(++index); |
michael@0 | 262 | if (NULL == info) { |
michael@0 | 263 | break; |
michael@0 | 264 | } |
michael@0 | 265 | if (SkDisplayType::IsDisplayable(maker, info->fType)) { |
michael@0 | 266 | SkDisplayable** displayable = (SkDisplayable**) info->memberData(this); |
michael@0 | 267 | if (*displayable == NULL || *displayable == (SkDisplayable*) -1) |
michael@0 | 268 | continue; |
michael@0 | 269 | if (closedAngle == false) { |
michael@0 | 270 | SkDebugf(">\n"); |
michael@0 | 271 | closedAngle = true; |
michael@0 | 272 | } |
michael@0 | 273 | (*displayable)->dump(maker); |
michael@0 | 274 | } |
michael@0 | 275 | } while (true); |
michael@0 | 276 | SkDisplayList::fIndent -= 4; |
michael@0 | 277 | if (closedAngle) |
michael@0 | 278 | dumpEnd(maker); |
michael@0 | 279 | else |
michael@0 | 280 | SkDebugf("/>\n"); |
michael@0 | 281 | } |
michael@0 | 282 | |
michael@0 | 283 | void SkDisplayable::dumpEnd(SkAnimateMaker* maker) { |
michael@0 | 284 | SkDisplayTypes type = getType(); |
michael@0 | 285 | const char* elementName = "(unknown)"; |
michael@0 | 286 | if (type != SkType_Unknown && type != SkType_Screenplay) |
michael@0 | 287 | elementName = SkDisplayType::GetName(maker, type); |
michael@0 | 288 | SkDebugf("%*s", SkDisplayList::fIndent, ""); |
michael@0 | 289 | SkDebugf("</%s>\n", elementName); |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | void SkDisplayable::dumpEvents() { |
michael@0 | 293 | } |
michael@0 | 294 | |
michael@0 | 295 | void SkDisplayable::dumpValues(const SkMemberInfo* info, SkDisplayTypes type, SkOperand op, SkOperand blankOp, |
michael@0 | 296 | SkOperand op2, SkOperand blankOp2) { |
michael@0 | 297 | switch (type) { |
michael@0 | 298 | case SkType_BitmapEncoding: |
michael@0 | 299 | switch (op.fS32) { |
michael@0 | 300 | case 0 : SkDebugf("type=\"jpeg\" "); |
michael@0 | 301 | break; |
michael@0 | 302 | case 1 : SkDebugf("type=\"png\" "); |
michael@0 | 303 | break; |
michael@0 | 304 | default: SkDebugf("type=\"UNDEFINED\" "); |
michael@0 | 305 | } |
michael@0 | 306 | break; |
michael@0 | 307 | //should make this a separate case in dump attrs, rather than make dump values have a larger signature |
michael@0 | 308 | case SkType_Point: |
michael@0 | 309 | if (op.fScalar != blankOp.fScalar || op2.fScalar != blankOp.fScalar) { |
michael@0 | 310 | SkDebugf("%s=\"[%g,%g]\" ", info->fName, SkScalarToFloat(op.fScalar), SkScalarToFloat(op2.fScalar)); |
michael@0 | 311 | } |
michael@0 | 312 | break; |
michael@0 | 313 | case SkType_FromPathMode: |
michael@0 | 314 | switch (op.fS32) { |
michael@0 | 315 | case 0: |
michael@0 | 316 | //don't want to print anything for 0, just adding it to remove it from default: |
michael@0 | 317 | break; |
michael@0 | 318 | case 1: |
michael@0 | 319 | SkDebugf("%s=\"%s\" ", info->fName, "angle"); |
michael@0 | 320 | break; |
michael@0 | 321 | case 2: |
michael@0 | 322 | SkDebugf("%s=\"%s\" ", info->fName, "position"); |
michael@0 | 323 | break; |
michael@0 | 324 | default: |
michael@0 | 325 | SkDebugf("%s=\"INVALID\" ", info->fName); |
michael@0 | 326 | } |
michael@0 | 327 | break; |
michael@0 | 328 | case SkType_MaskFilterBlurStyle: |
michael@0 | 329 | switch (op.fS32) { |
michael@0 | 330 | case 0: |
michael@0 | 331 | break; |
michael@0 | 332 | case 1: |
michael@0 | 333 | SkDebugf("%s=\"%s\" ", info->fName, "solid"); |
michael@0 | 334 | break; |
michael@0 | 335 | case 2: |
michael@0 | 336 | SkDebugf("%s=\"%s\" ", info->fName, "outer"); |
michael@0 | 337 | break; |
michael@0 | 338 | case 3: |
michael@0 | 339 | SkDebugf("%s=\"%s\" ", info->fName, "inner"); |
michael@0 | 340 | break; |
michael@0 | 341 | default: |
michael@0 | 342 | SkDebugf("%s=\"INVALID\" ", info->fName); |
michael@0 | 343 | } |
michael@0 | 344 | break; |
michael@0 | 345 | case SkType_FilterType: |
michael@0 | 346 | if (op.fS32 == 1) |
michael@0 | 347 | SkDebugf("%s=\"%s\" ", info->fName, "bilinear"); |
michael@0 | 348 | break; |
michael@0 | 349 | case SkType_PathDirection: |
michael@0 | 350 | SkDebugf("%s=\"%s\" ", info->fName, op.fS32 == 0 ? "cw" : "ccw"); |
michael@0 | 351 | break; |
michael@0 | 352 | case SkType_FillType: |
michael@0 | 353 | SkDebugf("%s=\"%s\" ", info->fName, op.fS32 == 0 ? "winding" : "evenOdd"); |
michael@0 | 354 | break; |
michael@0 | 355 | case SkType_TileMode: |
michael@0 | 356 | //correct to look at the S32? |
michael@0 | 357 | if (op.fS32 != blankOp.fS32) |
michael@0 | 358 | SkDebugf("%s=\"%s\" ", info->fName, op.fS32 == 0 ? "clamp" : op.fS32 == 1 ? "repeat" : "mirror"); |
michael@0 | 359 | break; |
michael@0 | 360 | case SkType_Boolean: |
michael@0 | 361 | if (op.fS32 != blankOp.fS32) |
michael@0 | 362 | SkDebugf("%s=\"%s\" ", info->fName, op.fS32 == 0 ? "false" : "true"); |
michael@0 | 363 | break; |
michael@0 | 364 | case SkType_Int: |
michael@0 | 365 | if (op.fS32 != blankOp.fS32) |
michael@0 | 366 | SkDebugf(" %s=\"%d\" ", info->fName, op.fS32); |
michael@0 | 367 | break; |
michael@0 | 368 | case SkType_Float: |
michael@0 | 369 | if (op.fScalar != blankOp.fScalar) { //or /65536? |
michael@0 | 370 | SkDebugf("%s=\"%g\" ", info->fName, SkScalarToFloat(op.fScalar)); |
michael@0 | 371 | } |
michael@0 | 372 | break; |
michael@0 | 373 | case SkType_String: |
michael@0 | 374 | case SkType_DynamicString: |
michael@0 | 375 | if (op.fString->size() > 0) |
michael@0 | 376 | SkDebugf("%s=\"%s\" ", info->fName, op.fString->c_str()); |
michael@0 | 377 | break; |
michael@0 | 378 | case SkType_MSec: |
michael@0 | 379 | if (op.fS32 != blankOp.fS32) { |
michael@0 | 380 | SkDebugf(" %s=\"%g\" ", info->fName, SkScalarToFloat(SkScalarDiv(op.fS32, 1000))); |
michael@0 | 381 | } |
michael@0 | 382 | default: |
michael@0 | 383 | SkDebugf(""); |
michael@0 | 384 | } |
michael@0 | 385 | } |
michael@0 | 386 | |
michael@0 | 387 | #endif |
michael@0 | 388 | |
michael@0 | 389 | bool SkDisplayable::enable( SkAnimateMaker& ) { |
michael@0 | 390 | return false; |
michael@0 | 391 | } |
michael@0 | 392 | |
michael@0 | 393 | void SkDisplayable::enableBounder() { |
michael@0 | 394 | } |
michael@0 | 395 | |
michael@0 | 396 | void SkDisplayable::executeFunction(SkDisplayable* , int index, |
michael@0 | 397 | SkTDArray<SkScriptValue>& , SkDisplayTypes, SkScriptValue* ) { |
michael@0 | 398 | SkASSERT(0); |
michael@0 | 399 | } |
michael@0 | 400 | |
michael@0 | 401 | void SkDisplayable::executeFunction(SkDisplayable* target, |
michael@0 | 402 | const SkMemberInfo* info, SkTypedArray* values, SkScriptValue* value) { |
michael@0 | 403 | SkTDArray<SkScriptValue> typedValues; |
michael@0 | 404 | for (SkOperand* op = values->begin(); op < values->end(); op++) { |
michael@0 | 405 | SkScriptValue temp; |
michael@0 | 406 | temp.fType = values->getType(); |
michael@0 | 407 | temp.fOperand = *op; |
michael@0 | 408 | *typedValues.append() = temp; |
michael@0 | 409 | } |
michael@0 | 410 | executeFunction(target, info->functionIndex(), typedValues, info->getType(), value); |
michael@0 | 411 | } |
michael@0 | 412 | |
michael@0 | 413 | void SkDisplayable::executeFunction2(SkDisplayable* , int index, |
michael@0 | 414 | SkOpArray* params, SkDisplayTypes, SkOperand2* ) { |
michael@0 | 415 | SkASSERT(0); |
michael@0 | 416 | } |
michael@0 | 417 | |
michael@0 | 418 | void SkDisplayable::getBounds(SkRect* rect) { |
michael@0 | 419 | SkASSERT(rect); |
michael@0 | 420 | rect->fLeft = rect->fTop = SK_ScalarMax; |
michael@0 | 421 | rect->fRight= rect->fBottom = -SK_ScalarMax; |
michael@0 | 422 | } |
michael@0 | 423 | |
michael@0 | 424 | const SkFunctionParamType* SkDisplayable::getFunctionsParameters() { |
michael@0 | 425 | return NULL; |
michael@0 | 426 | } |
michael@0 | 427 | |
michael@0 | 428 | const SkMemberInfo* SkDisplayable::getMember(int index) { |
michael@0 | 429 | return NULL; |
michael@0 | 430 | } |
michael@0 | 431 | |
michael@0 | 432 | const SkMemberInfo* SkDisplayable::getMember(const char name[]) { |
michael@0 | 433 | return NULL; |
michael@0 | 434 | } |
michael@0 | 435 | |
michael@0 | 436 | const SkFunctionParamType* SkDisplayable::getParameters(const SkMemberInfo* info, |
michael@0 | 437 | int* paramCount) { |
michael@0 | 438 | const SkFunctionParamType* params = getFunctionsParameters(); |
michael@0 | 439 | SkASSERT(params != NULL); |
michael@0 | 440 | int funcIndex = info->functionIndex(); |
michael@0 | 441 | // !!! eventually break traversing params into an external function (maybe this whole function) |
michael@0 | 442 | int index = funcIndex; |
michael@0 | 443 | int offset = 0; |
michael@0 | 444 | while (--index >= 0) { |
michael@0 | 445 | while (params[offset] != 0) |
michael@0 | 446 | offset++; |
michael@0 | 447 | offset++; |
michael@0 | 448 | } |
michael@0 | 449 | int count = 0; |
michael@0 | 450 | while (params[offset] != 0) { |
michael@0 | 451 | count++; |
michael@0 | 452 | offset++; |
michael@0 | 453 | } |
michael@0 | 454 | *paramCount = count; |
michael@0 | 455 | return ¶ms[offset - count]; |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | SkDisplayable* SkDisplayable::getParent() const { |
michael@0 | 459 | return NULL; |
michael@0 | 460 | } |
michael@0 | 461 | |
michael@0 | 462 | bool SkDisplayable::getProperty(int index, SkScriptValue* ) const { |
michael@0 | 463 | // SkASSERT(0); |
michael@0 | 464 | return false; |
michael@0 | 465 | } |
michael@0 | 466 | |
michael@0 | 467 | bool SkDisplayable::getProperty2(int index, SkOperand2* value) const { |
michael@0 | 468 | SkASSERT(0); |
michael@0 | 469 | return false; |
michael@0 | 470 | } |
michael@0 | 471 | |
michael@0 | 472 | SkDisplayTypes SkDisplayable::getType() const { |
michael@0 | 473 | return SkType_Unknown; |
michael@0 | 474 | } |
michael@0 | 475 | |
michael@0 | 476 | bool SkDisplayable::hasEnable() const { |
michael@0 | 477 | return false; |
michael@0 | 478 | } |
michael@0 | 479 | |
michael@0 | 480 | bool SkDisplayable::isDrawable() const { |
michael@0 | 481 | return false; |
michael@0 | 482 | } |
michael@0 | 483 | |
michael@0 | 484 | void SkDisplayable::onEndElement(SkAnimateMaker& ) {} |
michael@0 | 485 | |
michael@0 | 486 | const SkMemberInfo* SkDisplayable::preferredChild(SkDisplayTypes type) { |
michael@0 | 487 | return NULL; |
michael@0 | 488 | } |
michael@0 | 489 | |
michael@0 | 490 | bool SkDisplayable::resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply) { |
michael@0 | 491 | return false; |
michael@0 | 492 | } |
michael@0 | 493 | |
michael@0 | 494 | //SkDisplayable* SkDisplayable::resolveTarget(SkAnimateMaker& ) { |
michael@0 | 495 | // return this; |
michael@0 | 496 | //} |
michael@0 | 497 | |
michael@0 | 498 | void SkDisplayable::setChildHasID() { |
michael@0 | 499 | } |
michael@0 | 500 | |
michael@0 | 501 | bool SkDisplayable::setParent(SkDisplayable* ) { |
michael@0 | 502 | return false; |
michael@0 | 503 | } |
michael@0 | 504 | |
michael@0 | 505 | bool SkDisplayable::setProperty(int index, SkScriptValue& ) { |
michael@0 | 506 | //SkASSERT(0); |
michael@0 | 507 | return false; |
michael@0 | 508 | } |
michael@0 | 509 | |
michael@0 | 510 | void SkDisplayable::setReference(const SkMemberInfo* info, SkDisplayable* displayable) { |
michael@0 | 511 | if (info->fType == SkType_MemberProperty) { |
michael@0 | 512 | SkScriptValue scriptValue; |
michael@0 | 513 | scriptValue.fOperand.fDisplayable = displayable; |
michael@0 | 514 | scriptValue.fType = displayable->getType(); |
michael@0 | 515 | setProperty(info->propertyIndex(), scriptValue); |
michael@0 | 516 | } else if (info->fType == SkType_Array) { |
michael@0 | 517 | SkASSERT(displayable->getType() == SkType_Array); |
michael@0 | 518 | SkDisplayArray* dispArray = (SkDisplayArray*) displayable; |
michael@0 | 519 | SkTDScalarArray* array = (SkTDScalarArray* ) info->memberData(this); |
michael@0 | 520 | array->setCount(dispArray->values.count()); |
michael@0 | 521 | memcpy(array->begin(), dispArray->values.begin(), dispArray->values.count() * sizeof(int)); |
michael@0 | 522 | // |
michael@0 | 523 | |
michael@0 | 524 | // !!! need a way for interpreter engine to own array |
michael@0 | 525 | // !!! probably need to replace all scriptable arrays with single bigger array |
michael@0 | 526 | // that has operand and type on every element -- or |
michael@0 | 527 | // when array is dirtied, need to get parent to reparse to local array |
michael@0 | 528 | } else { |
michael@0 | 529 | void* storage = info->memberData(this); |
michael@0 | 530 | memcpy(storage, &displayable, sizeof(SkDisplayable*)); |
michael@0 | 531 | } |
michael@0 | 532 | // !!! unclear why displayable is dirtied here |
michael@0 | 533 | // if this is called, this breaks fromPath.xml |
michael@0 | 534 | // displayable->dirty(); |
michael@0 | 535 | } |
michael@0 | 536 | |
michael@0 | 537 | #ifdef SK_DEBUG |
michael@0 | 538 | void SkDisplayable::validate() { |
michael@0 | 539 | } |
michael@0 | 540 | #endif |