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

Unified Diff: experimental/SkV8Example/SkV8Example.cpp

Issue 132413002: Just use one version of the scripts in both the browser and in SkV8. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/SkV8Example/Path.cpp ('k') | experimental/SkV8Example/compare/gears.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/SkV8Example/SkV8Example.cpp
diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp
index 6eb8d89e047fa403dfdbac9a28d839595034175f..eb0e7133769eec94198d58352b8b36509a0968d1 100644
--- a/experimental/SkV8Example/SkV8Example.cpp
+++ b/experimental/SkV8Example/SkV8Example.cpp
@@ -156,12 +156,28 @@ SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
Isolate* isolate = Isolate::GetCurrent();
Global* global = new Global(isolate);
+
+ // Set up things to look like a browser by creating
+ // a console object that invokes our print function.
+ const char* startupScript =
+ "function Console() {}; \n"
+ "Console.prototype.log = function() { \n"
+ " var args = Array.prototype.slice.call(arguments).join(' '); \n"
+ " print(args); \n"
+ "}; \n"
+ "console = new Console(); \n";
+
+ if (!global->parseScript(startupScript)) {
+ printf("Failed to parse startup script: %s.\n", FLAGS_infile[0]);
+ exit(1);
+ }
+
const char* script =
-"function onDraw(canvas) { \n"
-" canvas.fillStyle = '#00FF00'; \n"
-" canvas.fillRect(20, 20, 100, 100); \n"
-" canvas.inval(); \n"
-"} \n";
+ "function onDraw(canvas) { \n"
+ " canvas.fillStyle = '#00FF00'; \n"
+ " canvas.fillRect(20, 20, 100, 100); \n"
+ " canvas.inval(); \n"
+ "} \n";
SkAutoTUnref<SkData> data;
if (FLAGS_infile.count()) {
@@ -179,6 +195,7 @@ SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
exit(1);
}
+
JsContext* jsContext = new JsContext(global);
if (!jsContext->initialize()) {
« no previous file with comments | « experimental/SkV8Example/Path.cpp ('k') | experimental/SkV8Example/compare/gears.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698