Title: [285333] trunk/Source/WebCore
Revision
285333
Author
[email protected]
Date
2021-11-04 21:06:12 -0700 (Thu, 04 Nov 2021)

Log Message

Avoid sending video data to Web process for canvas.drawImage(video)
https://bugs.webkit.org/show_bug.cgi?id=230766
<rdar://problem/83576009>

Reviewed by Simon Fraser.

Using nativeImageForCurrentTime() to get the image to paint on to the
canvas results in a ShareableBitmap being created to send to the
Web process, the identifier for which we then send back to the GPU
process for the drawImage() call. But if we use
paintCurrentFrameInContext(), this uses the PaintFrameForMedia
message, which just sends the MediaPlayer ID and avoids the bitmap
creation.

* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::drawImage):
* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::isRemote const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285332 => 285333)


--- trunk/Source/WebCore/ChangeLog	2021-11-05 03:40:04 UTC (rev 285332)
+++ trunk/Source/WebCore/ChangeLog	2021-11-05 04:06:12 UTC (rev 285333)
@@ -1,5 +1,26 @@
 2021-11-04  Cameron McCormack  <[email protected]>
 
+        Avoid sending video data to Web process for canvas.drawImage(video)
+        https://bugs.webkit.org/show_bug.cgi?id=230766
+        <rdar://problem/83576009>
+
+        Reviewed by Simon Fraser.
+
+        Using nativeImageForCurrentTime() to get the image to paint on to the
+        canvas results in a ShareableBitmap being created to send to the
+        Web process, the identifier for which we then send back to the GPU
+        process for the drawImage() call. But if we use
+        paintCurrentFrameInContext(), this uses the PaintFrameForMedia
+        message, which just sends the MediaPlayer ID and avoids the bitmap
+        creation.
+
+        * html/canvas/CanvasRenderingContext2DBase.cpp:
+        (WebCore::CanvasRenderingContext2DBase::drawImage):
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::isRemote const):
+
+2021-11-04  Cameron McCormack  <[email protected]>
+
         Nested run loops under MediaPlayerPrivateAVFoundationObjC::waitForVideoOutputMediaDataWillChange can cause hang when timeout fires
         https://bugs.webkit.org/show_bug.cgi?id=232695
         <rdar://problem/85004449>

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (285332 => 285333)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-11-05 03:40:04 UTC (rev 285332)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp	2021-11-05 04:06:12 UTC (rev 285333)
@@ -1677,17 +1677,19 @@
     checkOrigin(&video);
 
 #if USE(CG)
-    if (auto image = video.nativeImageForCurrentTime()) {
-        c->drawNativeImage(*image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect);
+    if (c->hasPlatformContext()) {
+        if (auto image = video.nativeImageForCurrentTime()) {
+            c->drawNativeImage(*image, FloatSize(video.videoWidth(), video.videoHeight()), dstRect, srcRect);
 
-        if (isEntireBackingStoreDirty())
-            didDraw(std::nullopt);
-        else if (rectContainsCanvas(dstRect))
-            didDrawEntireCanvas();
-        else
-            didDraw(dstRect);
+            if (isEntireBackingStoreDirty())
+                didDraw(std::nullopt);
+            else if (rectContainsCanvas(dstRect))
+                didDrawEntireCanvas();
+            else
+                didDraw(dstRect);
 
-        return { };
+            return { };
+        }
     }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to