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