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

Side by Side Diff: experimental/SkV8Example/JsContext.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 | « experimental/SkV8Example/Global.cpp ('k') | experimental/SkV8Example/JsContext.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_JsContext_DEFINED 10 #ifndef SkV8Example_JsContext_DEFINED
11 #define SkV8Example_JsContext_DEFINED 11 #define SkV8Example_JsContext_DEFINED
12 12
13 #include <v8.h> 13 #include <v8.h>
14 14
15 #include "SkPaint.h" 15 #include "SkPaint.h"
16 #include "BaseContext.h" 16 #include "BaseContext.h"
17 17
18 using namespace v8;
19
20 class SkCanvas; 18 class SkCanvas;
21 class Global; 19 class Global;
22 20
23 // Provides the canvas context implementation in JS, and the OnDraw() method in 21 // Provides the canvas context implementation in JS, and the OnDraw() method in
24 // C++ that's used to bridge from C++ to JS. Should be used in JS as: 22 // C++ that's used to bridge from C++ to JS. Should be used in JS as:
25 // 23 //
26 // function onDraw(context) { 24 // function onDraw(context) {
27 // context.fillStyle="#FF0000"; 25 // context.fillStyle="#FF0000";
28 // context.fillRect(x, y, w, h); 26 // context.fillRect(x, y, w, h);
29 // } 27 // }
(...skipping 10 matching lines...) Expand all
40 bool initialize(); 38 bool initialize();
41 39
42 // Call this with the SkCanvas you want onDraw to draw on. 40 // Call this with the SkCanvas you want onDraw to draw on.
43 void onDraw(SkCanvas* canvas); 41 void onDraw(SkCanvas* canvas);
44 42
45 virtual SkCanvas* getCanvas() { return fCanvas; }; 43 virtual SkCanvas* getCanvas() { return fCanvas; };
46 44
47 private: 45 private:
48 46
49 // Wrap the 'this' pointer into an Object. Can be retrieved via Unwrap. 47 // Wrap the 'this' pointer into an Object. Can be retrieved via Unwrap.
50 Handle<Object> wrap(); 48 v8::Handle<v8::Object> wrap();
51 49
52 // A handle to the onDraw function defined in the script. 50 // A handle to the onDraw function defined in the script.
53 Persistent<Function> fOnDraw; 51 v8::Persistent<v8::Function> fOnDraw;
54 52
55 // The template for what a canvas context object looks like. The canvas 53 // The template for what a canvas context object looks like. The canvas
56 // context object is what's passed into the JS onDraw() function. 54 // context object is what's passed into the JS onDraw() function.
57 static Persistent<ObjectTemplate> gContextTemplate; 55 static v8::Persistent<v8::ObjectTemplate> gContextTemplate;
58 56
59 // Only valid when inside OnDraw(). 57 // Only valid when inside OnDraw().
60 SkCanvas* fCanvas; 58 SkCanvas* fCanvas;
61 59
62 typedef BaseContext INHERITED; 60 typedef BaseContext INHERITED;
63 }; 61 };
64 62
65 #endif 63 #endif
OLDNEW
« no previous file with comments | « experimental/SkV8Example/Global.cpp ('k') | experimental/SkV8Example/JsContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698