Bug 1794361 [wpt PR 36364] - Update overlapping nav and traversal tests to match...
[gecko.git] / gfx / ipc / CanvasRenderThread.h
blobba06931de4b48c4c2b2968d702beff873c546a4b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef _include_gfx_ipc_CanvasRenderThread_h__
8 #define _include_gfx_ipc_CanvasRenderThread_h__
10 #include "mozilla/DataMutex.h"
11 #include "mozilla/layers/SynchronousTask.h"
12 #include "mozilla/StaticPtr.h"
13 #include "nsISupportsImpl.h"
14 #include "nsThread.h"
16 namespace mozilla::gfx {
18 class CanvasRenderThread final {
19 NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_DELETE_ON_MAIN_THREAD(
20 CanvasRenderThread)
22 public:
23 /// Can be called from any thread.
24 static CanvasRenderThread* Get();
26 /// Can only be called from the main thread.
27 static void Start();
29 /// Can only be called from the main thread.
30 static void ShutDown();
32 /// Can be called from any thread.
33 static bool IsInCanvasRenderThread();
35 /// Can be called from any thread.
36 static already_AddRefed<nsIThread> GetCanvasRenderThread();
38 private:
39 explicit CanvasRenderThread(RefPtr<nsIThread> aThread);
40 ~CanvasRenderThread();
42 void ShutDownTask(layers::SynchronousTask* aTask);
43 void PostRunnable(already_AddRefed<nsIRunnable> aRunnable);
45 RefPtr<nsIThread> const mThread;
48 } // namespace mozilla::gfx
50 #endif // _include_gfx_ipc_CanvasRenderThread_h__