/* * 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 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; // Add the Javascript attributes and methods that DrawingMethods // implements to the ObjectTemplate. void addAttributesAndMethods(v8::Handle tmpl); protected: // Get the pointer out of obj. static DrawingMethods* Unwrap(v8::Handle obj); Global* fGlobal; private: // JS Attributes static void GetWidth(v8::Local name, const v8::PropertyCallbackInfo& info); static void GetHeight(v8::Local name, const v8::PropertyCallbackInfo& info); // JS Methods static void Save(const v8::FunctionCallbackInfo& args); static void Restore(const v8::FunctionCallbackInfo& args); static void Rotate(const v8::FunctionCallbackInfo& args); static void Translate(const v8::FunctionCallbackInfo& args); static void ResetTransform(const v8::FunctionCallbackInfo& args); static void DrawPath(const v8::FunctionCallbackInfo& args); }; #endif