gpu.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_H_
  5. #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_H_
  6. #include "base/memory/scoped_refptr.h"
  7. #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
  8. #include "third_party/blink/renderer/core/execution_context/execution_context.h"
  9. #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
  10. #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
  11. struct WGPUDeviceProperties;
  12. namespace blink {
  13. class GPURequestAdapterOptions;
  14. class ScriptPromiseResolver;
  15. class ScriptState;
  16. class DawnControlClientHolder;
  17. class GPU final : public ScriptWrappable,
  18. public ExecutionContextLifecycleObserver {
  19. DEFINE_WRAPPERTYPEINFO();
  20. public:
  21. static GPU* Create(ExecutionContext& execution_context);
  22. explicit GPU(ExecutionContext& execution_context);
  23. ~GPU() override;
  24. // ScriptWrappable overrides
  25. void Trace(Visitor* visitor) const override;
  26. // ExecutionContextLifecycleObserver overrides
  27. void ContextDestroyed() override;
  28. // gpu.idl
  29. ScriptPromise requestAdapter(ScriptState* script_state,
  30. const GPURequestAdapterOptions* options);
  31. private:
  32. void OnRequestAdapterCallback(ScriptPromiseResolver* resolver,
  33. int32_t adapter_server_id,
  34. const WGPUDeviceProperties& properties);
  35. scoped_refptr<DawnControlClientHolder> dawn_control_client_;
  36. DISALLOW_COPY_AND_ASSIGN(GPU);
  37. };
  38. } // namespace blink
  39. #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_H_