| 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 "SkEventSink.h" | 10 #include "SkEventSink.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 SkListenersTagList* prev = (SkListenersTagList*)this->findTagList(kListeners
_SkTagList); | 141 SkListenersTagList* prev = (SkListenersTagList*)this->findTagList(kListeners
_SkTagList); |
| 142 int count = 0; | 142 int count = 0; |
| 143 | 143 |
| 144 if (prev) | 144 if (prev) |
| 145 { | 145 { |
| 146 if (prev->find(id) >= 0) | 146 if (prev->find(id) >= 0) |
| 147 return; | 147 return; |
| 148 count = prev->countListners(); | 148 count = prev->countListners(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 SkListenersTagList* next = SkNEW_ARGS(SkListenersTagList, (count + 1)); | 151 SkListenersTagList* next = new SkListenersTagList(count + 1); |
| 152 | 152 |
| 153 if (prev) | 153 if (prev) |
| 154 { | 154 { |
| 155 memcpy(next->fIDs, prev->fIDs, count * sizeof(SkEventSinkID)); | 155 memcpy(next->fIDs, prev->fIDs, count * sizeof(SkEventSinkID)); |
| 156 this->removeTagList(kListeners_SkTagList); | 156 this->removeTagList(kListeners_SkTagList); |
| 157 } | 157 } |
| 158 next->fIDs[count] = id; | 158 next->fIDs[count] = id; |
| 159 this->addTagList(next); | 159 this->addTagList(next); |
| 160 } | 160 } |
| 161 | 161 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return this->findTagList(kListeners_SkTagList) != NULL; | 202 return this->findTagList(kListeners_SkTagList) != NULL; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void SkEventSink::postToListeners(const SkEvent& evt, SkMSec delay) { | 205 void SkEventSink::postToListeners(const SkEvent& evt, SkMSec delay) { |
| 206 SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners
_SkTagList); | 206 SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners
_SkTagList); |
| 207 if (list) { | 207 if (list) { |
| 208 SkASSERT(list->countListners() > 0); | 208 SkASSERT(list->countListners() > 0); |
| 209 const SkEventSinkID* iter = list->fIDs; | 209 const SkEventSinkID* iter = list->fIDs; |
| 210 const SkEventSinkID* stop = iter + list->countListners(); | 210 const SkEventSinkID* stop = iter + list->countListners(); |
| 211 while (iter < stop) { | 211 while (iter < stop) { |
| 212 SkEvent* copy = SkNEW_ARGS(SkEvent, (evt)); | 212 SkEvent* copy = new SkEvent(evt); |
| 213 copy->setTargetID(*iter++)->postDelay(delay); | 213 copy->setTargetID(*iter++)->postDelay(delay); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 /////////////////////////////////////////////////////////////////////////////// | 218 /////////////////////////////////////////////////////////////////////////////// |
| 219 | 219 |
| 220 SkEventSink::EventResult SkEventSink::DoEvent(const SkEvent& evt) { | 220 SkEventSink::EventResult SkEventSink::DoEvent(const SkEvent& evt) { |
| 221 SkEvent::Proc proc = evt.getTargetProc(); | 221 SkEvent::Proc proc = evt.getTargetProc(); |
| 222 if (proc) { | 222 if (proc) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 /** Remove all name/id pairs from the system. This is call internally | 292 /** Remove all name/id pairs from the system. This is call internally |
| 293 on shutdown, to ensure no memory leaks. It should not be called | 293 on shutdown, to ensure no memory leaks. It should not be called |
| 294 before shutdown. | 294 before shutdown. |
| 295 */ | 295 */ |
| 296 void SkEventSink::RemoveAllNamedSinkIDs() | 296 void SkEventSink::RemoveAllNamedSinkIDs() |
| 297 { | 297 { |
| 298 SkAutoMutexAcquire ac(gNamedSinkMutex); | 298 SkAutoMutexAcquire ac(gNamedSinkMutex); |
| 299 (void)gNamedSinkIDs.reset(); | 299 (void)gNamedSinkIDs.reset(); |
| 300 } | 300 } |
| 301 #endif | 301 #endif |
| OLD | NEW |