Rename Path to Path2D

BUG=skia:
R=robertphillips@google.com

Author: jcgregorio@google.com

Review URL: https://codereview.chromium.org/177963005

git-svn-id: http://skia.googlecode.com/svn/trunk@13615 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-02-27 20:20:21 +00:00
parent 64ca10287a
commit f679d1bf38
8 changed files with 49 additions and 49 deletions

View File

@ -13,7 +13,7 @@ using namespace v8;
#include "Global.h"
#include "JsContext.h"
#include "Path.h"
#include "Path2D.h"
#include "SkCanvas.h"
@ -119,7 +119,7 @@ void JsContext::Stroke(const v8::FunctionCallbackInfo<Value>& args) {
Handle<External> field = Handle<External>::Cast(
args[0]->ToObject()->GetInternalField(0));
void* ptr = field->Value();
Path* path = static_cast<Path*>(ptr);
Path2D* path = static_cast<Path2D*>(ptr);
canvas->drawPath(path->getSkPath(), jsContext->fStrokeStyle);
}
@ -138,7 +138,7 @@ void JsContext::Fill(const v8::FunctionCallbackInfo<Value>& args) {
Handle<External> field = Handle<External>::Cast(
args[0]->ToObject()->GetInternalField(0));
void* ptr = field->Value();
Path* path = static_cast<Path*>(ptr);
Path2D* path = static_cast<Path2D*>(ptr);
canvas->drawPath(path->getSkPath(), jsContext->fFillStyle);
}

View File

