Commit dcf1fe27 authored by Brandon Jones's avatar Brandon Jones Committed by Chromium LUCI CQ

Updated signature of GPUCanvasContext.getSwapChainPreferredFormat

Changes the function to accept a GPUAdapter instead of a GPUDevice and
return a GPUTextureFormat synchronously rather than via a Promise. The
previous function signature is left in place with a deprecation warning.

Bug: 1154326
Change-Id: I0593d04933b5bf6d91c6428239fd04a32170210b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566885Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833099}
parent a1e3b5ad
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/rendering_context.h" #include "third_party/blink/renderer/bindings/modules/v8/rendering_context.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_swap_chain_descriptor.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_swap_chain_descriptor.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h" #include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_adapter.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" #include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
namespace blink { namespace blink {
...@@ -130,15 +131,26 @@ GPUSwapChain* GPUCanvasContext::configureSwapChain( ...@@ -130,15 +131,26 @@ GPUSwapChain* GPUCanvasContext::configureSwapChain(
ScriptPromise GPUCanvasContext::getSwapChainPreferredFormat( ScriptPromise GPUCanvasContext::getSwapChainPreferredFormat(
ScriptState* script_state, ScriptState* script_state,
const GPUDevice* device) { GPUDevice* device) {
ScriptPromiseResolver* resolver = ScriptPromiseResolver* resolver =
MakeGarbageCollected<ScriptPromiseResolver>(script_state); MakeGarbageCollected<ScriptPromiseResolver>(script_state);
ScriptPromise promise = resolver->Promise(); ScriptPromise promise = resolver->Promise();
device->AddConsoleWarning(
"Passing a GPUDevice to getSwapChainPreferredFormat is deprecated. "
"Pass a GPUAdapter instead, and update the calling code to expect a "
"GPUTextureFormat to be retured instead of a Promise.");
// TODO(crbug.com/1007166): Return actual preferred format for the swap chain. // TODO(crbug.com/1007166): Return actual preferred format for the swap chain.
resolver->Resolve("bgra8unorm"); resolver->Resolve("bgra8unorm");
return promise; return promise;
} }
String GPUCanvasContext::getSwapChainPreferredFormat(
const GPUAdapter* adapter) {
// TODO(crbug.com/1007166): Return actual preferred format for the swap chain.
return "bgra8unorm";
}
} // namespace blink } // namespace blink
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
namespace blink { namespace blink {
class GPUAdapter;
class GPUSwapChain; class GPUSwapChain;
class GPUSwapChainDescriptor; class GPUSwapChainDescriptor;
...@@ -63,7 +64,8 @@ class GPUCanvasContext : public CanvasRenderingContext { ...@@ -63,7 +64,8 @@ class GPUCanvasContext : public CanvasRenderingContext {
GPUSwapChain* configureSwapChain(const GPUSwapChainDescriptor* descriptor, GPUSwapChain* configureSwapChain(const GPUSwapChainDescriptor* descriptor,
ExceptionState&); ExceptionState&);
ScriptPromise getSwapChainPreferredFormat(ScriptState* script_state, ScriptPromise getSwapChainPreferredFormat(ScriptState* script_state,
const GPUDevice* device); GPUDevice* device);
String getSwapChainPreferredFormat(const GPUAdapter* adapter);
private: private:
DISALLOW_COPY_AND_ASSIGN(GPUCanvasContext); DISALLOW_COPY_AND_ASSIGN(GPUCanvasContext);
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
[RaisesException] GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor); [RaisesException] GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
[CallWith=ScriptState] Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device); [CallWith=ScriptState] Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
GPUTextureFormat getSwapChainPreferredFormat(GPUAdapter adapter);
}; };
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