commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 1 | /* |
| 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.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 10 | #ifndef SkV8Example_Path2D_DEFINED |
| 11 | #define SkV8Example_Path2D_DEFINED |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 12 | |
| 13 | #include <v8.h> |
| 14 | |
| 15 | #include "SkPath.h" |
| 16 | #include "SkTypes.h" |
| 17 | |
| 18 | class Global; |
| 19 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 20 | // Path2D bridges between JS and SkPath. |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 21 | class Path2D : SkNoncopyable { |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 22 | public: |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 23 | Path2D(SkPath* path); |
| 24 | virtual ~Path2D(); |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 25 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 26 | static void AddToGlobal(Global* global) { |
| 27 | gGlobal = global; |
| 28 | } |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 29 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 30 | v8::Persistent<v8::Object>& persistent() { |
| 31 | return handle_; |
| 32 | } |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 33 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 34 | SkPath* path() { |
| 35 | return path_; |
| 36 | } |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 37 | |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 38 | private: |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 39 | // The handle to this object in JS space. |
| 40 | v8::Persistent<v8::Object> handle_; |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 41 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 42 | SkPath* path_; |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 43 | |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 44 | // The global context we are running in. |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 45 | static Global* gGlobal; |
jcgregorio | e001da2 | 2014-10-29 05:33:27 -0700 | [diff] [blame] | 46 | |
| 47 | // The template for what a JS Path2D object looks like. |
| 48 | static v8::Persistent<v8::ObjectTemplate> gPath2DTemplate; |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #endif |