@ -7,14 +7,14 @@
*
*/
#include "Path.h"
#include "Path2D.h"
#include "Global.h"
Global* Path::gGlobal = NULL;
Global* Path2D::gGlobal = NULL;
void Path::ConstructPath(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::ConstructPath(const v8::FunctionCallbackInfo<Value>& args) {
HandleScope handleScope(gGlobal->getIsolate());
Path* path = new Path();
Path2D* path = new Path2D();
args.This()->SetInternalField(
0, External::New(gGlobal->getIsolate(), path));
}
@ -26,9 +26,9 @@ void Path::ConstructPath(const v8::FunctionCallbackInfo<Value>& args) {
String::kInternalizedString), \
FunctionTemplate::New(global->getIsolate(), fn))
// Install the constructor in the global scope so Paths can be constructed
// Install the constructor in the global scope so Path2Ds can be constructed
// in JS.
void Path::AddToGlobal(Global* global) {
void Path2D::AddToGlobal(Global* global) {
gGlobal = global;
// Create a stack-allocated handle scope.
@ -40,7 +40,7 @@ void Path::AddToGlobal(Global* global) {
Context::Scope contextScope(context);
Local<FunctionTemplate> constructor = FunctionTemplate::New(
gGlobal->getIsolate(), Path::ConstructPath);
gGlobal->getIsolate(), Path2D::ConstructPath);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
ADD_METHOD("closePath", ClosePath);
@ -54,22 +54,22 @@ void Path::AddToGlobal(Global* global) {
ADD_METHOD("conicTo", ConicTo);
context->Global()->Set(String::NewFromUtf8(
gGlobal->getIsolate(), "Path"), constructor->GetFunction());
gGlobal->getIsolate(), "Path2D"), constructor->GetFunction());
}
Path* Path::Unwrap(const v8::FunctionCallbackInfo<Value>& args) {
Path2D* Path2D::Unwrap(const v8::FunctionCallbackInfo<Value>& args) {
Handle<External> field = Handle<External>::Cast(
args.This()->GetInternalField(0));
void* ptr = field->Value();
return static_cast<Path*>(ptr);
return static_cast<Path2D*>(ptr);
}
void Path::ClosePath(const v8::FunctionCallbackInfo<Value>& args) {
Path* path = Unwrap(args);
void Path2D::ClosePath(const v8::FunctionCallbackInfo<Value>& args) {
Path2D* path = Unwrap(args);
path->fSkPath.close();
}
void Path::MoveTo(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::MoveTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -78,11 +78,11 @@ void Path::MoveTo(const v8::FunctionCallbackInfo<Value>& args) {
}
double x = args[0]->NumberValue();
double y = args[1]->NumberValue();
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
path->fSkPath.moveTo(SkDoubleToScalar(x), SkDoubleToScalar(y));
}
void Path::LineTo(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::LineTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -91,11 +91,11 @@ void Path::LineTo(const v8::FunctionCallbackInfo<Value>& args) {
}
double x = args[0]->NumberValue();
double y = args[1]->NumberValue();
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
path->fSkPath.lineTo(SkDoubleToScalar(x), SkDoubleToScalar(y));
}
void Path::QuadraticCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::QuadraticCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 4) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -106,7 +106,7 @@ void Path::QuadraticCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
double cpy = args[1]->NumberValue();
double x = args[2]->NumberValue();
double y = args[3]->NumberValue();
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
// TODO(jcgregorio) Doesn't handle the empty last path case correctly per
// the HTML 5 spec.
path->fSkPath.quadTo(
@ -114,7 +114,7 @@ void Path::QuadraticCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
SkDoubleToScalar(x), SkDoubleToScalar(y));
}
void Path::BezierCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::BezierCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 6) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -127,7 +127,7 @@ void Path::BezierCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
double cp2y = args[3]->NumberValue();
double x = args[4]->NumberValue();
double y = args[5]->NumberValue();
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
// TODO(jcgregorio) Doesn't handle the empty last path case correctly per
// the HTML 5 spec.
path->fSkPath.cubicTo(
@ -136,7 +136,7 @@ void Path::BezierCurveTo(const v8::FunctionCallbackInfo<Value>& args) {
SkDoubleToScalar(x), SkDoubleToScalar(y));
}
void Path::Arc(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::Arc(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 5 && args.Length() != 6) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -160,7 +160,7 @@ void Path::Arc(const v8::FunctionCallbackInfo<Value>& args) {
startAngle = endAngle;
}
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
SkRect rect = {
SkDoubleToScalar(x-radius),
SkDoubleToScalar(y-radius),
@ -172,7 +172,7 @@ void Path::Arc(const v8::FunctionCallbackInfo<Value>& args) {
SkRadiansToDegrees(sweepAngle));
}
void Path::Rect(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::Rect(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 4) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -190,11 +190,11 @@ void Path::Rect(const v8::FunctionCallbackInfo<Value>& args) {
SkDoubleToScalar(x) + SkDoubleToScalar(w),
SkDoubleToScalar(y) + SkDoubleToScalar(h)
};
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
path->fSkPath.addRect(rect);
}
void Path::Oval(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::Oval(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 4 && args.Length() != 5) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -209,7 +209,7 @@ void Path::Oval(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() == 5 && !args[4]->BooleanValue()) {
dir = SkPath::kCCW_Direction;
}
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
SkRect rect = {
SkDoubleToScalar(x-radiusX),
SkDoubleToScalar(y-radiusX),
@ -220,7 +220,7 @@ void Path::Oval(const v8::FunctionCallbackInfo<Value>& args) {
path->fSkPath.addOval(rect, dir);
}
void Path::ConicTo(const v8::FunctionCallbackInfo<Value>& args) {
void Path2D::ConicTo(const v8::FunctionCallbackInfo<Value>& args) {
if (args.Length() != 5) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(
@ -232,7 +232,7 @@ void Path::ConicTo(const v8::FunctionCallbackInfo<Value>& args) {
double x2 = args[2]->NumberValue();
double y2 = args[3]->NumberValue();
double w = args[4]->NumberValue();
Path* path = Unwrap(args);
Path2D* path = Unwrap(args);
path->fSkPath.conicTo(
SkDoubleToScalar(x1),

View File

@ -7,8 +7,8 @@
*
*/
#ifndef SkV8Example_Path_DEFINED
#define SkV8Example_Path_DEFINED
#ifndef SkV8Example_Path2D_DEFINED
#define SkV8Example_Path2D_DEFINED
#include <v8.h>
@ -17,20 +17,20 @@
class Global;
class Path : SkNoncopyable {
class Path2D : SkNoncopyable {
public:
Path() : fSkPath() {}
virtual ~Path() {}
Path2D() : fSkPath() {}
virtual ~Path2D() {}
const SkPath& getSkPath() { return fSkPath; }
// The JS Path constuctor implementation.
// The JS Path2D constuctor implementation.
static void ConstructPath(const v8::FunctionCallbackInfo<v8::Value>& args);
// Add the Path JS constructor to the global context.
// Add the Path2D JS constructor to the global context.
static void AddToGlobal(Global* global);
// Path JS methods.
// Path2D JS methods.
static void ClosePath(const v8::FunctionCallbackInfo<v8::Value>& args);
static void MoveTo(const v8::FunctionCallbackInfo<v8::Value>& args);
static void LineTo(const v8::FunctionCallbackInfo<v8::Value>& args);
@ -44,7 +44,7 @@ public:
private:
SkPath fSkPath;
static Path* Unwrap(const v8::FunctionCallbackInfo<v8::Value>& args);
static Path2D* Unwrap(const v8::FunctionCallbackInfo<v8::Value>& args);
static Global* gGlobal;
};

View File

@ -13,7 +13,7 @@ using namespace v8;
#include "SkV8Example.h"
#include "Global.h"
#include "JsContext.h"
#include "Path.h"
#include "Path2D.h"
#include "gl/GrGLUtil.h"
#include "gl/GrGLDefines.h"
@ -204,7 +204,7 @@ SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) {
printf("Could not load file: %s.\n", FLAGS_infile[0]);
exit(1);
}
Path::AddToGlobal(global);
Path2D::AddToGlobal(global);
if (!global->parseScript(script)) {
printf("Failed to parse file: %s.\n", FLAGS_infile[0]);

View File

@ -1,5 +1,5 @@
var IS_SKV8 = typeof document == "undefined";
var HAS_PATH = typeof Path != "undefined";
var HAS_PATH = typeof Path2D != "undefined";
var NumTeeth = 24;
var NumGears = 60;
@ -23,7 +23,7 @@ function makeGear(pathLike, r) {
function gearPath(r) {
if (HAS_PATH) {
p = new Path();
p = new Path2D();
makeGear(p, r)
p.closePath();
return p;

View File

@ -2,7 +2,7 @@
* @fileoverview Sample onDraw script for use with SkV8Example.
*/
var onDraw = function(){
var p = new Path();
var p = new Path2D();
p.moveTo(0, 0);
p.bezierCurveTo(0, 100, 100, 0, 200, 200);
p.close();

View File

@ -1,9 +1,9 @@
var IS_SKV8 = typeof document == "undefined";
var HAS_PATH = typeof Path != "undefined";
var HAS_PATH = typeof Path2D != "undefined";
function circlePath(r) {
if (HAS_PATH) {
var p = new Path();
var p = new Path2D();
p.arc(0, 0, r, 0, 2*Math.PI);
p.closePath();
return p;

View File

@ -14,8 +14,8 @@
'../experimental/SkV8Example/SkV8Example.h',
'../experimental/SkV8Example/Global.cpp',
'../experimental/SkV8Example/Global.h',
'../experimental/SkV8Example/Path.cpp',
'../experimental/SkV8Example/Path.h',
'../experimental/SkV8Example/Path2D.cpp',
'../experimental/SkV8Example/Path2D.h',
'../experimental/SkV8Example/JsContext.cpp',
'../experimental/SkV8Example/JsContext.h',
],