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

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

Issue 676423002: Start moving to the new canvas structure. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/DrawingMethods.cpp ('k') | experimental/SkV8Example/js/sample.js » ('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 "DrawingMethods.h"
17 17
18 class SkCanvas; 18 class SkCanvas;
19 class Global; 19 class Global;
20 20
21 // 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
22 // 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:
23 // 23 //
24 // function onDraw(context) { 24 // function onDraw(context) {
25 // context.fillStyle="#FF0000"; 25 // context.fillStyle="#FF0000";
26 // context.fillRect(x, y, w, h); 26 // context.fillRect(x, y, w, h);
27 // } 27 // }
28 class JsContext : public BaseContext { 28 class JsContext : public DrawingMethods {
29 public: 29 public:
30 JsContext(Global* global) 30 JsContext(Global* global)
31 : INHERITED(global) 31 : INHERITED(global)
32 , fCanvas(NULL) 32 , fCanvas(NULL)
33 { 33 {
34 } 34 }
35 virtual ~JsContext() {} 35 virtual ~JsContext() {}
36 36
37 // Parse the script. 37 // Parse the script.
38 bool initialize(); 38 bool initialize();
(...skipping 11 matching lines...) Expand all
50 // A handle to the onDraw function defined in the script. 50 // A handle to the onDraw function defined in the script.
51 v8::Persistent<v8::Function> fOnDraw; 51 v8::Persistent<v8::Function> fOnDraw;
52 52
53 // 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
54 // context object is what's passed into the JS onDraw() function. 54 // context object is what's passed into the JS onDraw() function.
55 static v8::Persistent<v8::ObjectTemplate> gContextTemplate; 55 static v8::Persistent<v8::ObjectTemplate> gContextTemplate;
56 56
57 // Only valid when inside OnDraw(). 57 // Only valid when inside OnDraw().
58 SkCanvas* fCanvas; 58 SkCanvas* fCanvas;
59 59
60 typedef BaseContext INHERITED; 60 typedef DrawingMethods INHERITED;
61 }; 61 };
62 62
63 #endif 63 #endif
OLDNEW
« no previous file with comments | « experimental/SkV8Example/DrawingMethods.cpp ('k') | experimental/SkV8Example/js/sample.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698