diff options
| author | xlai <xlai@chromium.org> | 2016-03-22 09:36:50 -0700 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-22 16:38:14 +0000 |
| commit | 743ca082b662386b4df43a5dc556f9a1be701785 (patch) | |
| tree | 0cb3338517a2f6511156c0833056a67fed4866da | |
| parent | 07b3e034d356a9d3629a82041473d6db785a507d (diff) | |
| download | chromium_src-743ca082b662386b4df43a5dc556f9a1be701785.zip chromium_src-743ca082b662386b4df43a5dc556f9a1be701785.tar.gz chromium_src-743ca082b662386b4df43a5dc556f9a1be701785.tar.bz2 | |
Implemented/Tested line-drawing functions in OffscreenCanvas 2D Context
The new Web APIs that are implemented are:
* OffscreenCanvasRendering2D.beginPath()
* OffscreenCanvasRendering2D.fill(optional CanvasFillRule)
* OffscreenCanvasRendering2D.fill(Path2D, optional CanvasFillRule)
* OffscreenCanvasRendering2D.stroke()
* OffscreenCanvasRendering2D.stroke(Path2D)
* OffscreenCanvasRendering2D.lineWidth
* OffscreenCanvasRendering2D.lineCap
* OffscreenCanvasRendering2D.lineJoin
* OffscreenCanvasRendering2D.miterLimit
* OffscreenCanvasRendering2D.setLineDash(array);
* OffscreenCanvasRendering2D.getLineDash
* OffscreenCanvasRendering2D.lineDashOffset
A subset of existing Web APIs shared with non-Offscreen
canvas from CanvasPathMethods are also tested, including:
arc, lineTo, bezierCurveTo, moveTo, closePath.
BUG=563856
Review URL: https://codereview.chromium.org/1806943005
Cr-Commit-Position: refs/heads/master@{#382584}
12 files changed, 211 insertions, 2 deletions
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index 5e171c2..af9a285 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations @@ -116,6 +116,7 @@ crbug.com/539226 [ Win ] http/tests/xmlhttprequest/open-in-body-onload-sync-to-i # Expected to fail until OffscreenCanvas can render on the gpu crbug.com/593514 virtual/gpu/fast/canvas/OffscreenCanvas-strokeRect-in-worker.html [ Failure ] +crbug.com/593514 virtual/gpu/fast/canvas/OffscreenCanvas-paths-in-worker.html [ Failure ] crbug.com/417782 [ Linux Win ] virtual/rootlayerscrolls/fast/scrolling/fractional-scroll-offset-fixed-position-non-composited.html [ Failure ] crbug.com/492664 [ Linux ] imported/csswg-test/css-writing-modes-3/box-offsets-rel-pos-vlr-005.xht [ Failure ] diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker-expected.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker-expected.html new file mode 100644 index 0000000..a390f04 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker-expected.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> +<body> +<canvas id ='output' width='200' height='400'></canvas> +<script> +var aCanvas = document.getElementById('output'); +var ctx = aCanvas.getContext('2d'); +ctx.beginPath(); +ctx.lineWidth = '10'; +ctx.strokeStyle = 'green'; +ctx.lineJoin = 'round'; +ctx.moveTo(15, 15); +ctx.lineTo(135, 15); +ctx.lineTo(70, 170); +ctx.closePath(); +ctx.stroke(); + +var path1 = new Path2D(); +path1.moveTo(150, 25); +path1.bezierCurveTo(10, 150, 10, 300, 100, 200); +ctx.strokeStyle = 'purple'; +ctx.setLineDash([ 10, 5 ]); +ctx.stroke(path1); + +ctx.fillStyle = 'red'; +ctx.beginPath() +ctx.arc(75, 325, 50, 0, Math.PI * 2, true); +ctx.arc(75, 325, 20, 0, Math.PI * 2, true); +ctx.fill("evenodd"); +</script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker.html b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker.html new file mode 100644 index 0000000..e508669 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-paths-in-worker.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<html> +<body> +<canvas id='output' width='200' height='400'></canvas> +<script id='myWorker' type='text/worker'> +self.onmessage = function(e) { + var aCanvas = new OffscreenCanvas(200, 400); + var ctx = aCanvas.getContext('2d'); + + ctx.beginPath(); + ctx.lineWidth = '10'; + ctx.strokeStyle = 'green'; + ctx.lineJoin = 'round'; + ctx.moveTo(15, 15); + ctx.lineTo(135, 15); + ctx.lineTo(70, 170); + ctx.closePath(); + ctx.stroke(); + + var path1 = new Path2D(); + path1.moveTo(150, 25); + path1.bezierCurveTo(10, 150, 10, 300, 100, 200); + ctx.strokeStyle = 'purple'; + ctx.setLineDash([ 10, 5 ]); + ctx.stroke(path1); + + ctx.fillStyle = 'red'; + ctx.beginPath() + ctx.arc(75, 325, 50, 0, Math.PI * 2, true); + ctx.arc(75, 325, 20, 0, Math.PI * 2, true); + ctx.fill("evenodd"); + + var image = aCanvas.transferToImageBitmap(); + self.postMessage(image, [image]); +}; +</script> +<script> +if (window.testRunner) { + testRunner.waitUntilDone(); +} +var blob = new Blob([document.getElementById('myWorker').textContent]); +var worker = new Worker(URL.createObjectURL(blob)); +worker.addEventListener('message', msg => { + var outputCtx = document.getElementById('output').getContext('imagebitmap'); + outputCtx.transferImageBitmap(msg.data); + if (window.testRunner) { + testRunner.notifyDone(); + } +}); +worker.postMessage(""); +</script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt index ad186d6..811fd1b 100644 --- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt @@ -484,23 +484,50 @@ interface OffscreenCanvas setter width interface OffscreenCanvasRenderingContext2D getter fillStyle + getter lineCap + getter lineDashOffset + getter lineJoin + getter lineWidth + getter miterLimit getter offscreenCanvas getter strokeStyle method arc method arcTo + method beginPath method bezierCurveTo method clearRect method closePath method constructor method ellipse + method fill method fillRect + method getLineDash method lineTo method moveTo method quadraticCurveTo method rect + method setLineDash + method stroke method strokeRect setter fillStyle + setter lineCap + setter lineDashOffset + setter lineJoin + setter lineWidth + setter miterLimit setter strokeStyle +interface Path2D + method addPath + method arc + method arcTo + method bezierCurveTo + method closePath + method constructor + method ellipse + method lineTo + method moveTo + method quadraticCurveTo + method rect interface PerformanceObserverEntryList method constructor method getEntries diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt index b574145..62a012c 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-dedicated-worker-expected.txt @@ -503,23 +503,51 @@ Starting worker: resources/global-interface-listing.js [Worker] interface OffscreenCanvasRenderingContext2D [Worker] attribute @@toStringTag [Worker] getter fillStyle +[Worker] getter lineCap +[Worker] getter lineDashOffset +[Worker] getter lineJoin +[Worker] getter lineWidth +[Worker] getter miterLimit [Worker] getter offscreenCanvas [Worker] getter strokeStyle [Worker] method arc [Worker] method arcTo +[Worker] method beginPath [Worker] method bezierCurveTo [Worker] method clearRect [Worker] method closePath [Worker] method constructor [Worker] method ellipse +[Worker] method fill [Worker] method fillRect +[Worker] method getLineDash [Worker] method lineTo [Worker] method moveTo [Worker] method quadraticCurveTo [Worker] method rect +[Worker] method setLineDash +[Worker] method stroke [Worker] method strokeRect [Worker] setter fillStyle +[Worker] setter lineCap +[Worker] setter lineDashOffset +[Worker] setter lineJoin +[Worker] setter lineWidth +[Worker] setter miterLimit [Worker] setter strokeStyle +[Worker] interface Path2D +[Worker] attribute @@toStringTag +[Worker] method addPath +[Worker] method arc +[Worker] method arcTo +[Worker] method bezierCurveTo +[Worker] method closePath +[Worker] method constructor +[Worker] method ellipse +[Worker] method lineTo +[Worker] method moveTo +[Worker] method quadraticCurveTo +[Worker] method rect [Worker] interface PerformanceObserverEntryList [Worker] attribute @@toStringTag [Worker] method constructor diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt index 83d315f..e3e1459 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt @@ -4004,22 +4004,37 @@ interface OffscreenCanvas interface OffscreenCanvasRenderingContext2D attribute @@toStringTag getter fillStyle + getter lineCap + getter lineDashOffset + getter lineJoin + getter lineWidth + getter miterLimit getter offscreenCanvas getter strokeStyle method arc method arcTo + method beginPath method bezierCurveTo method clearRect method closePath method constructor method ellipse + method fill method fillRect + method getLineDash method lineTo method moveTo method quadraticCurveTo method rect + method setLineDash + method stroke method strokeRect setter fillStyle + setter lineCap + setter lineDashOffset + setter lineJoin + setter lineWidth + setter miterLimit setter strokeStyle interface Option method constructor diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt index 0a3d6c7..0d50a1f 100644 --- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt +++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-shared-worker-expected.txt @@ -490,23 +490,51 @@ Starting worker: resources/global-interface-listing.js [Worker] interface OffscreenCanvasRenderingContext2D [Worker] attribute @@toStringTag [Worker] getter fillStyle +[Worker] getter lineCap +[Worker] getter lineDashOffset +[Worker] getter lineJoin +[Worker] getter lineWidth +[Worker] getter miterLimit [Worker] getter offscreenCanvas [Worker] getter strokeStyle [Worker] method arc [Worker] method arcTo +[Worker] method beginPath [Worker] method bezierCurveTo [Worker] method clearRect [Worker] method closePath [Worker] method constructor [Worker] method ellipse +[Worker] method fill [Worker] method fillRect +[Worker] method getLineDash [Worker] method lineTo [Worker] method moveTo [Worker] method quadraticCurveTo [Worker] method rect +[Worker] method setLineDash +[Worker] method stroke [Worker] method strokeRect [Worker] setter fillStyle +[Worker] setter lineCap +[Worker] setter lineDashOffset +[Worker] setter lineJoin +[Worker] setter lineWidth +[Worker] setter miterLimit [Worker] setter strokeStyle +[Worker] interface Path2D +[Worker] attribute @@toStringTag +[Worker] method addPath +[Worker] method arc +[Worker] method arcTo +[Worker] method bezierCurveTo +[Worker] method closePath +[Worker] method constructor +[Worker] method ellipse +[Worker] method lineTo +[Worker] method moveTo +[Worker] method quadraticCurveTo +[Worker] method rect [Worker] interface PerformanceObserverEntryList [Worker] attribute @@toStringTag [Worker] method constructor diff --git a/third_party/WebKit/Source/modules/canvas2d/Path2D.idl b/third_party/WebKit/Source/modules/canvas2d/Path2D.idl index 8f8a2a1..909b880 100644 --- a/third_party/WebKit/Source/modules/canvas2d/Path2D.idl +++ b/third_party/WebKit/Source/modules/canvas2d/Path2D.idl @@ -33,6 +33,7 @@ Constructor(Path2D path), Constructor(DOMString text), GarbageCollected, + Exposed(Worker ExperimentalCanvasFeatures, Window StableBlinkFeatures), ] interface Path2D { [RuntimeEnabled=ExperimentalCanvasFeatures] void addPath(Path2D path, optional SVGMatrix? transform); diff --git a/third_party/WebKit/Source/modules/offscreencanvas/OWNERS b/third_party/WebKit/Source/modules/offscreencanvas/OWNERS index 28fb2d0..b930c97 100644 --- a/third_party/WebKit/Source/modules/offscreencanvas/OWNERS +++ b/third_party/WebKit/Source/modules/offscreencanvas/OWNERS @@ -1 +1,2 @@ junov@chromium.org +xlai@chromium.org diff --git a/third_party/WebKit/Source/modules/offscreencanvas2d/OWNERS b/third_party/WebKit/Source/modules/offscreencanvas2d/OWNERS index 28fb2d0..b930c97 100644 --- a/third_party/WebKit/Source/modules/offscreencanvas2d/OWNERS +++ b/third_party/WebKit/Source/modules/offscreencanvas2d/OWNERS @@ -1 +1,2 @@ junov@chromium.org +xlai@chromium.org diff --git a/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl b/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl index 29a3d06..0c95f53 100644 --- a/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl +++ b/third_party/WebKit/Source/modules/offscreencanvas2d/OffscreenCanvasRenderingContext2D.idl @@ -12,14 +12,32 @@ // back-reference to the canvas [ImplementedAs=getOffscreenCanvas] readonly attribute OffscreenCanvas offscreenCanvas; - // colors and styles (see also the CanvasDrawingStyles interface) + // colors and styles attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black) attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black) - //CanvasRect interface + // CanvasRect interface void clearRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height); void fillRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height); void strokeRect(unrestricted double x, unrestricted double y, unrestricted double width, unrestricted double height); + + // Path API (See BaseRenderingContext2D) + void beginPath(); + void fill(optional CanvasFillRule winding); + void fill(Path2D path, optional CanvasFillRule winding); + void stroke(); + void stroke(Path2D path); + + // Line caps/joins + attribute unrestricted double lineWidth; // (default 1) + attribute DOMString lineCap; // "butt", "round", "square" (default "butt") + attribute DOMString lineJoin; // "round", "bevel", "miter" (default "miter") + attribute unrestricted double miterLimit; // (default 10) + + // dashed lines + void setLineDash(sequence<unrestricted double> dash); + sequence<unrestricted double> getLineDash(); + attribute unrestricted double lineDashOffset; }; OffscreenCanvasRenderingContext2D implements CanvasPathMethods; diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index b12c39f..ee44457 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in @@ -184,6 +184,10 @@ SlimmingPaintInvalidation SlimmingPaintV2 SlimmingPaintStrictCullRectClipping SlimmingPaintUnderInvalidationChecking +// Used as argument in attribute of stable-release functions/interfaces where +// a runtime-enabled feature name is required for correct IDL syntax. +// This is a global flag; do not change its status. +StableBlinkFeatures status=stable StackedCSSPropertyAnimations status=experimental StyleSharing status=stable StyleMatchedPropertiesCache status=stable |
