Start prototyping what DisplayList support will look like.
None of the new codepaths get executed yet since DisplayList doesn't exist, but that will happening in the new few CLs. BUG=skia: R=robertphillips@google.com Author: jcgregorio@google.com Review URL: https://codereview.chromium.org/183883017 git-svn-id: http://skia.googlecode.com/svn/trunk@13657 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
e09244d463
commit
cb336874e4
@ -1,5 +1,6 @@
|
|||||||
var IS_SKV8 = typeof document == "undefined";
|
var IS_SKV8 = typeof document == "undefined";
|
||||||
var HAS_PATH = typeof Path2D != "undefined";
|
var HAS_PATH = typeof Path2D != "undefined";
|
||||||
|
var HAS_DISPLAY_LIST = typeof DisplayList != "undefined";
|
||||||
|
|
||||||
var NumTeeth = 24;
|
var NumTeeth = 24;
|
||||||
var NumGears = 60;
|
var NumGears = 60;
|
||||||
@ -32,6 +33,36 @@ function gearPath(r) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gearDisplayListStroke(r, color) {
|
||||||
|
if (HAS_DISPLAY_LIST) {
|
||||||
|
p = new Path2D();
|
||||||
|
makeGear(p, r)
|
||||||
|
p.closePath();
|
||||||
|
var dl = new DisplayList();
|
||||||
|
dl.strokeStyle = color;
|
||||||
|
dl.stroke(p);
|
||||||
|
dl.finalize()
|
||||||
|
return dl;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function gearDisplayListFill(r, color) {
|
||||||
|
if (HAS_DISPLAY_LIST) {
|
||||||
|
p = new Path2D();
|
||||||
|
makeGear(p, r)
|
||||||
|
p.closePath();
|
||||||
|
var dl = new DisplayList();
|
||||||
|
dl.fillStyle = color;
|
||||||
|
dl.fill(p);
|
||||||
|
dl.finalize()
|
||||||
|
return dl;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function strokeGear(ctx, gear) {
|
function strokeGear(ctx, gear) {
|
||||||
if (HAS_PATH) {
|
if (HAS_PATH) {
|
||||||
ctx.stroke(gear.path);
|
ctx.stroke(gear.path);
|
||||||
@ -63,9 +94,17 @@ function draw3DGear(ctx, angle, gear) {
|
|||||||
ctx.rotate(-angle);
|
ctx.rotate(-angle);
|
||||||
ctx.translate(0.707, 0.707);
|
ctx.translate(0.707, 0.707);
|
||||||
ctx.rotate(angle);
|
ctx.rotate(angle);
|
||||||
strokeGear(ctx, gear);
|
if (HAS_DISPLAY_LIST) {
|
||||||
|
ctx.draw(gear.gearStroke);
|
||||||
|
} else {
|
||||||
|
strokeGear(ctx, gear);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (HAS_DISPLAY_LIST) {
|
||||||
|
ctx.draw(gear.gearFill);
|
||||||
|
} else {
|
||||||
|
fillGear(ctx, gear);
|
||||||
}
|
}
|
||||||
fillGear(ctx, gear);
|
|
||||||
ctx.rotate(-angle);
|
ctx.rotate(-angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +127,8 @@ var onDraw = function() {
|
|||||||
x: Math.random()*500,
|
x: Math.random()*500,
|
||||||
y: Math.random()*500,
|
y: Math.random()*500,
|
||||||
path: gearPath(r),
|
path: gearPath(r),
|
||||||
|
gearFill: gearDisplayListFill(r, FaceColors[color]),
|
||||||
|
gearStroke: gearDisplayListStroke(r, SideColors[color]),
|
||||||
r: r,
|
r: r,
|
||||||
faceColor: FaceColors[color],
|
faceColor: FaceColors[color],
|
||||||
sideColor: SideColors[color]
|
sideColor: SideColors[color]
|
||||||
|
Loading…
Reference in New Issue
Block a user