blob: 4ac9877fd790c7e4e997d1a18f718e6ce9508075 [file] [log] [blame]
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +00001/*
2 * Copyright 2014 Google Inc.
3 *
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 *
8 */
9
commit-bot@chromium.orgf679d1b2014-02-27 20:20:21 +000010#ifndef SkV8Example_Path2D_DEFINED
11#define SkV8Example_Path2D_DEFINED
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000012
13#include <v8.h>
14
15#include "SkPath.h"
16#include "SkTypes.h"
17
18class Global;
19
jcgregorioe001da22014-10-29 05:33:27 -070020// Path2D bridges between JS and SkPath.
commit-bot@chromium.orgf679d1b2014-02-27 20:20:21 +000021class Path2D : SkNoncopyable {
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000022public:
jcgregorioe001da22014-10-29 05:33:27 -070023 Path2D(SkPath* path);
24 virtual ~Path2D();
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000025
jcgregorioe001da22014-10-29 05:33:27 -070026 static void AddToGlobal(Global* global) {
27 gGlobal = global;
28 }
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000029
jcgregorioe001da22014-10-29 05:33:27 -070030 v8::Persistent<v8::Object>& persistent() {
31 return handle_;
32 }
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000033
jcgregorioe001da22014-10-29 05:33:27 -070034 SkPath* path() {
35 return path_;
36 }
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000037
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000038private:
jcgregorioe001da22014-10-29 05:33:27 -070039 // The handle to this object in JS space.
40 v8::Persistent<v8::Object> handle_;
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000041
jcgregorioe001da22014-10-29 05:33:27 -070042 SkPath* path_;
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000043
jcgregorioe001da22014-10-29 05:33:27 -070044 // The global context we are running in.
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000045 static Global* gGlobal;
jcgregorioe001da22014-10-29 05:33:27 -070046
47 // The template for what a JS Path2D object looks like.
48 static v8::Persistent<v8::ObjectTemplate> gPath2DTemplate;
commit-bot@chromium.orgc8d73282014-01-06 18:17:24 +000049};
50
51#endif