aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/SkV8Example/Path2D.h
blob: 4ac9877fd790c7e4e997d1a18f718e6ce9508075 (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
51
/*
 * Copyright 2014 Google Inc.
 *
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 */

#ifndef SkV8Example_Path2D_DEFINED
#define SkV8Example_Path2D_DEFINED

#include <v8.h>

#include "SkPath.h"
#include "SkTypes.h"

class Global;

// Path2D bridges between JS and SkPath.
class Path2D : SkNoncopyable {
public:
    Path2D(SkPath* path);
    virtual ~Path2D();

    static void AddToGlobal(Global* global) {
        gGlobal = global;
    }

    v8::Persistent<v8::Object>& persistent() {
        return handle_;
    }

    SkPath* path() {
        return path_;
    }

private:
    // The handle to this object in JS space.
    v8::Persistent<v8::Object> handle_;

    SkPath* path_;

    // The global context we are running in.
    static Global* gGlobal;

    // The template for what a JS Path2D object looks like.
    static v8::Persistent<v8::ObjectTemplate> gPath2DTemplate;
};

#endif