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 "SkDisplayPost.h" | 10 #include "SkDisplayPost.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 SK_MEMBER(mode, EventMode), | 31 SK_MEMBER(mode, EventMode), |
32 SK_MEMBER(sink, String), | 32 SK_MEMBER(sink, String), |
33 SK_MEMBER_PROPERTY(target, String), | 33 SK_MEMBER_PROPERTY(target, String), |
34 SK_MEMBER_PROPERTY(type, String) | 34 SK_MEMBER_PROPERTY(type, String) |
35 }; | 35 }; |
36 | 36 |
37 #endif | 37 #endif |
38 | 38 |
39 DEFINE_GET_MEMBER(SkPost); | 39 DEFINE_GET_MEMBER(SkPost); |
40 | 40 |
41 SkPost::SkPost() : delay(0), /*initialized(SkBool(-1)), */ mode(kImmediate), fMa
ker(NULL), | 41 SkPost::SkPost() : delay(0), /*initialized(SkBool(-1)), */ mode(kImmediate), fMa
ker(nullptr), |
42 fSinkID(0), fTargetMaker(NULL), fChildHasID(false), fDirty(false) { | 42 fSinkID(0), fTargetMaker(nullptr), fChildHasID(false), fDirty(false) { |
43 } | 43 } |
44 | 44 |
45 SkPost::~SkPost() { | 45 SkPost::~SkPost() { |
46 for (SkDataInput** part = fParts.begin(); part < fParts.end(); part++) | 46 for (SkDataInput** part = fParts.begin(); part < fParts.end(); part++) |
47 delete *part; | 47 delete *part; |
48 } | 48 } |
49 | 49 |
50 bool SkPost::addChild(SkAnimateMaker& , SkDisplayable* child) { | 50 bool SkPost::addChild(SkAnimateMaker& , SkDisplayable* child) { |
51 SkASSERT(child && child->isDataInput()); | 51 SkASSERT(child && child->isDataInput()); |
52 SkDataInput* part = (SkDataInput*) child; | 52 SkDataInput* part = (SkDataInput*) child; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const char* name; | 97 const char* name; |
98 bool closedYet = false; | 98 bool closedYet = false; |
99 SkDisplayList::fIndent += 4; | 99 SkDisplayList::fIndent += 4; |
100 //this seems to work, but kinda hacky | 100 //this seems to work, but kinda hacky |
101 //for some reason the last part is id, which i don't want | 101 //for some reason the last part is id, which i don't want |
102 //and the parts seem to be in the reverse order from the one in which we fin
d the | 102 //and the parts seem to be in the reverse order from the one in which we fin
d the |
103 //data itself | 103 //data itself |
104 //SkDataInput** ptr = fParts.end(); | 104 //SkDataInput** ptr = fParts.end(); |
105 //SkDataInput* data; | 105 //SkDataInput* data; |
106 //const char* ID; | 106 //const char* ID; |
107 while ((name = iter.next(&type, &number)) != NULL) { | 107 while ((name = iter.next(&type, &number)) != nullptr) { |
108 //ptr--; | 108 //ptr--; |
109 if (strcmp(name, "id") == 0) | 109 if (strcmp(name, "id") == 0) |
110 continue; | 110 continue; |
111 if (closedYet == false) { | 111 if (closedYet == false) { |
112 SkDebugf(">\n"); | 112 SkDebugf(">\n"); |
113 closedYet = true; | 113 closedYet = true; |
114 } | 114 } |
115 //data = *ptr; | 115 //data = *ptr; |
116 //if (data->id) | 116 //if (data->id) |
117 // ID = data->id; | 117 // ID = data->id; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 fEvent.setFast32(futureTime); | 203 fEvent.setFast32(futureTime); |
204 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING | 204 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING |
205 debugOut.append(" future="); | 205 debugOut.append(" future="); |
206 debugOut.appendS32(futureTime - maker.fDebugTimeBase); | 206 debugOut.appendS32(futureTime - maker.fDebugTimeBase); |
207 SkDebugf("%s\n", debugOut.c_str()); | 207 SkDebugf("%s\n", debugOut.c_str()); |
208 #endif | 208 #endif |
209 SkEventSinkID targetID = fSinkID; | 209 SkEventSinkID targetID = fSinkID; |
210 bool isAnimatorEvent = true; | 210 bool isAnimatorEvent = true; |
211 SkAnimator* anim = maker.getAnimator(); | 211 SkAnimator* anim = maker.getAnimator(); |
212 if (targetID == 0) { | 212 if (targetID == 0) { |
213 isAnimatorEvent = fEvent.findString("id") != NULL; | 213 isAnimatorEvent = fEvent.findString("id") != nullptr; |
214 if (isAnimatorEvent) | 214 if (isAnimatorEvent) |
215 targetID = anim->getSinkID(); | 215 targetID = anim->getSinkID(); |
216 else if (maker.fHostEventSinkID) | 216 else if (maker.fHostEventSinkID) |
217 targetID = maker.fHostEventSinkID; | 217 targetID = maker.fHostEventSinkID; |
218 else | 218 else |
219 return true; | 219 return true; |
220 } else | 220 } else |
221 anim = fTargetMaker->getAnimator(); | 221 anim = fTargetMaker->getAnimator(); |
222 if (delay == 0) { | 222 if (delay == 0) { |
223 if (isAnimatorEvent && mode == kImmediate) | 223 if (isAnimatorEvent && mode == kImmediate) |
224 fTargetMaker->doEvent(fEvent); | 224 fTargetMaker->doEvent(fEvent); |
225 else | 225 else |
226 anim->onEventPost(new SkEvent(fEvent), targetID); | 226 anim->onEventPost(new SkEvent(fEvent), targetID); |
227 } else | 227 } else |
228 anim->onEventPostTime(new SkEvent(fEvent), targetID, futureTime); | 228 anim->onEventPostTime(new SkEvent(fEvent), targetID, futureTime); |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 void SkPost::findSinkID() { | 232 void SkPost::findSinkID() { |
233 // get the next delimiter '.' if any | 233 // get the next delimiter '.' if any |
234 fTargetMaker = fMaker; | 234 fTargetMaker = fMaker; |
235 const char* ch = sink.c_str(); | 235 const char* ch = sink.c_str(); |
236 do { | 236 do { |
237 const char* end = strchr(ch, '.'); | 237 const char* end = strchr(ch, '.'); |
238 size_t len = end ? (size_t) (end - ch) : strlen(ch); | 238 size_t len = end ? (size_t) (end - ch) : strlen(ch); |
239 SkDisplayable* displayable = NULL; | 239 SkDisplayable* displayable = nullptr; |
240 if (SK_LITERAL_STR_EQUAL("parent", ch, len)) { | 240 if (SK_LITERAL_STR_EQUAL("parent", ch, len)) { |
241 if (fTargetMaker->fParentMaker) | 241 if (fTargetMaker->fParentMaker) |
242 fTargetMaker = fTargetMaker->fParentMaker; | 242 fTargetMaker = fTargetMaker->fParentMaker; |
243 else { | 243 else { |
244 fTargetMaker->setErrorCode(SkDisplayXMLParserError::kNoParentAva
ilable); | 244 fTargetMaker->setErrorCode(SkDisplayXMLParserError::kNoParentAva
ilable); |
245 return; | 245 return; |
246 } | 246 } |
247 } else { | 247 } else { |
248 fTargetMaker->find(ch, len, &displayable); | 248 fTargetMaker->find(ch, len, &displayable); |
249 if (displayable == NULL || displayable->getType() != SkType_Movie) { | 249 if (displayable == nullptr || displayable->getType() != SkType_Movie
) { |
250 fTargetMaker->setErrorCode(SkDisplayXMLParserError::kExpectedMov
ie); | 250 fTargetMaker->setErrorCode(SkDisplayXMLParserError::kExpectedMov
ie); |
251 return; | 251 return; |
252 } | 252 } |
253 SkDisplayMovie* movie = (SkDisplayMovie*) displayable; | 253 SkDisplayMovie* movie = (SkDisplayMovie*) displayable; |
254 fTargetMaker = movie->fMovie.fMaker; | 254 fTargetMaker = movie->fMovie.fMaker; |
255 } | 255 } |
256 if (end == NULL) | 256 if (end == nullptr) |
257 break; | 257 break; |
258 ch = ++end; | 258 ch = ++end; |
259 } while (true); | 259 } while (true); |
260 SkAnimator* anim = fTargetMaker->getAnimator(); | 260 SkAnimator* anim = fTargetMaker->getAnimator(); |
261 fSinkID = anim->getSinkID(); | 261 fSinkID = anim->getSinkID(); |
262 } | 262 } |
263 | 263 |
264 bool SkPost::hasEnable() const { | 264 bool SkPost::hasEnable() const { |
265 return true; | 265 return true; |
266 } | 266 } |
(...skipping 22 matching lines...) Expand all Loading... |
289 } break; | 289 } break; |
290 case SK_PROPERTY(type): | 290 case SK_PROPERTY(type): |
291 fEvent.setType(*string); | 291 fEvent.setType(*string); |
292 break; | 292 break; |
293 default: | 293 default: |
294 SkASSERT(0); | 294 SkASSERT(0); |
295 return false; | 295 return false; |
296 } | 296 } |
297 return true; | 297 return true; |
298 } | 298 } |
OLD | NEW |