Chromium Code Reviews| Index: experimental/SkV8Example/DrawingMethods.h |
| diff --git a/experimental/SkV8Example/DrawingMethods.h b/experimental/SkV8Example/DrawingMethods.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a18684624a87ffa58d38f40164528d67f0feeb17 |
| --- /dev/null |
| +++ b/experimental/SkV8Example/DrawingMethods.h |
| @@ -0,0 +1,58 @@ |
| +/* |
| + * 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_DrawingMethods_DEFINED |
| +#define SkV8Example_DrawingMethods_DEFINED |
| + |
| +#include <v8.h> |
| + |
|
robertphillips
2014/10/27 16:11:17
Do we need this?
jcgregorio
2014/10/27 16:30:23
Done.
|
| +#include "SkPaint.h" |
| + |
| +class SkCanvas; |
| +class Global; |
| + |
| +// DrawingMethods contains common functionality for both Context, Image2Builder, |
| +// and DisplayListBuiler. |
| +class DrawingMethods { |
| +public: |
| + DrawingMethods(Global* global) |
| + : fGlobal(global) |
| + {} |
| + virtual ~DrawingMethods() {} |
| + |
| + // Retrieve the SkCanvas to draw on. May return NULL. |
| + virtual SkCanvas* getCanvas() = 0; |
| + |
|
robertphillips
2014/10/27 16:11:17
overlength ?
jcgregorio
2014/10/27 16:30:23
Done.
|
| + // Add the Javascript attributes and methods that DrawingMethods implements to the ObjectTemplate. |
| + void addAttributesAndMethods(v8::Handle<v8::ObjectTemplate> tmpl); |
| + |
| +protected: |
| + // Get the pointer out of obj. |
| + static DrawingMethods* Unwrap(v8::Handle<v8::Object> obj); |
| + |
| + Global* fGlobal; |
| + |
| +private: |
| + // JS Attributes |
| + static void GetWidth(v8::Local<v8::String> name, |
| + const v8::PropertyCallbackInfo<v8::Value>& info); |
| + static void GetHeight(v8::Local<v8::String> name, |
| + const v8::PropertyCallbackInfo<v8::Value>& info); |
| + |
| + // JS Methods |
| + static void Save(const v8::FunctionCallbackInfo<v8::Value>& args); |
| + static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args); |
| + static void Rotate(const v8::FunctionCallbackInfo<v8::Value>& args); |
| + static void Translate(const v8::FunctionCallbackInfo<v8::Value>& args); |
| + static void ResetTransform(const v8::FunctionCallbackInfo<v8::Value>& args); |
| + |
| + static void DrawPath(const v8::FunctionCallbackInfo<v8::Value>& args); |
| +}; |
| + |
| +#endif |