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

Side by Side Diff: experimental/SkV8Example/BaseContext.h

Issue 673223002: Get SkV8Example running again. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | experimental/SkV8Example/BaseContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 * 7 *
8 */ 8 */
9 9
10 #ifndef SkV8Example_BaseContext_DEFINED 10 #ifndef SkV8Example_BaseContext_DEFINED
11 #define SkV8Example_BaseContext_DEFINED 11 #define SkV8Example_BaseContext_DEFINED
12 12
13 #include <v8.h> 13 #include <v8.h>
14 14
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 16
17 using namespace v8;
18
19 class SkCanvas; 17 class SkCanvas;
20 class Global; 18 class Global;
21 19
22 // BaseContext contains common functionality for both JsContext 20 // BaseContext contains common functionality for both JsContext
23 // and DisplayList. 21 // and DisplayList.
24 class BaseContext { 22 class BaseContext {
25 public: 23 public:
26 BaseContext(Global* global) 24 BaseContext(Global* global)
27 : fGlobal(global) 25 : fGlobal(global)
28 { 26 {
29 fFillStyle.setColor(SK_ColorBLACK); 27 fFillStyle.setColor(SK_ColorBLACK);
30 fFillStyle.setAntiAlias(true); 28 fFillStyle.setAntiAlias(true);
31 fFillStyle.setStyle(SkPaint::kFill_Style); 29 fFillStyle.setStyle(SkPaint::kFill_Style);
32 fStrokeStyle.setColor(SK_ColorBLACK); 30 fStrokeStyle.setColor(SK_ColorBLACK);
33 fStrokeStyle.setAntiAlias(true); 31 fStrokeStyle.setAntiAlias(true);
34 fStrokeStyle.setStyle(SkPaint::kStroke_Style); 32 fStrokeStyle.setStyle(SkPaint::kStroke_Style);
35 } 33 }
36 virtual ~BaseContext() {} 34 virtual ~BaseContext() {}
37 35
38 // Retrieve the SkCanvas to draw on. May return NULL. 36 // Retrieve the SkCanvas to draw on. May return NULL.
39 virtual SkCanvas* getCanvas() = 0; 37 virtual SkCanvas* getCanvas() = 0;
40 38
41 // Add the Javascript attributes and methods that BaseContext implements to the ObjectTemplate. 39 // Add the Javascript attributes and methods that BaseContext implements to the ObjectTemplate.
42 void addAttributesAndMethods(Handle<ObjectTemplate> tmpl); 40 void addAttributesAndMethods(v8::Handle<v8::ObjectTemplate> tmpl);
43 41
44 protected: 42 protected:
45 // Get the pointer out of obj. 43 // Get the pointer out of obj.
46 static BaseContext* Unwrap(Handle<Object> obj); 44 static BaseContext* Unwrap(v8::Handle<v8::Object> obj);
47 45
48 Global* fGlobal; 46 Global* fGlobal;
49 SkPaint fFillStyle; 47 SkPaint fFillStyle;
50 SkPaint fStrokeStyle; 48 SkPaint fStrokeStyle;
51 49
52 private: 50 private:
53 static void GetStyle(Local<String> name, 51 static void GetStyle(v8::Local<v8::String> name,
54 const PropertyCallbackInfo<Value>& info, 52 const v8::PropertyCallbackInfo<v8::Value>& info,
55 const SkPaint& style); 53 const SkPaint& style);
56 static void SetStyle(Local<String> name, Local<Value> value, 54 static void SetStyle(v8::Local<v8::String> name, v8::Local<v8::Value> value,
57 const PropertyCallbackInfo<void>& info, 55 const v8::PropertyCallbackInfo<void>& info,
58 SkPaint& style); 56 SkPaint& style);
59 // JS Attributes 57 // JS Attributes
60 static void GetFillStyle(Local<String> name, 58 static void GetFillStyle(v8::Local<v8::String> name,
61 const PropertyCallbackInfo<Value>& info); 59 const v8::PropertyCallbackInfo<v8::Value>& info);
62 static void SetFillStyle(Local<String> name, Local<Value> value, 60 static void SetFillStyle(v8::Local<v8::String> name, v8::Local<v8::Value> va lue,
63 const PropertyCallbackInfo<void>& info); 61 const v8::PropertyCallbackInfo<void>& info);
64 static void GetStrokeStyle(Local<String> name, 62 static void GetStrokeStyle(v8::Local<v8::String> name,
65 const PropertyCallbackInfo<Value>& info); 63 const v8::PropertyCallbackInfo<v8::Value>& info);
66 static void SetStrokeStyle(Local<String> name, Local<Value> value, 64 static void SetStrokeStyle(v8::Local<v8::String> name, v8::Local<v8::Value> value,
67 const PropertyCallbackInfo<void>& info); 65 const v8::PropertyCallbackInfo<void>& info);
68 static void GetWidth(Local<String> name, 66 static void GetWidth(v8::Local<v8::String> name,
69 const PropertyCallbackInfo<Value>& info); 67 const v8::PropertyCallbackInfo<v8::Value>& info);
70 static void GetHeight(Local<String> name, 68 static void GetHeight(v8::Local<v8::String> name,
71 const PropertyCallbackInfo<Value>& info); 69 const v8::PropertyCallbackInfo<v8::Value>& info);
72 70
73 // JS Methods 71 // JS Methods
74 static void FillRect(const v8::FunctionCallbackInfo<Value>& args); 72 static void FillRect(const v8::FunctionCallbackInfo<v8::Value>& args);
75 static void Stroke(const v8::FunctionCallbackInfo<Value>& args); 73 static void Stroke(const v8::FunctionCallbackInfo<v8::Value>& args);
76 static void Fill(const v8::FunctionCallbackInfo<Value>& args); 74 static void Fill(const v8::FunctionCallbackInfo<v8::Value>& args);
77 static void Rotate(const v8::FunctionCallbackInfo<Value>& args); 75 static void Rotate(const v8::FunctionCallbackInfo<v8::Value>& args);
78 static void Save(const v8::FunctionCallbackInfo<Value>& args); 76 static void Save(const v8::FunctionCallbackInfo<v8::Value>& args);
79 static void Restore(const v8::FunctionCallbackInfo<Value>& args); 77 static void Restore(const v8::FunctionCallbackInfo<v8::Value>& args);
80 static void Translate(const v8::FunctionCallbackInfo<Value>& args); 78 static void Translate(const v8::FunctionCallbackInfo<v8::Value>& args);
81 static void ResetTransform(const v8::FunctionCallbackInfo<Value>& args); 79 static void ResetTransform(const v8::FunctionCallbackInfo<v8::Value>& args);
82 }; 80 };
83 81
84 #endif 82 #endif
OLDNEW
« no previous file with comments | « no previous file | experimental/SkV8Example/BaseContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698