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 | |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 20 | class Path2D : SkNoncopyable { |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 21 | public: |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 22 | Path2D() : fSkPath() {} |
| 23 | virtual ~Path2D() {} |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 24 | |
| 25 | const SkPath& getSkPath() { return fSkPath; } |
| 26 | |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 27 | // The JS Path2D constuctor implementation. |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 28 | static void ConstructPath(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 29 | |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 30 | // Add the Path2D JS constructor to the global context. |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 31 | static void AddToGlobal(Global* global); |
| 32 | |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 33 | // Path2D JS methods. |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 34 | static void ClosePath(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 35 | static void MoveTo(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 36 | static void LineTo(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 37 | static void QuadraticCurveTo( |
| 38 | const v8::FunctionCallbackInfo<v8::Value>& args); |
| 39 | static void BezierCurveTo(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 40 | static void Arc(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 41 | static void Rect(const v8::FunctionCallbackInfo<v8::Value>& args); |
commit-bot@chromium.org | cd11018 | 2014-01-10 21:33:01 +0000 | [diff] [blame] | 42 | static void Oval(const v8::FunctionCallbackInfo<v8::Value>& args); |
commit-bot@chromium.org | e1df565 | 2014-02-13 16:00:58 +0000 | [diff] [blame] | 43 | static void ConicTo(const v8::FunctionCallbackInfo<v8::Value>& args); |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 44 | private: |
| 45 | SkPath fSkPath; |
| 46 | |
commit-bot@chromium.org | f679d1b | 2014-02-27 20:20:21 +0000 | [diff] [blame] | 47 | static Path2D* Unwrap(const v8::FunctionCallbackInfo<v8::Value>& args); |
commit-bot@chromium.org | c8d7328 | 2014-01-06 18:17:24 +0000 | [diff] [blame] | 48 | |
| 49 | static Global* gGlobal; |
| 50 | }; |
| 51 | |
| 52 | #endif |