summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/webgpu/window_webgpu.cc
blob: 1a578453d9154647ea8da76312720239c41179fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/webgpu/window_webgpu.h"

#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/modules/webgpu/webgpu.h"

namespace blink {

const char WindowWebGPU::kSupplementName[] = "WindowWebGPU";

// static
WindowWebGPU& WindowWebGPU::From(LocalDOMWindow& window) {
  WindowWebGPU* supplement =
      Supplement<LocalDOMWindow>::From<WindowWebGPU>(window);
  if (!supplement) {
    supplement = new WindowWebGPU(window);
    ProvideTo(window, supplement);
  }
  return *supplement;
}

// static
WebGPU* WindowWebGPU::webgpu(LocalDOMWindow& window) {
  return WindowWebGPU::From(window).webgpu();
}

WebGPU* WindowWebGPU::webgpu() const {
  if (!webgpu_) {
    webgpu_ = WebGPU::Create();
  }
  return webgpu_.Get();
}

void WindowWebGPU::Trace(blink::Visitor* visitor) {
  visitor->Trace(webgpu_);
  Supplement<LocalDOMWindow>::Trace(visitor);
}

WindowWebGPU::WindowWebGPU(LocalDOMWindow& window)
    : Supplement<LocalDOMWindow>(window) {}

}  // namespace blink