Source/WebCore/ChangeLog

 12020-07-22 Justin Fan <justin_fan@apple.com>
 2
 3 [WebGL] Safari snapshots of WebGL content in the tab picker don't work
 4 https://bugs.webkit.org/show_bug.cgi?id=214452
 5 <rdar://problem/21243082>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 No new tests; writing a test may involve adding a new feature to TestRunner to trigger this path.
 10
 11 * html/HTMLCanvasElement.cpp:
 12 (WebCore::HTMLCanvasElement::paint): Will properly request a paint when a snapshot is requested.
 13 * html/HTMLCanvasElement.h:
 14 * html/canvas/WebGLRenderingContextBase.cpp:
 15 (WebCore::WebGLRenderingContextBase::paintRenderingResultsToCanvas): Only clear the last snapshot if readPixels will succeed.
 16 * rendering/RenderHTMLCanvas.cpp:
 17 (WebCore::RenderHTMLCanvas::paintReplaced):
 18
1192020-07-22 Fujii Hironori <Hironori.Fujii@sony.com>
220
321 [WinCairo][32bit] JPEG2000ImageDecoder.cpp: error C2664: 'std::unique_ptr<...>::unique_ptr(...)': cannot convert argument 2 from 'void (__stdcall *)(opj_codec_t *)' to 'const _Dx &'

Source/WebCore/html/HTMLCanvasElement.cpp

@@void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r)
635635 bool shouldPaint = true;
636636
637637 if (m_context) {
638  shouldPaint = paintsIntoCanvasBuffer() || document().printing();
 638 shouldPaint = paintsIntoCanvasBuffer() || document().printing() || m_isSnapshotting;
639639 if (shouldPaint)
640640 m_context->paintRenderingResultsToCanvas();
641641 }

Source/WebCore/html/HTMLCanvasElement.h

@@public:
132132 bool needsPreparationForDisplay();
133133 void prepareForDisplay();
134134
 135 void setIsSnapshotting(bool isSnapshotting) { m_isSnapshotting = isSnapshotting; }
 136 bool isSnapshotting() const { return m_isSnapshotting; }
 137
135138private:
136139 HTMLCanvasElement(const QualifiedName&, Document&);
137140

@@private:
188191 bool m_hasRelevantWebGLEventListener { false };
189192#endif
190193
 194 bool m_isSnapshotting { false };
 195
191196 mutable RefPtr<Image> m_presentedImage;
192197 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platforms that have to copy the image buffer to render (and for CSSCanvasValue).
193198};

Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

@@void WebGLRenderingContextBase::paintRenderingResultsToCanvas()
11881188 if (!canvas)
11891189 return;
11901190
1191  if (canvas->document().printing())
 1191 if (canvas->document().printing() || (canvas->isSnapshotting() && canvas->document().page()->isVisible()))
11921192 canvas->clearPresentationCopy();
11931193
11941194 // Until the canvas is written to by the application, the clear that
11951195 // happened after it was composited should be ignored by the compositor.
11961196 if (m_context->layerComposited() && !m_attributes.preserveDrawingBuffer) {
1197  m_context->paintCompositedResultsToCanvas(canvas->buffer());
 1197 m_context->paintRenderingResultsToCanvas(canvas->buffer());
11981198
11991199 canvas->makePresentationCopy();
12001200 } else

Source/WebCore/rendering/RenderHTMLCanvas.cpp

@@void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& pa
9292 page().addRelevantRepaintedObject(this, intersection(replacedContentRect, contentBoxRect));
9393
9494 InterpolationQualityMaintainer interpolationMaintainer(context, ImageQualityController::interpolationQualityFromStyle(style()));
 95
 96 canvasElement().setIsSnapshotting(paintInfo.paintBehavior.contains(PaintBehavior::Snapshotting));
9597 canvasElement().paint(context, replacedContentRect);
 98 canvasElement().setIsSnapshotting(false);
9699}
97100
98101void RenderHTMLCanvas::canvasSizeChanged()