gfx/layers/OOPCanvasRenderer.h
author Randell Jesup <rjesup@wgate.com>
Wed, 28 Sep 2022 02:10:18 +0000
changeset 636504 388419886525a4b8d6be986bc890f09e6c16052d
parent 516859 0194aff14e504c2d787f9084acdc162afc1a9688
permissions -rw-r--r--
Bug 1791332: Add an OPFS-specific synchronous ordered cleanup queue r=asuth,dom-storage-reviewers The default test.add_cleanup() code from testharness.js in wpt executes the cleanups in parallel, and even if it wasn't in parallel it would be in FIFO order (the wrong order). This adds an OPFS-specific cleanup queue called once from the test cleanup list, and we process the list synchronously in LIFO order. Depends on D146203 Differential Revision: https://phabricator.services.mozilla.com/D157606

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 MOZILLA_LAYERS_OOPCANVASRENDERER_H_
#define MOZILLA_LAYERS_OOPCANVASRENDERER_H_

#include "nsISupportsImpl.h"

class nsICanvasRenderingContextInternal;

namespace mozilla {

namespace dom {
class HTMLCanvasElement;
}

namespace layers {
class CanvasClient;

/**
 * This renderer works with WebGL running in the host process.  It does
 * not perform any graphics operations itself -- it is the client-side
 * representation.  It forwards WebGL composition to the remote process.
 */
class OOPCanvasRenderer final {
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(OOPCanvasRenderer)

 public:
  explicit OOPCanvasRenderer(nsICanvasRenderingContextInternal* aContext)
      : mContext(aContext) {}

  dom::HTMLCanvasElement* mHTMLCanvasElement = nullptr;

  // The ClientWebGLContext that this is for
  nsICanvasRenderingContextInternal* mContext = nullptr;

  // The lifetime of this pointer is controlled by OffscreenCanvas
  // Can be accessed in active thread and ImageBridge thread.
  // But we never accessed it at the same time on both thread. So no
  // need to protect this member.
  CanvasClient* mCanvasClient = nullptr;

 private:
  ~OOPCanvasRenderer() = default;
};

}  // namespace layers
}  // namespace mozilla

#endif  // MOZILLA_LAYERS_OOPCANVASRENDERER_H_