aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/SkEvent.cpp
blob: 6ead33ec7f775afd52e9a9ccc05856200f1f2bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkEvent.h"

void SkEvent::initialize(const char* type) {
    fType = nullptr;
    setType(type);
    f32 = 0;
}

SkEvent::SkEvent()
{
    initialize("");
}

SkEvent::SkEvent(const SkEvent& src)
{
    *this = src;
    setType(src.fType);
}

SkEvent::SkEvent(const char type[])
{
    SkASSERT(type);
    initialize(type);
}

SkEvent::~SkEvent()
{
    sk_free(fType);
}

bool SkEvent::isType(const char type[]) const
{
    size_t typeLen = strlen(type);
    return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0;
}

void SkEvent::setType(const char type[])
{
    size_t typeLen = strlen(type);
    fType = (char*) sk_malloc_throw(typeLen + 1);
    memcpy(fType, type, typeLen);
    fType[typeLen] = 0;
}