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 "SkDisplayAdd.h" | 10 #include "SkDisplayAdd.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // start here; | 28 // start here; |
29 // add onEndElement to turn where string into f_Where | 29 // add onEndElement to turn where string into f_Where |
30 // probably need new SkAnimateMaker::resolve flavor that takes | 30 // probably need new SkAnimateMaker::resolve flavor that takes |
31 // where="id", where="event-target" or not-specified | 31 // where="id", where="event-target" or not-specified |
32 // offset="#" (implements before, after, and index if no 'where') | 32 // offset="#" (implements before, after, and index if no 'where') |
33 | 33 |
34 DEFINE_GET_MEMBER(SkAdd); | 34 DEFINE_GET_MEMBER(SkAdd); |
35 | 35 |
36 SkAdd::SkAdd() : mode(kMode_indirect), | 36 SkAdd::SkAdd() : mode(kMode_indirect), |
37 offset(SK_MaxS32), use(NULL), where(NULL) { | 37 offset(SK_MaxS32), use(nullptr), where(nullptr) { |
38 } | 38 } |
39 | 39 |
40 SkDisplayable* SkAdd::deepCopy(SkAnimateMaker* maker) { | 40 SkDisplayable* SkAdd::deepCopy(SkAnimateMaker* maker) { |
41 SkADrawable* saveUse = use; | 41 SkADrawable* saveUse = use; |
42 SkADrawable* saveWhere = where; | 42 SkADrawable* saveWhere = where; |
43 use = NULL; | 43 use = nullptr; |
44 where = NULL; | 44 where = nullptr; |
45 SkAdd* copy = (SkAdd*) INHERITED::deepCopy(maker); | 45 SkAdd* copy = (SkAdd*) INHERITED::deepCopy(maker); |
46 copy->use = use = saveUse; | 46 copy->use = use = saveUse; |
47 copy->where = where = saveWhere; | 47 copy->where = where = saveWhere; |
48 return copy; | 48 return copy; |
49 } | 49 } |
50 | 50 |
51 bool SkAdd::draw(SkAnimateMaker& maker) { | 51 bool SkAdd::draw(SkAnimateMaker& maker) { |
52 SkASSERT(use); | 52 SkASSERT(use); |
53 SkASSERT(use->isDrawable()); | 53 SkASSERT(use->isDrawable()); |
54 if (mode == kMode_indirect) | 54 if (mode == kMode_indirect) |
(...skipping 18 matching lines...) Expand all Loading... |
73 SkDisplayList::fDumpIndex = save; | 73 SkDisplayList::fDumpIndex = save; |
74 dumpEnd(maker); | 74 dumpEnd(maker); |
75 } | 75 } |
76 #endif | 76 #endif |
77 | 77 |
78 bool SkAdd::enable(SkAnimateMaker& maker ) { | 78 bool SkAdd::enable(SkAnimateMaker& maker ) { |
79 SkDisplayTypes type = getType(); | 79 SkDisplayTypes type = getType(); |
80 SkDisplayList& displayList = maker.fDisplayList; | 80 SkDisplayList& displayList = maker.fDisplayList; |
81 SkTDDrawableArray* parentList = displayList.getDrawList(); | 81 SkTDDrawableArray* parentList = displayList.getDrawList(); |
82 if (type == SkType_Add) { | 82 if (type == SkType_Add) { |
83 if (use == NULL) // not set in apply yet | 83 if (use == nullptr) // not set in apply yet |
84 return true; | 84 return true; |
85 } | 85 } |
86 bool skipAddToParent = true; | 86 bool skipAddToParent = true; |
87 SkASSERT(type != SkType_Replace || where); | 87 SkASSERT(type != SkType_Replace || where); |
88 SkTDDrawableArray* grandList SK_INIT_TO_AVOID_WARNING; | 88 SkTDDrawableArray* grandList SK_INIT_TO_AVOID_WARNING; |
89 SkGroup* parentGroup = NULL; | 89 SkGroup* parentGroup = nullptr; |
90 SkGroup* thisGroup = NULL; | 90 SkGroup* thisGroup = nullptr; |
91 int index = where ? displayList.findGroup(where, &parentList, &parentGroup, | 91 int index = where ? displayList.findGroup(where, &parentList, &parentGroup, |
92 &thisGroup, &grandList) : 0; | 92 &thisGroup, &grandList) : 0; |
93 if (index < 0) | 93 if (index < 0) |
94 return true; | 94 return true; |
95 int max = parentList->count(); | 95 int max = parentList->count(); |
96 if (where == NULL && type == SkType_Move) | 96 if (where == nullptr && type == SkType_Move) |
97 index = max; | 97 index = max; |
98 if (offset != SK_MaxS32) { | 98 if (offset != SK_MaxS32) { |
99 index += offset; | 99 index += offset; |
100 if (index > max) { | 100 if (index > max) { |
101 maker.setErrorCode(SkDisplayXMLParserError::kIndexOutOfRange); | 101 maker.setErrorCode(SkDisplayXMLParserError::kIndexOutOfRange); |
102 return true; // caller should not add | 102 return true; // caller should not add |
103 } | 103 } |
104 } | 104 } |
105 if (offset < 0 && where == NULL) | 105 if (offset < 0 && where == nullptr) |
106 index += max + 1; | 106 index += max + 1; |
107 switch (type) { | 107 switch (type) { |
108 case SkType_Add: | 108 case SkType_Add: |
109 if (offset == SK_MaxS32 && where == NULL) { | 109 if (offset == SK_MaxS32 && where == nullptr) { |
110 if (use->isDrawable()) { | 110 if (use->isDrawable()) { |
111 skipAddToParent = mode == kMode_immediate; | 111 skipAddToParent = mode == kMode_immediate; |
112 if (skipAddToParent) { | 112 if (skipAddToParent) { |
113 if (where == NULL) { | 113 if (where == nullptr) { |
114 SkTDDrawableArray* useParentList; | 114 SkTDDrawableArray* useParentList; |
115 index = displayList.findGroup(this, &useParentList,
&parentGroup, | 115 index = displayList.findGroup(this, &useParentList,
&parentGroup, |
116 &thisGroup, &grandList); | 116 &thisGroup, &grandList); |
117 if (index >= 0) { | 117 if (index >= 0) { |
118 parentGroup->markCopySize(index); | 118 parentGroup->markCopySize(index); |
119 parentGroup->markCopySet(index); | 119 parentGroup->markCopySet(index); |
120 useParentList->begin()[index] = use; | 120 useParentList->begin()[index] = use; |
121 break; | 121 break; |
122 } | 122 } |
123 } | 123 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return true; | 187 return true; |
188 } | 188 } |
189 | 189 |
190 void SkAdd::initialize() { | 190 void SkAdd::initialize() { |
191 if (use) | 191 if (use) |
192 use->initialize(); | 192 use->initialize(); |
193 } | 193 } |
194 | 194 |
195 bool SkAdd::isDrawable() const { | 195 bool SkAdd::isDrawable() const { |
196 return getType() == SkType_Add && mode == kMode_indirect && offset == SK_Max
S32 && | 196 return getType() == SkType_Add && mode == kMode_indirect && offset == SK_Max
S32 && |
197 where == NULL && use != NULL && use->isDrawable(); | 197 where == nullptr && use != nullptr && use->isDrawable(); |
198 } | 198 } |
199 | 199 |
200 //SkDisplayable* SkAdd::resolveTarget(SkAnimateMaker& maker) { | 200 //SkDisplayable* SkAdd::resolveTarget(SkAnimateMaker& maker) { |
201 // return use; | 201 // return use; |
202 //} | 202 //} |
203 | 203 |
204 | 204 |
205 bool SkClear::enable(SkAnimateMaker& maker ) { | 205 bool SkClear::enable(SkAnimateMaker& maker ) { |
206 SkDisplayList& displayList = maker.fDisplayList; | 206 SkDisplayList& displayList = maker.fDisplayList; |
207 displayList.clear(); | 207 displayList.clear(); |
(...skipping 28 matching lines...) Expand all Loading... |
236 | 236 |
237 #if SK_USE_CONDENSED_INFO == 0 | 237 #if SK_USE_CONDENSED_INFO == 0 |
238 | 238 |
239 const SkMemberInfo SkReplace::fInfo[] = { | 239 const SkMemberInfo SkReplace::fInfo[] = { |
240 SK_MEMBER_INHERITED | 240 SK_MEMBER_INHERITED |
241 }; | 241 }; |
242 | 242 |
243 #endif | 243 #endif |
244 | 244 |
245 DEFINE_GET_MEMBER(SkReplace); | 245 DEFINE_GET_MEMBER(SkReplace); |
OLD | NEW |