1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkEvent.h" 97edde238f741b7954a18797e88dcd04b59d79d2fMike Reed#include "SkMalloc.h" 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osmanvoid SkEvent::initialize(const char* type) { 1296fcdcc219d2a0d3579719b84b28bede76efba64halcanary fType = nullptr; 138ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman setType(type); 148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com f32 = 0; 158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 177edde238f741b7954a18797e88dcd04b59d79d2fMike ReedSkEvent::SkEvent() { 188ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman initialize(""); 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 217edde238f741b7954a18797e88dcd04b59d79d2fMike ReedSkEvent::SkEvent(const SkEvent& src) { 228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *this = src; 238ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman setType(src.fType); 248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 267edde238f741b7954a18797e88dcd04b59d79d2fMike ReedSkEvent::SkEvent(const char type[]) { 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkASSERT(type); 288ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman initialize(type); 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 317edde238f741b7954a18797e88dcd04b59d79d2fMike ReedSkEvent::~SkEvent() { 328ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman sk_free(fType); 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 357edde238f741b7954a18797e88dcd04b59d79d2fMike Reedbool SkEvent::isType(const char type[]) const { 368ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman size_t typeLen = strlen(type); 37d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0; 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 407edde238f741b7954a18797e88dcd04b59d79d2fMike Reedvoid SkEvent::setType(const char type[]) { 418ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman size_t typeLen = strlen(type); 428ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman fType = (char*) sk_malloc_throw(typeLen + 1); 438ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman memcpy(fType, type, typeLen); 448ceee43de49b314fff58852c2d89ed3885ae71eeBrian Osman fType[typeLen] = 0; 458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com} 46