144a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org/* 244a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * Copyright 2013 Google Inc. 344a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * 444a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * 544a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 644a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * found in the LICENSE file. 744a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org * 844a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org */ 944a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include <v8.h> 1044a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 1144a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.orgusing namespace v8; 1244a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 1344a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "SkV8Example.h" 140fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org#include "Global.h" 15c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org#include "JsContext.h" 16f679d1bf38a9e319c2b38fa53852f05b7f246e8ecommit-bot@chromium.org#include "Path2D.h" 1744a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 1844a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "gl/GrGLUtil.h" 1944a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "gl/GrGLDefines.h" 2044a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "gl/GrGLInterface.h" 219ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#include "GrRenderTarget.h" 229ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#include "GrContext.h" 2344a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "SkApplication.h" 2448d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org#include "SkCommandLineFlags.h" 2548d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org#include "SkData.h" 2644a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "SkDraw.h" 2744a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "SkGpuDevice.h" 2844a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org#include "SkGraphics.h" 293a6143d91f06d01f07b3b0e8adfa703a574d2beccommit-bot@chromium.org#include "SkScalar.h" 30939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org#include "SkSurface.h" 3144a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 3244a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 3348d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.orgDEFINE_string2(infile, i, NULL, "Name of file to load JS from.\n"); 349ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.orgDEFINE_bool(gpu, true, "Use the GPU for rendering."); 3548d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org 3644a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.orgvoid application_init() { 3744a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org SkGraphics::Init(); 3844a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org SkEvent::Init(); 3944a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org} 4044a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 4144a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.orgvoid application_term() { 4244a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org SkEvent::Term(); 4344a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org SkGraphics::Term(); 4444a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org} 4544a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org 46c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.orgSkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context) 470fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org : INHERITED(hwnd) 48c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org , fJsContext(context) 499ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 509ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org , fCurContext(NULL) 519ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org , fCurIntf(NULL) 529ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org , fCurRenderTarget(NULL) 53939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org , fCurSurface(NULL) 549ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 550fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org{ 56939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org this->setColorType(kBGRA_8888_SkColorType); 570fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org this->setVisibleP(true); 580fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org this->setClipToBounds(false); 599ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 609ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 619ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org this->windowSizeChanged(); 629ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 639ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org} 649ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 65939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.orgSkV8ExampleWindow::~SkV8ExampleWindow() { 66939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org#if SK_SUPPORT_GPU 67939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkSafeUnref(fCurContext); 68939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkSafeUnref(fCurIntf); 69939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkSafeUnref(fCurRenderTarget); 70939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkSafeUnref(fCurSurface); 71939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org#endif 72939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org} 73939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org 749ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 759ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.orgvoid SkV8ExampleWindow::windowSizeChanged() { 769ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org if (FLAGS_gpu) { 779ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org SkOSWindow::AttachmentInfo attachmentInfo; 789ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org bool result = this->attach( 799ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org SkOSWindow::kNativeGL_BackEndType, 0, &attachmentInfo); 809ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org if (!result) { 819ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org printf("Failed to attach."); 829ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org exit(1); 839ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } 849ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 859ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org fCurIntf = GrGLCreateNativeInterface(); 869ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org fCurContext = GrContext::Create( 879ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org kOpenGL_GrBackend, (GrBackendContext) fCurIntf); 889ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org if (NULL == fCurIntf || NULL == fCurContext) { 899ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org printf("Failed to initialize GL."); 909ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org exit(1); 919ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } 929ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 939ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org GrBackendRenderTargetDesc desc; 949ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fWidth = SkScalarRoundToInt(this->width()); 959ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fHeight = SkScalarRoundToInt(this->height()); 969ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fConfig = kSkia8888_GrPixelConfig; 979ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fOrigin = kBottomLeft_GrSurfaceOrigin; 989ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fSampleCnt = attachmentInfo.fSampleCount; 999ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fStencilBits = attachmentInfo.fStencilBits; 1009ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org GrGLint buffer; 1019ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); 1029ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org desc.fRenderTargetHandle = buffer; 1039ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 1049ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org SkSafeUnref(fCurRenderTarget); 1059ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); 106939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkSafeUnref(fCurSurface); 107939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget); 1089ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } 1099ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org} 1109ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 1119ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 1129ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 1139ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.orgSkCanvas* SkV8ExampleWindow::createCanvas() { 1149ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org if (FLAGS_gpu) { 115939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org SkCanvas* c = fCurSurface->getCanvas(); 116939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org // Increase the ref count since the surface keeps a reference 117939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org // to the canvas, but callers of createCanvas put the results 118939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org // in a SkAutoTUnref. 119939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org c->ref(); 120939560b87a392911c5aeaacdbd1f8d26fe4845adcommit-bot@chromium.org return c; 1219ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } else { 1229ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org return this->INHERITED::createCanvas(); 1239ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } 1249ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org} 1259ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 1269ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 1279ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.orgvoid SkV8ExampleWindow::onSizeChange() { 1289ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org this->INHERITED::onSizeChange(); 1299ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 1309ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 1319ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org this->windowSizeChanged(); 1329ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 1330fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org} 1340fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1350fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.orgvoid SkV8ExampleWindow::onDraw(SkCanvas* canvas) { 1360fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1370fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org canvas->save(); 1380fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org canvas->drawColor(SK_ColorWHITE); 1390fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1400fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org // Now jump into JS and call the onDraw(canvas) method defined there. 141c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org fJsContext->onDraw(canvas); 1420fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1430fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org canvas->restore(); 1440fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1459ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org this->INHERITED::onDraw(canvas); 1460fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1479ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#if SK_SUPPORT_GPU 1489ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org if (FLAGS_gpu) { 1499ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org fCurContext->flush(); 1509ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org this->present(); 1519ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org } 1529ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org#endif 1539ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org} 1540fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1550fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org#ifdef SK_BUILD_FOR_WIN 1560fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.orgvoid SkV8ExampleWindow::onHandleInval(const SkIRect& rect) { 1570fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org RECT winRect; 1580fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org winRect.top = rect.top(); 1590fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org winRect.bottom = rect.bottom(); 1600fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org winRect.right = rect.right(); 1610fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org winRect.left = rect.left(); 1620fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org InvalidateRect((HWND)this->getHWND(), &winRect, false); 1630fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org} 1640fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org#endif 1650fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 1669bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.orgSkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { 1679bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org printf("Started\n"); 1689bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org 16948d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org SkCommandLineFlags::Parse(argc, argv); 17048d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org 1719bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org // Get the default Isolate created at startup. 1729bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org Isolate* isolate = Isolate::GetCurrent(); 1730fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org Global* global = new Global(isolate); 17448d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org 175cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org 176cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org // Set up things to look like a browser by creating 177cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org // a console object that invokes our print function. 178cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org const char* startupScript = 179cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "function Console() {}; \n" 180cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "Console.prototype.log = function() { \n" 181cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org " var args = Array.prototype.slice.call(arguments).join(' '); \n" 182cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org " print(args); \n" 183cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "}; \n" 184cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "console = new Console(); \n"; 185cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org 186cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org if (!global->parseScript(startupScript)) { 187cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org printf("Failed to parse startup script: %s.\n", FLAGS_infile[0]); 188cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org exit(1); 189cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org } 190cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org 1913a6143d91f06d01f07b3b0e8adfa703a574d2beccommit-bot@chromium.org const char* script = 192cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "function onDraw(canvas) { \n" 193cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org " canvas.fillStyle = '#00FF00'; \n" 194cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org " canvas.fillRect(20, 20, 100, 100); \n" 195cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org " canvas.inval(); \n" 196cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org "} \n"; 19748d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org 19848d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org SkAutoTUnref<SkData> data; 19948d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org if (FLAGS_infile.count()) { 20048d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org data.reset(SkData::NewFromFileName(FLAGS_infile[0])); 20148d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org script = static_cast<const char*>(data->data()); 20248d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org } 20348d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org if (NULL == script) { 20448d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org printf("Could not load file: %s.\n", FLAGS_infile[0]); 20548d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org exit(1); 20648d94b8ce51a4b75fe1fe996b135fcd5b2d34779commit-bot@chromium.org } 207f679d1bf38a9e319c2b38fa53852f05b7f246e8ecommit-bot@chromium.org Path2D::AddToGlobal(global); 2080fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 2090fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org if (!global->parseScript(script)) { 210872796bb8eaabbd9ab76dc8821310438aa690d85commit-bot@chromium.org printf("Failed to parse file: %s.\n", FLAGS_infile[0]); 2110fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org exit(1); 2120fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org } 2130fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 214cd110186256cee6acb0d503ab4af4b7ea7dc48a1commit-bot@chromium.org 215c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org JsContext* jsContext = new JsContext(global); 2160fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org 217c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org if (!jsContext->initialize()) { 2189bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org printf("Failed to initialize.\n"); 2199bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org exit(1); 2209bde13c1b27b3704a45992341855192032e966b2commit-bot@chromium.org } 221c8d732800e1a660fca6d2478fc24d6e6935ef8adcommit-bot@chromium.org SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); 2220fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org global->setWindow(win); 2239ee0e32886254fc3feba9ab25ec112b270085b92commit-bot@chromium.org 2240fc0dea333f313a579558beb7ba498db0711780ecommit-bot@chromium.org return win; 22544a3877442805f48158c0d1e936b9c3970ddd3afcommit-bot@chromium.org} 226