dom/webgpu/Device.h
author James Teh <jteh@mozilla.com>
Thu, 07 Mar 2019 18:10:13 +0000
changeset 520910 c26d4a8d43c4d0d6f6e13135b8f35924123fe99e
parent 505471 66eb1f485c1a3ea81372758bc92292c9428b17cd
permissions -rw-r--r--
Bug 1527922: Ensure the Reload button is disabled when testing against blank tabs in the browser toolbar key nav tests. r=Gijs For a blank tab, the Reload button should be disabled. These tests depend on this. This seems to be true when setting the new tab page to blank in Firefox Options. However, when we open about:blank with BrowserTestUtils.withNewTab, this is unreliable. That is, sometimes the Reload button is enabled, sometimes it isn't. I don't understand why this happens. For the purposes of these tests, just force the Reload button to be disabled for new, blank tabs so we get consistent results. Differential Revision: https://phabricator.services.mozilla.com/D22449

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef WEBGPU_DEVICE_H_
#define WEBGPU_DEVICE_H_

#include "mozilla/RefPtr.h"
#include "ObjectModel.h"

namespace mozilla {
namespace dom {
struct WebGPUExtensions;
struct WebGPUFeatures;
struct WebGPULimits;

struct WebGPUBufferDescriptor;
struct WebGPUTextureDescriptor;
struct WebGPUSamplerDescriptor;
struct WebGPUBindGroupLayoutDescriptor;
struct WebGPUPipelineLayoutDescriptor;
struct WebGPUBindGroupDescriptor;
struct WebGPUBlendStateDescriptor;
struct WebGPUDepthStencilStateDescriptor;
struct WebGPUInputStateDescriptor;
struct WebGPUShaderModuleDescriptor;
struct WebGPUAttachmentStateDescriptor;
struct WebGPUComputePipelineDescriptor;
struct WebGPURenderPipelineDescriptor;
struct WebGPUCommandEncoderDescriptor;

class Promise;
class WebGPUBufferOrWebGPUTexture;
class WebGPULogCallback;
}  // namespace dom

namespace webgpu {
class Adapter;
class AttachmentState;
class BindGroup;
class BindGroupLayout;
class BlendState;
class Buffer;
class CommandEncoder;
class ComputePipeline;
class DepthStencilState;
class Fence;
class InputState;
class PipelineLayout;
class Queue;
class RenderPipeline;
class Sampler;
class ShaderModule;
class Texture;

class Device final : public ChildOf<Adapter> {
 public:
  WEBGPU_DECL_GOOP(Device)

 private:
  Device() = delete;
  virtual ~Device();

 public:
  already_AddRefed<webgpu::Adapter> Adapter() const;

  void Extensions(dom::WebGPUExtensions& out) const;
  void Features(dom::WebGPUFeatures& out) const;
  void Limits(dom::WebGPULimits& out) const;

  already_AddRefed<Buffer> CreateBuffer(
      const dom::WebGPUBufferDescriptor& desc) const;
  already_AddRefed<Texture> CreateTexture(
      const dom::WebGPUTextureDescriptor& desc) const;
  already_AddRefed<Sampler> CreateSampler(
      const dom::WebGPUSamplerDescriptor& desc) const;

  already_AddRefed<BindGroupLayout> CreateBindGroupLayout(
      const dom::WebGPUBindGroupLayoutDescriptor& desc) const;
  already_AddRefed<PipelineLayout> CreatePipelineLayout(
      const dom::WebGPUPipelineLayoutDescriptor& desc) const;
  already_AddRefed<BindGroup> CreateBindGroup(
      const dom::WebGPUBindGroupDescriptor& desc) const;

  already_AddRefed<BlendState> CreateBlendState(
      const dom::WebGPUBlendStateDescriptor& desc) const;
  already_AddRefed<DepthStencilState> CreateDepthStencilState(
      const dom::WebGPUDepthStencilStateDescriptor& desc) const;
  already_AddRefed<InputState> CreateInputState(
      const dom::WebGPUInputStateDescriptor& desc) const;
  already_AddRefed<ShaderModule> CreateShaderModule(
      const dom::WebGPUShaderModuleDescriptor& desc) const;
  already_AddRefed<AttachmentState> CreateAttachmentState(
      const dom::WebGPUAttachmentStateDescriptor& desc) const;
  already_AddRefed<ComputePipeline> CreateComputePipeline(
      const dom::WebGPUComputePipelineDescriptor& desc) const;
  already_AddRefed<RenderPipeline> CreateRenderPipeline(
      const dom::WebGPURenderPipelineDescriptor& desc) const;

  already_AddRefed<CommandEncoder> CreateCommandEncoder(
      const dom::WebGPUCommandEncoderDescriptor& desc) const;

  already_AddRefed<Queue> GetQueue() const;

  RefPtr<dom::WebGPULogCallback> OnLog() const;
  void SetOnLog(const dom::WebGPULogCallback& callback) const;

  already_AddRefed<dom::Promise> GetObjectStatus(
      const dom::WebGPUBufferOrWebGPUTexture& obj) const;
};

}  // namespace webgpu
}  // namespace mozilla

#endif  // WEBGPU_DEVICE_H_