| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include <v8.h> | 9 #include <v8.h> |
| 10 #include <include/libplatform/libplatform.h> | 10 #include <include/libplatform/libplatform.h> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 exit(1); | 193 exit(1); |
| 194 } | 194 } |
| 195 | 195 |
| 196 const char* script = | 196 const char* script = |
| 197 "function onDraw(canvas) { \n" | 197 "function onDraw(canvas) { \n" |
| 198 " canvas.fillStyle = '#00FF00'; \n" | 198 " canvas.fillStyle = '#00FF00'; \n" |
| 199 " canvas.fillRect(20, 20, 100, 100); \n" | 199 " canvas.fillRect(20, 20, 100, 100); \n" |
| 200 " canvas.inval(); \n" | 200 " canvas.inval(); \n" |
| 201 "} \n"; | 201 "} \n"; |
| 202 | 202 |
| 203 SkAutoTUnref<SkData> data; | 203 sk_sp<SkData> data; |
| 204 if (FLAGS_infile.count()) { | 204 if (FLAGS_infile.count()) { |
| 205 data.reset(SkData::NewFromFileName(FLAGS_infile[0])); | 205 data = SkData::MakeFromFileName(FLAGS_infile[0]); |
| 206 script = static_cast<const char*>(data->data()); | 206 script = static_cast<const char*>(data->data()); |
| 207 } | 207 } |
| 208 if (NULL == script) { | 208 if (NULL == script) { |
| 209 printf("Could not load file: %s.\n", FLAGS_infile[0]); | 209 printf("Could not load file: %s.\n", FLAGS_infile[0]); |
| 210 exit(1); | 210 exit(1); |
| 211 } | 211 } |
| 212 Path2DBuilder::AddToGlobal(global); | 212 Path2DBuilder::AddToGlobal(global); |
| 213 Path2D::AddToGlobal(global); | 213 Path2D::AddToGlobal(global); |
| 214 | 214 |
| 215 if (!global->parseScript(script)) { | 215 if (!global->parseScript(script)) { |
| 216 printf("Failed to parse file: %s.\n", FLAGS_infile[0]); | 216 printf("Failed to parse file: %s.\n", FLAGS_infile[0]); |
| 217 exit(1); | 217 exit(1); |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 JsContext* jsContext = new JsContext(global); | 221 JsContext* jsContext = new JsContext(global); |
| 222 | 222 |
| 223 if (!jsContext->initialize()) { | 223 if (!jsContext->initialize()) { |
| 224 printf("Failed to initialize.\n"); | 224 printf("Failed to initialize.\n"); |
| 225 exit(1); | 225 exit(1); |
| 226 } | 226 } |
| 227 SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); | 227 SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); |
| 228 global->setWindow(win); | 228 global->setWindow(win); |
| 229 | 229 |
| 230 return win; | 230 return win; |
| 231 } | 231 } |
| OLD | NEW |