Chromium Code Reviews| Index: experimental/SkV8Example/JsContext.h |
| diff --git a/experimental/SkV8Example/JsContext.h b/experimental/SkV8Example/JsContext.h |
| index c1466a08dda05e4cb7dc3b99dcc68865e6493c36..2a7ca507a10ad5476404dd32ac526bdad0406318 100644 |
| --- a/experimental/SkV8Example/JsContext.h |
| +++ b/experimental/SkV8Example/JsContext.h |
| @@ -13,6 +13,7 @@ |
| #include <v8.h> |
| #include "SkPaint.h" |
| +#include "BaseContext.h" |
| using namespace v8; |
| @@ -26,20 +27,14 @@ class Global; |
| // context.fillStyle="#FF0000"; |
| // context.fillRect(x, y, w, h); |
| // } |
| -class JsContext { |
| +class JsContext : public BaseContext { |
| public: |
| JsContext(Global* global) |
| - : fGlobal(global) |
| + : INHERITED(global) |
| , fCanvas(NULL) |
| { |
| - fFillStyle.setColor(SK_ColorBLACK); |
| - fFillStyle.setAntiAlias(true); |
| - fFillStyle.setStyle(SkPaint::kFill_Style); |
| - fStrokeStyle.setColor(SK_ColorBLACK); |
| - fStrokeStyle.setAntiAlias(true); |
| - fStrokeStyle.setStyle(SkPaint::kStroke_Style); |
| } |
|
robertphillips
2014/03/04 20:05:03
virtual
jcgregorio
2014/03/04 20:29:31
Done.
|
| - ~JsContext(); |
| + ~JsContext() {} |
| // Parse the script. |
| bool initialize(); |
| @@ -47,61 +42,24 @@ public: |
| // Call this with the SkCanvas you want onDraw to draw on. |
| void onDraw(SkCanvas* canvas); |
| + virtual SkCanvas* getCanvas() { return fCanvas; }; |
| + |
| private: |
| - static void GetStyle(Local<String> name, |
| - const PropertyCallbackInfo<Value>& info, |
| - const SkPaint& style); |
| - static void SetStyle(Local<String> name, Local<Value> value, |
| - const PropertyCallbackInfo<void>& info, |
| - SkPaint& style); |
| - // JS Attributes |
| - static void GetFillStyle(Local<String> name, |
| - const PropertyCallbackInfo<Value>& info); |
| - static void SetFillStyle(Local<String> name, Local<Value> value, |
| - const PropertyCallbackInfo<void>& info); |
| - static void GetStrokeStyle(Local<String> name, |
| - const PropertyCallbackInfo<Value>& info); |
| - static void SetStrokeStyle(Local<String> name, Local<Value> value, |
| - const PropertyCallbackInfo<void>& info); |
| - static void GetWidth(Local<String> name, |
| - const PropertyCallbackInfo<Value>& info); |
| - static void GetHeight(Local<String> name, |
| - const PropertyCallbackInfo<Value>& info); |
| - |
| - // JS Methods |
| - static void FillRect(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Stroke(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Fill(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Rotate(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Save(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Restore(const v8::FunctionCallbackInfo<Value>& args); |
| - static void Translate(const v8::FunctionCallbackInfo<Value>& args); |
| - static void ResetTransform(const v8::FunctionCallbackInfo<Value>& args); |
| - |
| - // Get the pointer out of obj. |
| - static JsContext* Unwrap(Handle<Object> obj); |
| - |
| - // Create a template for JS object associated with JsContext, called lazily |
| - // by Wrap() and the results are stored in gContextTemplate; |
| - Handle<ObjectTemplate> makeContextTemplate(); |
| // Wrap the 'this' pointer into an Object. Can be retrieved via Unwrap. |
| Handle<Object> wrap(); |
| - Global* fGlobal; |
| - |
| - // Only valid when inside OnDraw(). |
| - SkCanvas* fCanvas; |
| - |
| - SkPaint fFillStyle; |
| - SkPaint fStrokeStyle; |
| - |
| // A handle to the onDraw function defined in the script. |
| Persistent<Function> fOnDraw; |
| // The template for what a canvas context object looks like. The canvas |
| // context object is what's passed into the JS onDraw() function. |
| static Persistent<ObjectTemplate> gContextTemplate; |
| + |
|
robertphillips
2014/03/04 20:05:03
this should be last
jcgregorio
2014/03/04 20:29:31
Done.
|
| + typedef BaseContext INHERITED; |
| + |
| + // Only valid when inside OnDraw(). |
| + SkCanvas* fCanvas; |
| }; |
| #endif |