Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| index e04ea2b304f96f0bc3e3c80e013ff43918bbac47..08952acdae436450bb6d318ce56846109d988cbe 100644 |
| --- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| +++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
| @@ -283,6 +283,8 @@ void HTMLCanvasElement::didDraw(const FloatRect& rect) |
| void HTMLCanvasElement::didFinalizeFrame() |
| { |
| + notifyListenersCanvasChanged(); |
| + |
| if (m_dirtyRect.isEmpty()) |
| return; |
| @@ -393,13 +395,30 @@ bool HTMLCanvasElement::paintsIntoCanvasBuffer() const |
| if (!m_context->isAccelerated()) |
| return true; |
| - |
| if (layoutBox() && layoutBox()->hasAcceleratedCompositing()) |
| return false; |
| return true; |
| } |
| +void HTMLCanvasElement::notifyListenersCanvasChanged() |
| +{ |
| + if (!originClean()) { |
| + m_listeners.clear(); |
| + return; |
| + } |
| + |
| + for (CanvasDrawListener* listener : m_listeners) { |
| + if (listener->needsNewFrameCapture()) { |
| + SourceImageStatus status; |
| + RefPtr<Image> sourceImage = getSourceImageForCanvas(&status, PreferNoAcceleration); |
|
esprehn
2015/12/01 20:04:26
getSourceImageForCanvas is expensive I think it se
emircan
2015/12/01 21:07:34
Done. My bad, I was initially designing it with a
|
| + if (status != NormalSourceImageStatus) |
| + return; |
| + listener->setNewFrameCapture(sourceImage->imageForCurrentFrame()); |
| + } |
| + } |
| +} |
| + |
| void HTMLCanvasElement::paint(GraphicsContext* context, const LayoutRect& r) |
| { |
| // FIXME: crbug.com/438240; there is a bug with the new CSS blending and compositing feature. |
| @@ -568,6 +587,17 @@ void HTMLCanvasElement::toBlob(FileCallback* callback, const String& mimeType, c |
| } |
| } |
| +void HTMLCanvasElement::addListener(CanvasDrawListener* listener) |
| +{ |
| + m_listeners.add(listener); |
| + notifyListenersCanvasChanged(); |
|
esprehn
2015/12/01 20:04:26
hmm, this means we do a sync readback the first ti
emircan
2015/12/01 21:07:34
I see that frame might not be completed. I was try
|
| +} |
| + |
| +void HTMLCanvasElement::removeListener(CanvasDrawListener* listener) |
| +{ |
| + m_listeners.remove(listener); |
| +} |
| + |
| SecurityOrigin* HTMLCanvasElement::securityOrigin() const |
| { |
| return document().securityOrigin(); |
| @@ -743,6 +773,7 @@ void HTMLCanvasElement::notifySurfaceInvalid() |
| DEFINE_TRACE(HTMLCanvasElement) |
| { |
| + visitor->trace(m_listeners); |
| visitor->trace(m_context); |
| DocumentVisibilityObserver::trace(visitor); |
| HTMLElement::trace(visitor); |