Allow canvas to use display-list drawing for testing
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 01:53:18 +0000 (01:53 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 01:53:18 +0000 (01:53 +0000)
commit7866ba7f868f578e4e74c162750f3f19c4beb842
treee3e18600338d083e9eabc72d43e94196e566b429
parent5bb860cff2a705ccc80042214c8ce36b0fd257ca
Allow canvas to use display-list drawing for testing
https://bugs.webkit.org/show_bug.cgi?id=153475

Reviewed by Dean Jackson.

Source/WebCore:

Optionally have 2D <canvas> use display-list drawing, which is only enabled
via Internals for now.

Support displayListAsText() and replayDisplayListAsText() on canvas, so we can
use it to test playback optimizations. [Note that displayListAsText() always
returns an empty string currently, because the display list is cleared when the
canvas is painted to the page.]

Display list rendering is implemented by giving CanvasRenderingContext2D an
optional DisplayListDrawingContext, which packages up a display list, recorder
and recording context. The existing paintRenderingResultsToCanvas() is overridden
to replay the recorded display list into the primary canvas context.

Tracked replay display lists are stored in a static map, keyed by the CanvasRenderingContext2D.

Test: displaylists/canvas-display-list.html

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::HTMLCanvasElement):
(WebCore::HTMLCanvasElement::getContext):
(WebCore::HTMLCanvasElement::paint):
(WebCore::HTMLCanvasElement::setUsesDisplayListDrawing):
(WebCore::HTMLCanvasElement::setTracksDisplayListReplay):
(WebCore::HTMLCanvasElement::displayListAsText):
(WebCore::HTMLCanvasElement::replayDisplayListAsText):
* html/HTMLCanvasElement.h:
* html/canvas/CanvasRenderingContext.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::DisplayListDrawingContext::DisplayListDrawingContext):
(WebCore::contextDisplayListMap):
(WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::setTracksDisplayListReplay):
(WebCore::CanvasRenderingContext2D::displayListAsText):
(WebCore::CanvasRenderingContext2D::replayDisplayListAsText):
(WebCore::CanvasRenderingContext2D::paintRenderingResultsToCanvas):
(WebCore::CanvasRenderingContext2D::drawingContext):
(WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): Deleted.
* html/canvas/CanvasRenderingContext2D.h:
* testing/Internals.cpp:
(WebCore::Internals::setElementUsesDisplayListDrawing):
(WebCore::Internals::setElementTracksDisplayListReplay):
(WebCore::Internals::displayListForElement):
(WebCore::Internals::replayDisplayListForElement):

LayoutTests:

Simple canvas-based display list test.

* displaylists/canvas-display-list-expected.txt: Added.
* displaylists/canvas-display-list.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195646 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/displaylists/canvas-display-list-expected.txt [new file with mode: 0644]
LayoutTests/displaylists/canvas-display-list.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLCanvasElement.cpp
Source/WebCore/html/HTMLCanvasElement.h
Source/WebCore/html/canvas/CanvasRenderingContext.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.h
Source/WebCore/testing/Internals.cpp