diff options
author | Brian Osman <brianosman@google.com> | 2017-11-22 13:23:35 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-22 18:59:44 +0000 |
commit | 4f99e58252175f01c0b9ca1a5e2fc7acec6acec3 (patch) | |
tree | 64458810ed2962bbdcb470a4f199feade2be2b03 /src/views/SkEventSink.cpp | |
parent | d923a71a113d97dc87b4424c25d5b5019331db24 (diff) |
Remove a huge pile of views code
All of this is dead when not using the old SkWindow framework.
TBR=reed@google.com
Bug: skia:
Change-Id: I0f6ab18987a98469bfd367d5bc10967300dfd3ca
Reviewed-on: https://skia-review.googlesource.com/75384
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/views/SkEventSink.cpp')
-rw-r--r-- | src/views/SkEventSink.cpp | 149 |
1 files changed, 1 insertions, 148 deletions
diff --git a/src/views/SkEventSink.cpp b/src/views/SkEventSink.cpp index cd83111f50..11af0f9623 100644 --- a/src/views/SkEventSink.cpp +++ b/src/views/SkEventSink.cpp @@ -8,7 +8,6 @@ #include "SkEventSink.h" #include "SkMutex.h" -#include "SkTagList.h" #include "SkTime.h" class SkEventSink_Globals { @@ -29,7 +28,7 @@ static SkEventSink_Globals& getGlobals() { return *gGlobals; } -SkEventSink::SkEventSink() : fTagHead(nullptr) { +SkEventSink::SkEventSink() { SkEventSink_Globals& globals = getGlobals(); globals.fSinkMutex.acquire(); @@ -44,9 +43,6 @@ SkEventSink::SkEventSink() : fTagHead(nullptr) { SkEventSink::~SkEventSink() { SkEventSink_Globals& globals = getGlobals(); - if (fTagHead) - SkTagList::DeleteAll(fTagHead); - globals.fSinkMutex.acquire(); SkEventSink* sink = globals.fSinkHead; @@ -87,149 +83,6 @@ bool SkEventSink::onQuery(SkEvent*) { /////////////////////////////////////////////////////////////////////////////// -SkTagList* SkEventSink::findTagList(U8CPU tag) const { - return fTagHead ? SkTagList::Find(fTagHead, tag) : nullptr; -} - -void SkEventSink::addTagList(SkTagList* rec) { - SkASSERT(rec); - SkASSERT(fTagHead == nullptr || SkTagList::Find(fTagHead, rec->fTag) == nullptr); - - rec->fNext = fTagHead; - fTagHead = rec; -} - -void SkEventSink::removeTagList(U8CPU tag) { - if (fTagHead) { - SkTagList::DeleteTag(&fTagHead, tag); - } -} - -/////////////////////////////////////////////////////////////////////////////// - -struct SkListenersTagList : SkTagList { - SkListenersTagList(U16CPU count) : SkTagList(kListeners_SkTagList) - { - fExtra16 = SkToU16(count); - fIDs = (SkEventSinkID*)sk_malloc_throw(count * sizeof(SkEventSinkID)); - } - virtual ~SkListenersTagList() - { - sk_free(fIDs); - } - - int countListners() const { return fExtra16; } - - int find(SkEventSinkID id) const - { - const SkEventSinkID* idptr = fIDs; - for (int i = fExtra16 - 1; i >= 0; --i) - if (idptr[i] == id) - return i; - return -1; - } - - SkEventSinkID* fIDs; -}; - -void SkEventSink::addListenerID(SkEventSinkID id) -{ - if (id == 0) - return; - - SkListenersTagList* prev = (SkListenersTagList*)this->findTagList(kListeners_SkTagList); - int count = 0; - - if (prev) - { - if (prev->find(id) >= 0) - return; - count = prev->countListners(); - } - - SkListenersTagList* next = new SkListenersTagList(count + 1); - - if (prev) - { - memcpy(next->fIDs, prev->fIDs, count * sizeof(SkEventSinkID)); - this->removeTagList(kListeners_SkTagList); - } - next->fIDs[count] = id; - this->addTagList(next); -} - -void SkEventSink::copyListeners(const SkEventSink& sink) -{ - SkListenersTagList* sinkList = (SkListenersTagList*)sink.findTagList(kListeners_SkTagList); - if (sinkList == nullptr) - return; - SkASSERT(sinkList->countListners() > 0); - const SkEventSinkID* iter = sinkList->fIDs; - const SkEventSinkID* stop = iter + sinkList->countListners(); - while (iter < stop) - addListenerID(*iter++); -} - -void SkEventSink::removeListenerID(SkEventSinkID id) -{ - if (id == 0) - return; - - SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList); - - if (list == nullptr) - return; - - int index = list->find(id); - if (index >= 0) - { - int count = list->countListners(); - SkASSERT(count > 0); - if (count == 1) - this->removeTagList(kListeners_SkTagList); - else - { - // overwrite without resize/reallocating our struct (for speed) - list->fIDs[index] = list->fIDs[count - 1]; - list->fExtra16 = SkToU16(count - 1); - } - } -} - -bool SkEventSink::hasListeners() const -{ - return this->findTagList(kListeners_SkTagList) != nullptr; -} - -void SkEventSink::postToListeners(const SkEvent& evt, SkMSec delay) { - SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList); - if (list) { - SkASSERT(list->countListners() > 0); - const SkEventSinkID* iter = list->fIDs; - const SkEventSinkID* stop = iter + list->countListners(); - while (iter < stop) { - SkEvent* copy = new SkEvent(evt); - copy->setTargetID(*iter++)->postDelay(delay); - } - } -} - -/////////////////////////////////////////////////////////////////////////////// - -SkEventSink::EventResult SkEventSink::DoEvent(const SkEvent& evt) { - SkEvent::Proc proc = evt.getTargetProc(); - if (proc) { - return proc(evt) ? kHandled_EventResult : kNotHandled_EventResult; - } - - SkEventSink* sink = SkEventSink::FindSink(evt.getTargetID()); - if (sink) { - return sink->doEvent(evt) ? kHandled_EventResult : kNotHandled_EventResult; - } - - return kSinkNotFound_EventResult; -} - SkEventSink* SkEventSink::FindSink(SkEventSinkID sinkID) { if (sinkID == 0) |