Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1407)

Unified Diff: experimental/SkV8Example/SkV8Example.h

Issue 108813004: Added canvas.fillStyle with support for just the "#RRGGBB" style of colors. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Review fixes. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/SkV8Example/SkV8Example.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/SkV8Example/SkV8Example.h
diff --git a/experimental/SkV8Example/SkV8Example.h b/experimental/SkV8Example/SkV8Example.h
index 878e1f0f1f8db13a1ce9a5d863711af648637576..9ed0eccb1247e6d17e7eab071d35506384222d9f 100644
--- a/experimental/SkV8Example/SkV8Example.h
+++ b/experimental/SkV8Example/SkV8Example.h
@@ -13,6 +13,7 @@
#include <v8.h>
#include "SkWindow.h"
+#include "SkPaint.h"
using namespace v8;
@@ -32,7 +33,6 @@ protected:
private:
typedef SkOSWindow INHERITED;
- SkScalar fRotationAngle;
JsCanvas* fJsCanvas;
};
@@ -41,17 +41,19 @@ private:
// that's used to bridge from C++ to JS. Should be used in JS as:
//
// function onDraw(canvas) {
-// canvas.drawRect();
-// canvas.inval();
+// canvas.fillStyle="#FF0000";
+// canvas.fillRect(x, y, w, h);
+// canvas.inval();
// }
-//
class JsCanvas {
public:
JsCanvas(Isolate* isolate)
: fIsolate(isolate)
, fCanvas(NULL)
, fWindow(NULL)
- {}
+ {
+ fFillStyle.setColor(SK_ColorRED);
+ }
~JsCanvas();
// Parse the script.
@@ -61,14 +63,20 @@ public:
void onDraw(SkCanvas* canvas, SkOSWindow* window);
private:
- // Implementation of the canvas.drawRect() JS function.
- static void drawRect(const v8::FunctionCallbackInfo<Value>& args);
+ // Implementation of the canvas.fillStyle field.
+ static void GetFillStyle(Local<String> name,
+ const PropertyCallbackInfo<Value>& info);
+ static void SetFillStyle(Local<String> name, Local<Value> value,
+ const PropertyCallbackInfo<void>& info);
+
+ // Implementation of the canvas.fillRect() JS function.
+ static void FillRect(const v8::FunctionCallbackInfo<Value>& args);
// Implementation of the canvas.inval() JS function.
- static void inval(const v8::FunctionCallbackInfo<Value>& args);
+ static void Inval(const v8::FunctionCallbackInfo<Value>& args);
// Get the pointer out of obj.
- static JsCanvas* unwrap(Handle<Object> obj);
+ static JsCanvas* Unwrap(Handle<Object> obj);
// Create a template for JS object associated with JsCanvas, called lazily
// by Wrap() and the results are stored in fCanvasTemplate;
@@ -82,6 +90,8 @@ private:
// Only valid when inside OnDraw().
SkCanvas* fCanvas;
+ SkPaint fFillStyle;
+
// Only valid when inside OnDraw().
SkOSWindow* fWindow;
« no previous file with comments | « no previous file | experimental/SkV8Example/SkV8Example.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698