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 "SkDisplayApply.h" | 10 #include "SkDisplayApply.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 SK_MEMBER_PROPERTY(steps, Int), | 49 SK_MEMBER_PROPERTY(steps, Int), |
50 SK_MEMBER_PROPERTY(time, MSec), | 50 SK_MEMBER_PROPERTY(time, MSec), |
51 SK_MEMBER(transition, ApplyTransition) | 51 SK_MEMBER(transition, ApplyTransition) |
52 }; | 52 }; |
53 | 53 |
54 #endif | 54 #endif |
55 | 55 |
56 DEFINE_GET_MEMBER(SkApply); | 56 DEFINE_GET_MEMBER(SkApply); |
57 | 57 |
58 SkApply::SkApply() : begin(0), dontDraw(false), interval((SkMSec) -1), mode((Mod
e) -1), /*pickup(false), */ | 58 SkApply::SkApply() : begin(0), dontDraw(false), interval((SkMSec) -1), mode((Mod
e) -1), /*pickup(false), */ |
59 restore(false), scope(NULL), steps(-1), transition((Transition) -1), fActive
(NULL), /*fCurrentScope(NULL),*/ | 59 restore(false), scope(nullptr), steps(-1), transition((Transition) -1), fAct
ive(nullptr), /*fCurrentScope(nullptr),*/ |
60 fLastTime(0), fAppended(false), fContainsScope(false), fDeleteScope(false),
fEmbedded(false), | 60 fLastTime(0), fAppended(false), fContainsScope(false), fDeleteScope(false),
fEmbedded(false), |
61 fEnabled(false), fEnabling(false) { | 61 fEnabled(false), fEnabling(false) { |
62 } | 62 } |
63 | 63 |
64 SkApply::~SkApply() { | 64 SkApply::~SkApply() { |
65 for (SkADrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr+
+) | 65 for (SkADrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr+
+) |
66 delete *curPtr; | 66 delete *curPtr; |
67 if (fDeleteScope) | 67 if (fDeleteScope) |
68 delete scope; | 68 delete scope; |
69 // !!! caller must call maker.removeActive(fActive) | 69 // !!! caller must call maker.removeActive(fActive) |
70 delete fActive; | 70 delete fActive; |
71 } | 71 } |
72 | 72 |
73 void SkApply::activate(SkAnimateMaker& maker) { | 73 void SkApply::activate(SkAnimateMaker& maker) { |
74 if (fActive != NULL) { | 74 if (fActive != nullptr) { |
75 if (fActive->fDrawIndex == 0 && fActive->fDrawMax == 0) | 75 if (fActive->fDrawIndex == 0 && fActive->fDrawMax == 0) |
76 return; // if only one use, nothing more to do | 76 return; // if only one use, nothing more to do |
77 if (restore == false) | 77 if (restore == false) |
78 return; // all share same state, regardless of instance number | 78 return; // all share same state, regardless of instance number |
79 bool save = fActive->initializeSave(); | 79 bool save = fActive->initializeSave(); |
80 fActive->fixInterpolator(save); | 80 fActive->fixInterpolator(save); |
81 } else { | 81 } else { |
82 fActive = new SkActive(*this, maker); | 82 fActive = new SkActive(*this, maker); |
83 fActive->init(); | 83 fActive->init(); |
84 maker.appendActive(fActive); | 84 maker.appendActive(fActive); |
85 if (restore) { | 85 if (restore) { |
86 fActive->initializeSave(); | 86 fActive->initializeSave(); |
87 int animators = fAnimators.count(); | 87 int animators = fAnimators.count(); |
88 for (int index = 0; index < animators; index++) | 88 for (int index = 0; index < animators; index++) |
89 fActive->saveInterpolatorValues(index); | 89 fActive->saveInterpolatorValues(index); |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 void SkApply::append(SkApply* apply) { | 94 void SkApply::append(SkApply* apply) { |
95 if (fActive == NULL) | 95 if (fActive == nullptr) |
96 return; | 96 return; |
97 int oldCount = fActive->fAnimators.count(); | 97 int oldCount = fActive->fAnimators.count(); |
98 fActive->append(apply); | 98 fActive->append(apply); |
99 if (restore) { | 99 if (restore) { |
100 fActive->appendSave(oldCount); | 100 fActive->appendSave(oldCount); |
101 int newCount = fActive->fAnimators.count(); | 101 int newCount = fActive->fAnimators.count(); |
102 for (int index = oldCount; index < newCount; index++) | 102 for (int index = oldCount; index < newCount; index++) |
103 fActive->saveInterpolatorValues(index); | 103 fActive->saveInterpolatorValues(index); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void SkApply::applyValues(int animatorIndex, SkOperand* values, int count, | 107 void SkApply::applyValues(int animatorIndex, SkOperand* values, int count, |
108 SkDisplayTypes valuesType, SkMSec time) | 108 SkDisplayTypes valuesType, SkMSec time) |
109 { | 109 { |
110 SkAnimateBase* animator = fActive->fAnimators[animatorIndex]; | 110 SkAnimateBase* animator = fActive->fAnimators[animatorIndex]; |
111 const SkMemberInfo * info = animator->fFieldInfo; | 111 const SkMemberInfo * info = animator->fFieldInfo; |
112 SkASSERT(animator); | 112 SkASSERT(animator); |
113 SkASSERT(info != NULL); | 113 SkASSERT(info != nullptr); |
114 SkDisplayTypes type = (SkDisplayTypes) info->fType; | 114 SkDisplayTypes type = (SkDisplayTypes) info->fType; |
115 SkDisplayable* target = getTarget(animator); | 115 SkDisplayable* target = getTarget(animator); |
116 if (animator->hasExecute() || type == SkType_MemberFunction || type == SkTyp
e_MemberProperty) { | 116 if (animator->hasExecute() || type == SkType_MemberFunction || type == SkTyp
e_MemberProperty) { |
117 SkDisplayable* executor = animator->hasExecute() ? animator : target; | 117 SkDisplayable* executor = animator->hasExecute() ? animator : target; |
118 if (type != SkType_MemberProperty) { | 118 if (type != SkType_MemberProperty) { |
119 SkTDArray<SkScriptValue> typedValues; | 119 SkTDArray<SkScriptValue> typedValues; |
120 for (int index = 0; index < count; index++) { | 120 for (int index = 0; index < count; index++) { |
121 SkScriptValue temp; | 121 SkScriptValue temp; |
122 temp.fType = valuesType; | 122 temp.fType = valuesType; |
123 temp.fOperand = values[index]; | 123 temp.fOperand = values[index]; |
124 *typedValues.append() = temp; | 124 *typedValues.append() = temp; |
125 } | 125 } |
126 executor->executeFunction(target, info->functionIndex(), typedValues
, info->getType(), NULL); | 126 executor->executeFunction(target, info->functionIndex(), typedValues
, info->getType(), nullptr); |
127 } else { | 127 } else { |
128 SkScriptValue scriptValue; | 128 SkScriptValue scriptValue; |
129 scriptValue.fOperand = values[0]; | 129 scriptValue.fOperand = values[0]; |
130 scriptValue.fType = info->getType(); | 130 scriptValue.fType = info->getType(); |
131 target->setProperty(info->propertyIndex(), scriptValue); | 131 target->setProperty(info->propertyIndex(), scriptValue); |
132 } | 132 } |
133 } else { | 133 } else { |
134 SkTypedArray converted; | 134 SkTypedArray converted; |
135 if (type == SkType_ARGB) { | 135 if (type == SkType_ARGB) { |
136 if (count == 4) { | 136 if (count == 4) { |
(...skipping 18 matching lines...) Expand all Loading... |
155 bool SkApply::contains(SkDisplayable* child) { | 155 bool SkApply::contains(SkDisplayable* child) { |
156 for (SkADrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr+
+) { | 156 for (SkADrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr+
+) { |
157 if (*curPtr == child || (*curPtr)->contains(child)) | 157 if (*curPtr == child || (*curPtr)->contains(child)) |
158 return true; | 158 return true; |
159 } | 159 } |
160 return fDeleteScope && scope == child; | 160 return fDeleteScope && scope == child; |
161 } | 161 } |
162 | 162 |
163 SkDisplayable* SkApply::deepCopy(SkAnimateMaker* maker) { | 163 SkDisplayable* SkApply::deepCopy(SkAnimateMaker* maker) { |
164 SkADrawable* saveScope = scope; | 164 SkADrawable* saveScope = scope; |
165 scope = NULL; | 165 scope = nullptr; |
166 SkApply* result = (SkApply*) INHERITED::deepCopy(maker); | 166 SkApply* result = (SkApply*) INHERITED::deepCopy(maker); |
167 result->scope = scope = saveScope; | 167 result->scope = scope = saveScope; |
168 SkAnimateBase** end = fAnimators.end(); | 168 SkAnimateBase** end = fAnimators.end(); |
169 for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < end; animPtr++)
{ | 169 for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < end; animPtr++)
{ |
170 SkAnimateBase* anim = (SkAnimateBase*) (*animPtr)->deepCopy(maker); | 170 SkAnimateBase* anim = (SkAnimateBase*) (*animPtr)->deepCopy(maker); |
171 *result->fAnimators.append() = anim; | 171 *result->fAnimators.append() = anim; |
172 maker->helperAdd(anim); | 172 maker->helperAdd(anim); |
173 } | 173 } |
174 return result; | 174 return result; |
175 } | 175 } |
176 | 176 |
177 void SkApply::disable() { | 177 void SkApply::disable() { |
178 //!!! this is the right thing to do, but has bad side effects because of oth
er problems | 178 //!!! this is the right thing to do, but has bad side effects because of oth
er problems |
179 // currently, if an apply is in a g and scopes a statement in another g, it
ends up as members | 179 // currently, if an apply is in a g and scopes a statement in another g, it
ends up as members |
180 // of both containers. The disabling here incorrectly disables both instance
s | 180 // of both containers. The disabling here incorrectly disables both instance
s |
181 // maybe the fEnabled flag needs to be moved to the fActive data so that bot
h | 181 // maybe the fEnabled flag needs to be moved to the fActive data so that bot
h |
182 // instances are not affected. | 182 // instances are not affected. |
183 // fEnabled = false; | 183 // fEnabled = false; |
184 } | 184 } |
185 | 185 |
186 bool SkApply::draw(SkAnimateMaker& maker) { | 186 bool SkApply::draw(SkAnimateMaker& maker) { |
187 if (scope ==NULL) | 187 if (scope ==nullptr) |
188 return false; | 188 return false; |
189 if (scope->isApply() || scope->isDrawable() == false) | 189 if (scope->isApply() || scope->isDrawable() == false) |
190 return false; | 190 return false; |
191 if (fEnabled == false) | 191 if (fEnabled == false) |
192 enable(maker); | 192 enable(maker); |
193 SkASSERT(scope); | 193 SkASSERT(scope); |
194 activate(maker); | 194 activate(maker); |
195 if (mode == kMode_immediate) | 195 if (mode == kMode_immediate) |
196 return fActive->draw(); | 196 return fActive->draw(); |
197 bool result = interpolate(maker, maker.getInTime()); | 197 bool result = interpolate(maker, maker.getInTime()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 SkDisplayList::fDumpIndex = save; | 255 SkDisplayList::fDumpIndex = save; |
256 if (closedYet) | 256 if (closedYet) |
257 dumpEnd(maker); | 257 dumpEnd(maker); |
258 else | 258 else |
259 SkDebugf("/>\n"); | 259 SkDebugf("/>\n"); |
260 } | 260 } |
261 #endif | 261 #endif |
262 | 262 |
263 bool SkApply::enable(SkAnimateMaker& maker) { | 263 bool SkApply::enable(SkAnimateMaker& maker) { |
264 fEnabled = true; | 264 fEnabled = true; |
265 bool initialized = fActive != NULL; | 265 bool initialized = fActive != nullptr; |
266 if (dynamicScope.size() > 0) | 266 if (dynamicScope.size() > 0) |
267 enableDynamic(maker); | 267 enableDynamic(maker); |
268 if (maker.fError.hasError()) | 268 if (maker.fError.hasError()) |
269 return false; | 269 return false; |
270 int animators = fAnimators.count(); | 270 int animators = fAnimators.count(); |
271 int index; | 271 int index; |
272 for (index = 0; index < animators; index++) { | 272 for (index = 0; index < animators; index++) { |
273 SkAnimateBase* animator = fAnimators[index]; | 273 SkAnimateBase* animator = fAnimators[index]; |
274 animator->fStart = maker.fEnableTime; | 274 animator->fStart = maker.fEnableTime; |
275 animator->fResetPending = animator->fReset; | 275 animator->fResetPending = animator->fReset; |
276 } | 276 } |
277 if (scope && scope->isApply()) | 277 if (scope && scope->isApply()) |
278 ((SkApply*) scope)->setEmbedded(); | 278 ((SkApply*) scope)->setEmbedded(); |
279 /* if (mode == kMode_once) { | 279 /* if (mode == kMode_once) { |
280 if (scope) { | 280 if (scope) { |
281 activate(maker); | 281 activate(maker); |
282 interpolate(maker, maker.fEnableTime); | 282 interpolate(maker, maker.fEnableTime); |
283 inactivate(maker); | 283 inactivate(maker); |
284 } | 284 } |
285 return true; | 285 return true; |
286 }*/ | 286 }*/ |
287 if ((mode == kMode_immediate || mode == kMode_create) && scope == NULL) | 287 if ((mode == kMode_immediate || mode == kMode_create) && scope == nullptr) |
288 return false; // !!! error? | 288 return false; // !!! error? |
289 bool enableMe = scope && (scope->hasEnable() || scope->isApply() || scope->i
sDrawable() == false); | 289 bool enableMe = scope && (scope->hasEnable() || scope->isApply() || scope->i
sDrawable() == false); |
290 if ((mode == kMode_immediate && enableMe) || mode == kMode_create) | 290 if ((mode == kMode_immediate && enableMe) || mode == kMode_create) |
291 activate(maker); // for non-drawables like post, prime them here | 291 activate(maker); // for non-drawables like post, prime them here |
292 if (mode == kMode_immediate && enableMe) | 292 if (mode == kMode_immediate && enableMe) |
293 fActive->enable(); | 293 fActive->enable(); |
294 if (mode == kMode_create && scope != NULL) { | 294 if (mode == kMode_create && scope != nullptr) { |
295 enableCreate(maker); | 295 enableCreate(maker); |
296 return true; | 296 return true; |
297 } | 297 } |
298 if (mode == kMode_immediate) { | 298 if (mode == kMode_immediate) { |
299 return scope->isApply() || scope->isDrawable() == false; | 299 return scope->isApply() || scope->isDrawable() == false; |
300 } | 300 } |
301 refresh(maker); | 301 refresh(maker); |
302 SkDisplayList& displayList = maker.fDisplayList; | 302 SkDisplayList& displayList = maker.fDisplayList; |
303 SkADrawable* drawable; | 303 SkADrawable* drawable; |
304 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING | 304 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING |
305 SkString debugOut; | 305 SkString debugOut; |
306 SkMSec time = maker.getAppTime(); | 306 SkMSec time = maker.getAppTime(); |
307 debugOut.appendS32(time - maker.fDebugTimeBase); | 307 debugOut.appendS32(time - maker.fDebugTimeBase); |
308 debugOut.append(" apply enable id="); | 308 debugOut.append(" apply enable id="); |
309 debugOut.append(_id); | 309 debugOut.append(_id); |
310 debugOut.append("; start="); | 310 debugOut.append("; start="); |
311 debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase); | 311 debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase); |
312 SkDebugf("%s\n", debugOut.c_str()); | 312 SkDebugf("%s\n", debugOut.c_str()); |
313 #endif | 313 #endif |
314 if (scope == NULL || scope->isApply() || scope->getType() == SkType_Movie ||
scope->isDrawable() == false) { | 314 if (scope == nullptr || scope->isApply() || scope->getType() == SkType_Movie
|| scope->isDrawable() == false) { |
315 activate(maker); // for non-drawables like post, prime them here | 315 activate(maker); // for non-drawables like post, prime them here |
316 if (initialized) { | 316 if (initialized) { |
317 append(this); | 317 append(this); |
318 } | 318 } |
319 fEnabling = true; | 319 fEnabling = true; |
320 interpolate(maker, maker.fEnableTime); | 320 interpolate(maker, maker.fEnableTime); |
321 fEnabling = false; | 321 fEnabling = false; |
322 if (scope != NULL && dontDraw == false) | 322 if (scope != nullptr && dontDraw == false) |
323 scope->enable(maker); | 323 scope->enable(maker); |
324 return true; | 324 return true; |
325 } else if (initialized && restore == false) | 325 } else if (initialized && restore == false) |
326 append(this); | 326 append(this); |
327 #if 0 | 327 #if 0 |
328 bool wasActive = inactivate(maker); // start fresh | 328 bool wasActive = inactivate(maker); // start fresh |
329 if (wasActive) { | 329 if (wasActive) { |
330 activate(maker); | 330 activate(maker); |
331 interpolate(maker, maker.fEnableTime); | 331 interpolate(maker, maker.fEnableTime); |
332 return true; | 332 return true; |
(...skipping 25 matching lines...) Expand all Loading... |
358 *parentList->append() = this; | 358 *parentList->append() = this; |
359 } else | 359 } else |
360 maker.setErrorCode(SkDisplayXMLParserError::kDisplayTreeTooDeep)
; | 360 maker.setErrorCode(SkDisplayXMLParserError::kDisplayTreeTooDeep)
; |
361 old = -1; | 361 old = -1; |
362 } else | 362 } else |
363 reset(); | 363 reset(); |
364 } else { | 364 } else { |
365 SkASSERT(old < parentList->count()); | 365 SkASSERT(old < parentList->count()); |
366 if ((*parentList)[old]->isApply()) { | 366 if ((*parentList)[old]->isApply()) { |
367 SkApply* apply = (SkApply*) (*parentList)[old]; | 367 SkApply* apply = (SkApply*) (*parentList)[old]; |
368 if (apply != this && apply->fActive == NULL) | 368 if (apply != this && apply->fActive == nullptr) |
369 apply->activate(maker); | 369 apply->activate(maker); |
370 apply->append(this); | 370 apply->append(this); |
371 parentGroup = NULL; | 371 parentGroup = nullptr; |
372 } else { | 372 } else { |
373 if (parentGroup) | 373 if (parentGroup) |
374 parentGroup->markCopySize(old); | 374 parentGroup->markCopySize(old); |
375 SkADrawable** newApplyLocation = &(*parentList)[old]; | 375 SkADrawable** newApplyLocation = &(*parentList)[old]; |
376 SkGroup* pGroup; | 376 SkGroup* pGroup; |
377 int oldApply = displayList.findGroup(this, &parentList, &pGroup, &th
isGroup, &grandList); | 377 int oldApply = displayList.findGroup(this, &parentList, &pGroup, &th
isGroup, &grandList); |
378 if (oldApply >= 0) { | 378 if (oldApply >= 0) { |
379 (*parentList)[oldApply] = (SkADrawable*) SkDisplayType::CreateIn
stance(&maker, SkType_Apply); | 379 (*parentList)[oldApply] = (SkADrawable*) SkDisplayType::CreateIn
stance(&maker, SkType_Apply); |
380 parentGroup = NULL; | 380 parentGroup = nullptr; |
381 fDeleteScope = true; | 381 fDeleteScope = true; |
382 } | 382 } |
383 *newApplyLocation = this; | 383 *newApplyLocation = this; |
384 } | 384 } |
385 } | 385 } |
386 if (parentGroup) { | 386 if (parentGroup) { |
387 parentGroup->markCopySet(old); | 387 parentGroup->markCopySet(old); |
388 fDeleteScope = dynamicScope.size() == 0; | 388 fDeleteScope = dynamicScope.size() == 0; |
389 } | 389 } |
390 return true; | 390 return true; |
391 } | 391 } |
392 | 392 |
393 void SkApply::enableCreate(SkAnimateMaker& maker) { | 393 void SkApply::enableCreate(SkAnimateMaker& maker) { |
394 SkString newID; | 394 SkString newID; |
395 for (int step = 0; step <= steps; step++) { | 395 for (int step = 0; step <= steps; step++) { |
396 fLastTime = step * SK_MSec1; | 396 fLastTime = step * SK_MSec1; |
397 bool success = maker.computeID(scope, this, &newID); | 397 bool success = maker.computeID(scope, this, &newID); |
398 if (success == false) | 398 if (success == false) |
399 return; | 399 return; |
400 if (maker.find(newID.c_str(), NULL)) | 400 if (maker.find(newID.c_str(), nullptr)) |
401 continue; | 401 continue; |
402 SkApply* copy = (SkApply*) deepCopy(&maker); // work on copy of animator
state | 402 SkApply* copy = (SkApply*) deepCopy(&maker); // work on copy of animator
state |
403 if (mode == kMode_create) | 403 if (mode == kMode_create) |
404 copy->mode = (Mode) -1; | 404 copy->mode = (Mode) -1; |
405 SkADrawable* copyScope = copy->scope = (SkADrawable*) scope->deepCopy(&m
aker); | 405 SkADrawable* copyScope = copy->scope = (SkADrawable*) scope->deepCopy(&m
aker); |
406 *fScopes.append() = copyScope; | 406 *fScopes.append() = copyScope; |
407 if (copyScope->resolveIDs(maker, scope, this)) { | 407 if (copyScope->resolveIDs(maker, scope, this)) { |
408 step = steps; // quit | 408 step = steps; // quit |
409 goto next; // resolveIDs failed | 409 goto next; // resolveIDs failed |
410 } | 410 } |
(...skipping 11 matching lines...) Expand all Loading... |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 void SkApply::enableDynamic(SkAnimateMaker& maker) { | 425 void SkApply::enableDynamic(SkAnimateMaker& maker) { |
426 SkASSERT(mode != kMode_create); // create + dynamic are not currently compat
ible | 426 SkASSERT(mode != kMode_create); // create + dynamic are not currently compat
ible |
427 SkDisplayable* newScope; | 427 SkDisplayable* newScope; |
428 bool success = SkAnimatorScript::EvaluateDisplayable(maker, this, dynamicSco
pe.c_str(), | 428 bool success = SkAnimatorScript::EvaluateDisplayable(maker, this, dynamicSco
pe.c_str(), |
429 &newScope); | 429 &newScope); |
430 if (success && scope != newScope) { | 430 if (success && scope != newScope) { |
431 SkTDDrawableArray* pList, * gList; | 431 SkTDDrawableArray* pList, * gList; |
432 SkGroup* pGroup = NULL, * found = NULL; | 432 SkGroup* pGroup = nullptr, * found = nullptr; |
433 int old = maker.fDisplayList.findGroup(scope, &pList, &pGroup, &found, &
gList); | 433 int old = maker.fDisplayList.findGroup(scope, &pList, &pGroup, &found, &
gList); |
434 if (pList && old >= 0 && (*pList)[old]->isApply() && (*pList)[old] != th
is) { | 434 if (pList && old >= 0 && (*pList)[old]->isApply() && (*pList)[old] != th
is) { |
435 if (fAppended == false) { | 435 if (fAppended == false) { |
436 if (found != NULL) { | 436 if (found != nullptr) { |
437 SkDisplayable* oldChild = (*pList)[old]; | 437 SkDisplayable* oldChild = (*pList)[old]; |
438 if (oldChild->isApply() && found->copySet(old)) { | 438 if (oldChild->isApply() && found->copySet(old)) { |
439 found->markCopyClear(old); | 439 found->markCopyClear(old); |
440 // delete oldChild; | 440 // delete oldChild; |
441 } | 441 } |
442 } | 442 } |
443 (*pList)[old] = scope; | 443 (*pList)[old] = scope; |
444 } else | 444 } else |
445 pList->remove(old); | 445 pList->remove(old); |
446 } | 446 } |
447 scope = (SkADrawable*) newScope; | 447 scope = (SkADrawable*) newScope; |
448 onEndElement(maker); | 448 onEndElement(maker); |
449 } | 449 } |
450 maker.removeActive(fActive); | 450 maker.removeActive(fActive); |
451 delete fActive; | 451 delete fActive; |
452 fActive = NULL; | 452 fActive = nullptr; |
453 } | 453 } |
454 | 454 |
455 void SkApply::endSave(int index) { | 455 void SkApply::endSave(int index) { |
456 SkAnimateBase* animate = fActive->fAnimators[index]; | 456 SkAnimateBase* animate = fActive->fAnimators[index]; |
457 const SkMemberInfo* info = animate->fFieldInfo; | 457 const SkMemberInfo* info = animate->fFieldInfo; |
458 SkDisplayTypes type = (SkDisplayTypes) info->fType; | 458 SkDisplayTypes type = (SkDisplayTypes) info->fType; |
459 if (type == SkType_MemberFunction) | 459 if (type == SkType_MemberFunction) |
460 return; | 460 return; |
461 SkDisplayable* target = getTarget(animate); | 461 SkDisplayable* target = getTarget(animate); |
462 size_t size = info->getSize(target); | 462 size_t size = info->getSize(target); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 return true; | 521 return true; |
522 } | 522 } |
523 return false; | 523 return false; |
524 } | 524 } |
525 | 525 |
526 bool SkApply::hasEnable() const { | 526 bool SkApply::hasEnable() const { |
527 return true; | 527 return true; |
528 } | 528 } |
529 | 529 |
530 bool SkApply::inactivate(SkAnimateMaker& maker) { | 530 bool SkApply::inactivate(SkAnimateMaker& maker) { |
531 if (fActive == NULL) | 531 if (fActive == nullptr) |
532 return false; | 532 return false; |
533 maker.removeActive(fActive); | 533 maker.removeActive(fActive); |
534 delete fActive; | 534 delete fActive; |
535 fActive = NULL; | 535 fActive = nullptr; |
536 return true; | 536 return true; |
537 } | 537 } |
538 | 538 |
539 #ifdef SK_DEBUG | 539 #ifdef SK_DEBUG |
540 SkMSec lastTime = (SkMSec) -1; | 540 SkMSec lastTime = (SkMSec) -1; |
541 #endif | 541 #endif |
542 | 542 |
543 bool SkApply::interpolate(SkAnimateMaker& maker, SkMSec rawTime) { | 543 bool SkApply::interpolate(SkAnimateMaker& maker, SkMSec rawTime) { |
544 if (fActive == NULL) | 544 if (fActive == nullptr) |
545 return false; | 545 return false; |
546 bool result = false; | 546 bool result = false; |
547 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING | 547 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING |
548 SkMSec time = maker.getAppTime(); | 548 SkMSec time = maker.getAppTime(); |
549 if (lastTime == (SkMSec) -1) | 549 if (lastTime == (SkMSec) -1) |
550 lastTime = rawTime - 1; | 550 lastTime = rawTime - 1; |
551 if (fActive != NULL && | 551 if (fActive != nullptr && |
552 strcmp(id, "a3") == 0 && rawTime > lastTime) { | 552 strcmp(id, "a3") == 0 && rawTime > lastTime) { |
553 lastTime += 1000; | 553 lastTime += 1000; |
554 SkString debugOut; | 554 SkString debugOut; |
555 debugOut.appendS32(time - maker.fDebugTimeBase); | 555 debugOut.appendS32(time - maker.fDebugTimeBase); |
556 debugOut.append(" apply id="); | 556 debugOut.append(" apply id="); |
557 debugOut.append(_id); | 557 debugOut.append(_id); |
558 debugOut.append("; "); | 558 debugOut.append("; "); |
559 debugOut.append(fActive->fAnimators[0]->_id); | 559 debugOut.append(fActive->fAnimators[0]->_id); |
560 debugOut.append("="); | 560 debugOut.append("="); |
561 debugOut.appendS32(rawTime - fActive->fState[0].fStartTime); | 561 debugOut.appendS32(rawTime - fActive->fState[0].fStartTime); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 // SkDEBUGF(("interpolate: post on end\n")); | 622 // SkDEBUGF(("interpolate: post on end\n")); |
623 state.fUnpostedEndEvent = false; | 623 state.fUnpostedEndEvent = false; |
624 maker.postOnEnd(animate, state.fBegin + state.fDuration); | 624 maker.postOnEnd(animate, state.fBegin + state.fDuration); |
625 maker.fAdjustedStart = 0; // !!! left over from synchronizing ani
mation days, undoubtably out of date (and broken) | 625 maker.fAdjustedStart = 0; // !!! left over from synchronizing ani
mation days, undoubtably out of date (and broken) |
626 } | 626 } |
627 if (animate->formula.size() > 0) { | 627 if (animate->formula.size() > 0) { |
628 if (fLastTime > animate->dur) | 628 if (fLastTime > animate->dur) |
629 fLastTime = animate->dur; | 629 fLastTime = animate->dur; |
630 SkTypedArray formulaValues; | 630 SkTypedArray formulaValues; |
631 formulaValues.setCount(count); | 631 formulaValues.setCount(count); |
632 SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(maker, &f
ormulaValues, 0, 0, NULL, | 632 SkDEBUGCODE(bool success = ) animate->fFieldInfo->setValue(maker, &f
ormulaValues, 0, 0, nullptr, |
633 animate->getValuesType(), animate->formula); | 633 animate->getValuesType(), animate->formula); |
634 SkASSERT(success); | 634 SkASSERT(success); |
635 if (restore) | 635 if (restore) |
636 save(inner); // save existing value | 636 save(inner); // save existing value |
637 applyValues(inner, formulaValues.begin(), count, animate->getValuesT
ype(), innerTime); | 637 applyValues(inner, formulaValues.begin(), count, animate->getValuesT
ype(), innerTime); |
638 } else { | 638 } else { |
639 if (restore) | 639 if (restore) |
640 save(inner); // save existing value | 640 save(inner); // save existing value |
641 applyValues(inner, values.get(), count, animate->getValuesType(), in
nerTime); | 641 applyValues(inner, values.get(), count, animate->getValuesType(), in
nerTime); |
642 } | 642 } |
643 } | 643 } |
644 return result; | 644 return result; |
645 } | 645 } |
646 | 646 |
647 void SkApply::initialize() { | 647 void SkApply::initialize() { |
648 if (scope == NULL) | 648 if (scope == nullptr) |
649 return; | 649 return; |
650 if (scope->isApply() || scope->isDrawable() == false) | 650 if (scope->isApply() || scope->isDrawable() == false) |
651 return; | 651 return; |
652 scope->initialize(); | 652 scope->initialize(); |
653 } | 653 } |
654 | 654 |
655 void SkApply::onEndElement(SkAnimateMaker& maker) | 655 void SkApply::onEndElement(SkAnimateMaker& maker) |
656 { | 656 { |
657 SkADrawable* scopePtr = scope; | 657 SkADrawable* scopePtr = scope; |
658 while (scopePtr && scopePtr->isApply()) { | 658 while (scopePtr && scopePtr->isApply()) { |
659 SkApply* scopedApply = (SkApply*) scopePtr; | 659 SkApply* scopedApply = (SkApply*) scopePtr; |
660 if (scopedApply->scope == this) { | 660 if (scopedApply->scope == this) { |
661 maker.setErrorCode(SkDisplayXMLParserError::kApplyScopesItself); | 661 maker.setErrorCode(SkDisplayXMLParserError::kApplyScopesItself); |
662 return; | 662 return; |
663 } | 663 } |
664 scopePtr = scopedApply->scope; | 664 scopePtr = scopedApply->scope; |
665 } | 665 } |
666 if (mode == kMode_create) | 666 if (mode == kMode_create) |
667 return; | 667 return; |
668 if (scope != NULL && steps >= 0 && scope->isApply() == false && scope->isDra
wable()) | 668 if (scope != nullptr && steps >= 0 && scope->isApply() == false && scope->is
Drawable()) |
669 scope->setSteps(steps); | 669 scope->setSteps(steps); |
670 for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(
); animPtr++) { | 670 for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(
); animPtr++) { |
671 SkAnimateBase* anim = *animPtr; | 671 SkAnimateBase* anim = *animPtr; |
672 //for reusing apply statements with dynamic scope | 672 //for reusing apply statements with dynamic scope |
673 if (anim->fTarget == NULL || anim->fTargetIsScope) { | 673 if (anim->fTarget == nullptr || anim->fTargetIsScope) { |
674 anim->fTargetIsScope = true; | 674 anim->fTargetIsScope = true; |
675 if (scope) | 675 if (scope) |
676 anim->fTarget = scope; | 676 anim->fTarget = scope; |
677 else | 677 else |
678 anim->setTarget(maker); | 678 anim->setTarget(maker); |
679 anim->onEndElement(maker); // allows animate->fFieldInfo to be set | 679 anim->onEndElement(maker); // allows animate->fFieldInfo to be set |
680 } | 680 } |
681 if (scope != NULL && steps >= 0 && anim->fTarget != scope && anim->fTarg
et->isDrawable()) | 681 if (scope != nullptr && steps >= 0 && anim->fTarget != scope && anim->fT
arget->isDrawable()) |
682 anim->fTarget->setSteps(steps); | 682 anim->fTarget->setSteps(steps); |
683 } | 683 } |
684 } | 684 } |
685 | 685 |
686 const SkMemberInfo* SkApply::preferredChild(SkDisplayTypes type) { | 686 const SkMemberInfo* SkApply::preferredChild(SkDisplayTypes type) { |
687 SkASSERT(SkDisplayType::IsAnimate(type) == false); | 687 SkASSERT(SkDisplayType::IsAnimate(type) == false); |
688 fContainsScope = true; | 688 fContainsScope = true; |
689 return getMember("scope"); // !!! cwap! need to refer to member through enum
like kScope instead | 689 return getMember("scope"); // !!! cwap! need to refer to member through enum
like kScope instead |
690 } | 690 } |
691 | 691 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 // info = animate->getResolvedInfo(); | 741 // info = animate->getResolvedInfo(); |
742 SkDisplayTypes type = (SkDisplayTypes) info->fType; | 742 SkDisplayTypes type = (SkDisplayTypes) info->fType; |
743 if (type == SkType_MemberFunction) | 743 if (type == SkType_MemberFunction) |
744 return; // nothing to save | 744 return; // nothing to save |
745 size_t size = info->getSize(target); | 745 size_t size = info->getSize(target); |
746 int count = (int) (size / sizeof(SkScalar)); | 746 int count = (int) (size / sizeof(SkScalar)); |
747 bool useLast = true; | 747 bool useLast = true; |
748 // !!! this all may be unneeded, at least in the dynamic case ?? | 748 // !!! this all may be unneeded, at least in the dynamic case ?? |
749 int activeIndex = fActive->fDrawIndex + index; | 749 int activeIndex = fActive->fDrawIndex + index; |
750 SkTDOperandArray last; | 750 SkTDOperandArray last; |
751 if (fActive->fSaveRestore[activeIndex] == NULL) { | 751 if (fActive->fSaveRestore[activeIndex] == nullptr) { |
752 fActive->fSaveRestore[activeIndex] = new SkOperand[count]; | 752 fActive->fSaveRestore[activeIndex] = new SkOperand[count]; |
753 useLast = false; | 753 useLast = false; |
754 } else { | 754 } else { |
755 last.setCount(count); | 755 last.setCount(count); |
756 memcpy(last.begin(), fActive->fSaveRestore[activeIndex], count * sizeof(
SkOperand)); | 756 memcpy(last.begin(), fActive->fSaveRestore[activeIndex], count * sizeof(
SkOperand)); |
757 } | 757 } |
758 if (type != SkType_MemberProperty) { | 758 if (type != SkType_MemberProperty) { |
759 info->getValue(target, fActive->fSaveRestore[activeIndex], count); | 759 info->getValue(target, fActive->fSaveRestore[activeIndex], count); |
760 if (useLast) | 760 if (useLast) |
761 info->setValue(target, last.begin(), count); | 761 info->setValue(target, last.begin(), count); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 void SkApply::setSteps(int _steps) { | 795 void SkApply::setSteps(int _steps) { |
796 steps = _steps; | 796 steps = _steps; |
797 } | 797 } |
798 | 798 |
799 #ifdef SK_DEBUG | 799 #ifdef SK_DEBUG |
800 void SkApply::validate() { | 800 void SkApply::validate() { |
801 if (fActive) | 801 if (fActive) |
802 fActive->validate(); | 802 fActive->validate(); |
803 } | 803 } |
804 #endif | 804 #endif |
OLD | NEW |