summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc')
-rw-r--r--chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc b/chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
index bfacc2148b4..50188762c2f 100644
--- a/chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
+++ b/chromium/third_party/blink/renderer/modules/webgpu/gpu_canvas_context.cc
@@ -7,6 +7,7 @@
#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/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"
namespace blink {
@@ -125,20 +126,38 @@ GPUSwapChain* GPUCanvasContext::configureSwapChain(
swapchain_ = MakeGarbageCollected<GPUSwapChain>(
this, descriptor->device(), usage, format, filter_quality_);
+ swapchain_->CcLayer()->SetContentsOpaque(!CreationAttributes().alpha);
+ swapchain_->setLabel(descriptor->label());
+
+ // If we don't notify the host that something has changed it may never check
+ // for the new cc::Layer.
+ Host()->SetNeedsCompositingUpdate();
+
return swapchain_;
}
ScriptPromise GPUCanvasContext::getSwapChainPreferredFormat(
ScriptState* script_state,
- const GPUDevice* device) {
+ GPUDevice* device) {
ScriptPromiseResolver* resolver =
MakeGarbageCollected<ScriptPromiseResolver>(script_state);
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.
resolver->Resolve("bgra8unorm");
return promise;
}
+String GPUCanvasContext::getSwapChainPreferredFormat(
+ const GPUAdapter* adapter) {
+ // TODO(crbug.com/1007166): Return actual preferred format for the swap chain.
+ return "bgra8unorm";
+}
+
} // namespace blink