• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkEvent.h"
9 #include "SkMalloc.h"
10 
initialize(const char * type)11 void SkEvent::initialize(const char* type) {
12     fType = nullptr;
13     setType(type);
14     f32 = 0;
15 }
16 
SkEvent()17 SkEvent::SkEvent() {
18     initialize("");
19 }
20 
SkEvent(const SkEvent & src)21 SkEvent::SkEvent(const SkEvent& src) {
22     *this = src;
23     setType(src.fType);
24 }
25 
SkEvent(const char type[])26 SkEvent::SkEvent(const char type[]) {
27     SkASSERT(type);
28     initialize(type);
29 }
30 
~SkEvent()31 SkEvent::~SkEvent() {
32     sk_free(fType);
33 }
34 
isType(const char type[]) const35 bool SkEvent::isType(const char type[]) const {
36     size_t typeLen = strlen(type);
37     return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0;
38 }
39 
setType(const char type[])40 void SkEvent::setType(const char type[]) {
41     size_t typeLen = strlen(type);
42     fType = (char*) sk_malloc_throw(typeLen + 1);
43     memcpy(fType, type, typeLen);
44     fType[typeLen] = 0;
45 }
46