diff options
author | Brian Osman <brianosman@google.com> | 2017-12-01 10:52:28 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-01 17:12:49 +0000 |
commit | 8ceee43de49b314fff58852c2d89ed3885ae71ee (patch) | |
tree | c3046b938bd7c026c84f164b785f749472629f80 /src/views/SkEvent.cpp | |
parent | 3ac99cfaa2d434c71d9c82fc234fadd55fe96394 (diff) |
Remove more views code, just to simplify things
Bug: skia:
Change-Id: Ie31a3c764e4f88f2b08f4198bd253841a2d8c264
Reviewed-on: https://skia-review.googlesource.com/79100
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/views/SkEvent.cpp')
-rw-r--r-- | src/views/SkEvent.cpp | 85 |
1 files changed, 13 insertions, 72 deletions
diff --git a/src/views/SkEvent.cpp b/src/views/SkEvent.cpp index c2b800fe9e..6ead33ec7f 100644 --- a/src/views/SkEvent.cpp +++ b/src/views/SkEvent.cpp @@ -7,103 +7,44 @@ #include "SkEvent.h" -void SkEvent::initialize(const char* type, size_t typeLen) { +void SkEvent::initialize(const char* type) { fType = nullptr; - setType(type, typeLen); + setType(type); f32 = 0; } SkEvent::SkEvent() { - initialize("", 0); + initialize(""); } SkEvent::SkEvent(const SkEvent& src) { *this = src; - if (((size_t) fType & 1) == 0) - setType(src.fType); -} - -SkEvent::SkEvent(const SkString& type) -{ - initialize(type.c_str(), type.size()); + setType(src.fType); } SkEvent::SkEvent(const char type[]) { SkASSERT(type); - initialize(type, strlen(type)); + initialize(type); } SkEvent::~SkEvent() { - if (((size_t) fType & 1) == 0) - sk_free((void*) fType); -} - -static size_t makeCharArray(char* buffer, size_t compact) -{ - size_t bits = (size_t) compact >> 1; - memcpy(buffer, &bits, sizeof(compact)); - buffer[sizeof(compact)] = 0; - return strlen(buffer); + sk_free(fType); } -void SkEvent::getType(SkString* str) const +bool SkEvent::isType(const char type[]) const { - if (str) - { - if ((size_t) fType & 1) // not a pointer - { - char chars[sizeof(size_t) + 1]; - size_t len = makeCharArray(chars, (size_t) fType); - str->set(chars, len); - } - else - str->set(fType); - } -} - -bool SkEvent::isType(const SkString& str) const -{ - return this->isType(str.c_str(), str.size()); -} - -bool SkEvent::isType(const char type[], size_t typeLen) const -{ - if (typeLen == 0) - typeLen = strlen(type); - if ((size_t) fType & 1) { // not a pointer - char chars[sizeof(size_t) + 1]; - size_t len = makeCharArray(chars, (size_t) fType); - return len == typeLen && strncmp(chars, type, typeLen) == 0; - } + size_t typeLen = strlen(type); return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0; } -void SkEvent::setType(const char type[], size_t typeLen) -{ - if (typeLen == 0) - typeLen = strlen(type); - if (typeLen <= sizeof(fType)) { - size_t slot = 0; - memcpy(&slot, type, typeLen); - if (slot << 1 >> 1 != slot) - goto useCharStar; - slot <<= 1; - slot |= 1; - fType = (char*) slot; - } else { -useCharStar: - fType = (char*) sk_malloc_throw(typeLen + 1); - SkASSERT(((size_t) fType & 1) == 0); - memcpy(fType, type, typeLen); - fType[typeLen] = 0; - } -} - -void SkEvent::setType(const SkString& type) +void SkEvent::setType(const char type[]) { - setType(type.c_str()); + size_t typeLen = strlen(type); + fType = (char*) sk_malloc_throw(typeLen + 1); + memcpy(fType, type, typeLen); + fType[typeLen] = 0; } |