WebGPU: Backend - hosting WebGPU layers
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Mar 2017 07:18:33 +0000 (07:18 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Mar 2017 07:18:33 +0000 (07:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169366
<rdar://problem/30928735>

Reviewed by Dean Jackson.

* html/canvas/WebGPURenderingContext.cpp:
(WebCore::WebGPURenderingContext::create): Create the device and the
rendering context.
* platform/graphics/cocoa/GPUCommandBufferMetal.mm:
(WebCore::GPUCommandBuffer::commit):
* platform/graphics/cocoa/GPUDrawableMetal.mm:
(WebCore::GPUDrawable::release): Fix a log message
* platform/graphics/gpu/GPUCommandBuffer.cpp:
(WebCore::GPUCommandBuffer::commit): Deleted. Moved to GPUCommandBufferMetal.
* rendering/RenderLayerBacking.cpp:
(WebCore::canvasCompositingStrategy): WebGPU canvas should return CanvasAsLayerContents.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213783 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGPURenderingContext.cpp
Source/WebCore/platform/graphics/cocoa/GPUCommandBufferMetal.mm
Source/WebCore/platform/graphics/cocoa/GPUDrawableMetal.mm
Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp

index c46fc48..854ad4e 100644 (file)
@@ -1,3 +1,23 @@
+2017-03-13  Jon Lee  <jonlee@apple.com>
+
+        WebGPU: Backend - hosting WebGPU layers
+        https://bugs.webkit.org/show_bug.cgi?id=169366
+        <rdar://problem/30928735>
+
+        Reviewed by Dean Jackson.
+
+        * html/canvas/WebGPURenderingContext.cpp:
+        (WebCore::WebGPURenderingContext::create): Create the device and the
+        rendering context.
+        * platform/graphics/cocoa/GPUCommandBufferMetal.mm:
+        (WebCore::GPUCommandBuffer::commit):
+        * platform/graphics/cocoa/GPUDrawableMetal.mm:
+        (WebCore::GPUDrawable::release): Fix a log message
+        * platform/graphics/gpu/GPUCommandBuffer.cpp:
+        (WebCore::GPUCommandBuffer::commit): Deleted. Moved to GPUCommandBufferMetal.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::canvasCompositingStrategy): WebGPU canvas should return CanvasAsLayerContents.
+
 2017-03-12  Jon Lee  <jonlee@apple.com>
 
         Remove stubs from WebGPU front end
index d50ccf4..8d24c77 100644 (file)
@@ -71,23 +71,7 @@ static const int kMaxTextureSize = 4096;
 
 std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(HTMLCanvasElement& canvas)
 {
-    UNUSED_PARAM(canvas);
-/* FIXME: WebGPU - To be implemented.
-    Document& document = canvas.document();
-    Frame* frame = document.frame();
-    if (!frame)
-        return nullptr;
-
-    GPUDevice::Attributes attributes;
-
-    attributes.antialias = false;
-
-    // FIXME: WebGPU - handle retina.
-    // if (page)
-    //     attributes.devicePixelRatio = page->deviceScaleFactor();
-
-    HostWindow* hostWindow = document.view()->root()->hostWindow();
-    RefPtr<GPUDevice> device(GPUDevice::create(attributes, hostWindow));
+    RefPtr<GPUDevice> device(GPUDevice::create());
 
     if (!device) {
         // FIXME: WebGPU - dispatch an event here for the failure.
@@ -99,8 +83,6 @@ std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(HTMLCanva
     renderingContext->suspendIfNeeded();
 
     return renderingContext;
-*/
-    return nullptr;
 }
 
 WebGPURenderingContext::WebGPURenderingContext(HTMLCanvasElement& canvas, PassRefPtr<GPUDevice> device)
index 219f2e0..f1ea592 100644 (file)
@@ -61,6 +61,14 @@ void GPUCommandBuffer::presentDrawable(GPUDrawable* drawable)
     drawable->release();
 }
 
+void GPUCommandBuffer::commit()
+{
+    if (!m_commandBuffer)
+        return;
+
+    [m_commandBuffer commit];
+}
+
 } // namespace WebCore
 
 #endif
index 75494b6..425e59f 100644 (file)
@@ -48,7 +48,7 @@ GPUDrawable::GPUDrawable(GPUDevice* device)
 
 void GPUDrawable::release()
 {
-    LOG(WebGPU, "MetalDrawable::release()");
+    LOG(WebGPU, "GPUDrawable::release()");
     m_drawable = nullptr;
 }
     
index 3a0adc3..ebd8e7d 100644 (file)
@@ -47,10 +47,6 @@ GPUCommandBuffer::~GPUCommandBuffer()
     LOG(WebGPU, "GPUCommandBuffer::~GPUCommandBuffer()");
 }
 
-void GPUCommandBuffer::commit()
-{
-}
-
 RefPtr<GPURenderCommandEncoder> GPUCommandBuffer::createRenderCommandEncoder(GPURenderPassDescriptor* descriptor)
 {
     return GPURenderCommandEncoder::create(this, descriptor);
index fdb5c28..46c9ecd 100644 (file)
@@ -84,6 +84,11 @@ CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject& renderer
     if (context->is3d())
         return CanvasAsLayerContents;
 
+#if ENABLE(WEBGPU)
+    if (context->isGPU())
+        return CanvasAsLayerContents;
+#endif
+
 #if ENABLE(ACCELERATED_2D_CANVAS)
     return CanvasAsLayerContents;
 #else