Commit 317df9c1 authored by leviw@chromium.org's avatar leviw@chromium.org

Revert of 2D canvas: remain in deferred rendering mode with canvas to canvas...

Revert of 2D canvas: remain in deferred rendering mode with canvas to canvas drawImage (patchset #2 id:20001 of https://codereview.chromium.org/1288773005/ )

Reason for revert:
Appears to be triggering MSAN crashes: http://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=virtual%2Fdisplay_list_2d_canvas%2Ffast%2Fcanvas%2F2d.composite.globalAlpha.fillPath.html&testType=layout-tests

Original issue's description:
> 2D canvas: remain in deferred rendering mode with canvas to canvas drawImage
> 
> If the source canvas is not animated, no need to exit deferred rendering
> because there is no risk of memory bloat due to snapshotting.
> 
> BUG=521001
> TEST=telemetry tough_canvas_cases
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=200654

TBR=senorblanco@chromium.org,junov@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=521001

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

git-svn-id: svn://svn.chromium.org/blink/trunk@200660 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent feb7f367
......@@ -434,11 +434,6 @@ bool HTMLCanvasElement::is3D() const
return m_context && m_context->is3d();
}
bool HTMLCanvasElement::isAnimated2D() const
{
return m_context && m_context->is2d() && hasImageBuffer() && m_imageBuffer->wasDrawnToAfterSnapshot();
}
void HTMLCanvasElement::setSurfaceSize(const IntSize& size)
{
m_size = size;
......
......@@ -138,7 +138,6 @@ public:
AffineTransform baseTransform() const;
bool is3D() const;
bool isAnimated2D() const;
bool hasImageBuffer() const { return m_imageBuffer; }
void discardImageBuffer();
......
......@@ -1353,20 +1353,6 @@ void CanvasRenderingContext2D::drawImageInternal(SkCanvas* c, CanvasImageSource*
c->restoreToCount(initialSaveCount);
}
bool shouldDisableDeferral(CanvasImageSource* imageSource)
{
if (imageSource->isVideoElement())
return true;
if (imageSource->isCanvasElement()) {
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(imageSource);
if (canvas->is3D())
return true;
if (canvas->isAnimated2D())
return true;
}
return false;
}
void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource,
float sx, float sy, float sw, float sh,
float dx, float dy, float dw, float dh, ExceptionState& exceptionState)
......@@ -1402,7 +1388,12 @@ void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource,
if (srcRect.isEmpty())
return;
if (shouldDisableDeferral(imageSource))
// FIXME: crbug.com/521001
// We make the destination canvas fall out of display list mode by forcing
// immediate rendering. This is to prevent run-away memory consumption caused by SkSurface
// copyOnWrite when the source canvas is animated and consumed at a rate higher than the
// presentation frame rate of the destination canvas.
if (imageSource->isVideoElement() || imageSource->isCanvasElement())
canvas()->disableDeferral();
validateStateStack();
......
......@@ -149,9 +149,6 @@ void ImageBuffer::resetCanvas(SkCanvas* canvas) const
PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const
{
if (m_snapshotState == InitialSnapshotState)
m_snapshotState = DidAcquireSnapshot;
if (!isSurfaceValid())
return nullptr;
return m_surface->newImageSnapshot();
......@@ -159,19 +156,14 @@ PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const
PassRefPtr<Image> ImageBuffer::newImageSnapshot() const
{
RefPtr<SkImage> snapshot = newSkImageSnapshot();
if (!isSurfaceValid())
return nullptr;
RefPtr<SkImage> snapshot = m_surface->newImageSnapshot();
if (!snapshot)
return nullptr;
return StaticBitmapImage::create(snapshot);
}
void ImageBuffer::didDraw(const FloatRect& rect) const
{
if (m_snapshotState == DidAcquireSnapshot)
m_snapshotState = DrawnToAfterSnapshot;
m_surface->didDraw(rect);
}
WebLayer* ImageBuffer::platformLayer() const
{
return m_surface->layer();
......
......@@ -82,8 +82,7 @@ public:
bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); }
bool isSurfaceValid() const;
bool restoreSurface() const;
void didDraw(const FloatRect&) const;
bool wasDrawnToAfterSnapshot() const { return m_snapshotState == DrawnToAfterSnapshot; }
void didDraw(const FloatRect& rect) const { m_surface->didDraw(rect); }
void setFilterQuality(SkFilterQuality filterQuality) { m_surface->setFilterQuality(filterQuality); }
void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); }
......@@ -139,12 +138,6 @@ public:
private:
ImageBuffer(PassOwnPtr<ImageBufferSurface>);
enum SnapshotState {
InitialSnapshotState,
DidAcquireSnapshot,
DrawnToAfterSnapshot,
};
mutable SnapshotState m_snapshotState;
OwnPtr<ImageBufferSurface> m_surface;
ImageBufferClient* m_client;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment