summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h')
-rw-r--r--chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h35
1 files changed, 20 insertions, 15 deletions
diff --git a/chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h b/chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h
index 45107df89b5..fd58ce91182 100644
--- a/chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h
+++ b/chromium/third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h
@@ -8,41 +8,46 @@
#include <dawn/dawn_proc_table.h>
#include <dawn/webgpu.h>
+#include "gpu/command_buffer/client/webgpu_interface.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_resource_provider_cache.h"
#include "third_party/blink/renderer/platform/graphics/web_graphics_context_3d_provider_wrapper.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/ref_counted.h"
-namespace gpu {
-namespace webgpu {
+namespace base {
-class WebGPUInterface;
+class SingleThreadTaskRunner;
-} // namespace webgpu
-} // namespace gpu
+} // namespace base
namespace blink {
-// This class holds the WebGPUInterface and a |destroyed_| flag.
-// DawnControlClientHolder::Destroy() should be called to destroy the backing
-// WebGPUInterface.
+// This class holds the WebGraphicsContext3DProviderWrapper and a strong
+// reference to the WebGPU APIChannel.
+// DawnControlClientHolder::Destroy() should be called to destroy the
+// context which will free all command buffer and GPU resources. As long
+// as the reference to the APIChannel is held, calling WebGPU procs is
+// valid.
class PLATFORM_EXPORT DawnControlClientHolder
: public RefCounted<DawnControlClientHolder> {
public:
+ static scoped_refptr<DawnControlClientHolder> Create(
+ std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+
DawnControlClientHolder(
std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
void Destroy();
+ // Returns a weak pointer to |context_provider_|. If the pointer is valid and
+ // non-null, the WebGPU context has not been destroyed, and it is safe to use
+ // the WebGPU interface.
base::WeakPtr<WebGraphicsContext3DProviderWrapper> GetContextProviderWeakPtr()
const;
- WebGraphicsContext3DProvider* GetContextProvider() const;
- gpu::webgpu::WebGPUInterface* GetInterface() const;
const DawnProcTable& GetProcs() const { return procs_; }
- void SetContextLost();
bool IsContextLost() const;
- void SetLostContextCallback();
std::unique_ptr<RecyclableCanvasResource> GetOrCreateCanvasResource(
const IntSize& size,
const CanvasResourceParams& params,
@@ -50,12 +55,12 @@ class PLATFORM_EXPORT DawnControlClientHolder
private:
friend class RefCounted<DawnControlClientHolder>;
- ~DawnControlClientHolder() = default;
+ ~DawnControlClientHolder();
std::unique_ptr<WebGraphicsContext3DProviderWrapper> context_provider_;
- gpu::webgpu::WebGPUInterface* interface_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<gpu::webgpu::APIChannel> api_channel_;
DawnProcTable procs_;
- bool lost_ = false;
WebGPURecyclableResourceCache recyclable_resource_cache_;
};