From 9bde13c1b27b3704a45992341855192032e966b2 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 10 Dec 2013 14:13:03 +0000 Subject: Add a canvas object with drawRect() and inval(). BUG= R=robertphillips@google.com Author: jcgregorio@google.com Review URL: https://codereview.chromium.org/110693002 git-svn-id: http://skia.googlecode.com/svn/trunk@12595 2bbb7eff-a529-9590-31e7-b0007b416f81 --- .gitignore | 1 + experimental/SkV8Example/SkV8Example.cpp | 390 ++++++++++++++++++++----------- experimental/SkV8Example/SkV8Example.h | 74 +++++- 3 files changed, 314 insertions(+), 151 deletions(-) diff --git a/.gitignore b/.gitignore index b44f4daf0d..2e09730bec 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ gyp/build/ out/ third_party/externals/ xcodebuild/ +TAGS diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp index 93f9d707cc..3c7a5f3642 100644 --- a/experimental/SkV8Example/SkV8Example.cpp +++ b/experimental/SkV8Example/SkV8Example.cpp @@ -33,139 +33,201 @@ void application_term() { // Extracts a C string from a V8 Utf8Value. const char* ToCString(const v8::String::Utf8Value& value) { - return *value ? *value : ""; + return *value ? *value : ""; } // Slight modification to an original function found in the V8 sample shell.cc. void reportException(Isolate* isolate, TryCatch* try_catch) { - HandleScope handle_scope(isolate); - String::Utf8Value exception(try_catch->Exception()); - const char* exception_string = ToCString(exception); - Handle message = try_catch->Message(); - if (message.IsEmpty()) { - // V8 didn't provide any extra information about this error; just - // print the exception. - fprintf(stderr, "%s\n", exception_string); - } else { - // Print (filename):(line number): (message). - String::Utf8Value filename(message->GetScriptResourceName()); - const char* filename_string = ToCString(filename); - int linenum = message->GetLineNumber(); - fprintf(stderr, "%s:%i: %s\n", filename_string, linenum, exception_string); - // Print line of source code. - String::Utf8Value sourceline(message->GetSourceLine()); - const char* sourceline_string = ToCString(sourceline); - fprintf(stderr, "%s\n", sourceline_string); - // Print wavy underline. - int start = message->GetStartColumn(); - for (int i = 0; i < start; i++) { - fprintf(stderr, " "); + HandleScope handleScope(isolate); + String::Utf8Value exception(try_catch->Exception()); + const char* exception_string = ToCString(exception); + Handle message = try_catch->Message(); + if (message.IsEmpty()) { + // V8 didn't provide any extra information about this error; just + // print the exception. + fprintf(stderr, "%s\n", exception_string); + } else { + // Print (filename):(line number): (message). + String::Utf8Value filename(message->GetScriptResourceName()); + const char* filename_string = ToCString(filename); + int linenum = message->GetLineNumber(); + fprintf(stderr, + "%s:%i: %s\n", filename_string, linenum, exception_string); + // Print line of source code. + String::Utf8Value sourceline(message->GetSourceLine()); + const char* sourceline_string = ToCString(sourceline); + fprintf(stderr, "%s\n", sourceline_string); + // Print wavy underline. + int start = message->GetStartColumn(); + for (int i = 0; i < start; i++) { + fprintf(stderr, " "); + } + int end = message->GetEndColumn(); + for (int i = start; i < end; i++) { + fprintf(stderr, "^"); + } + fprintf(stderr, "\n"); + String::Utf8Value stack_trace(try_catch->StackTrace()); + if (stack_trace.length() > 0) { + const char* stack_trace_string = ToCString(stack_trace); + fprintf(stderr, "%s\n", stack_trace_string); + } } - int end = message->GetEndColumn(); - for (int i = start; i < end; i++) { - fprintf(stderr, "^"); - } - fprintf(stderr, "\n"); - String::Utf8Value stack_trace(try_catch->StackTrace()); - if (stack_trace.length() > 0) { - const char* stack_trace_string = ToCString(stack_trace); - fprintf(stderr, "%s\n", stack_trace_string); - } - } } -SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, - Isolate* isolate, - Handle context, - Handle