Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / gfx / layers / TextureSourceProvider.h
blob50849692f5a6b8292ddc70fa88df81ae78177338
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/. */
6 #ifndef mozilla_gfx_layers_TextureSourceProvider_h
7 #define mozilla_gfx_layers_TextureSourceProvider_h
9 #include "nsISupportsImpl.h"
10 #include "mozilla/AlreadyAddRefed.h"
11 #include "mozilla/TimeStamp.h"
12 #include "mozilla/layers/CompositorTypes.h"
13 #include "nsTArray.h"
15 struct ID3D11Device;
17 namespace mozilla {
18 namespace gfx {
19 class DataSourceSurface;
20 } // namespace gfx
21 namespace gl {
22 class GLContext;
23 } // namespace gl
24 namespace layers {
26 class TextureHost;
27 class DataTextureSource;
28 class Compositor;
29 class CompositorOGL;
31 // Provided by a HostLayerManager or Compositor for allocating backend-specific
32 // texture types.
33 class TextureSourceProvider {
34 public:
35 NS_INLINE_DECL_REFCOUNTING(TextureSourceProvider)
37 virtual already_AddRefed<DataTextureSource> CreateDataTextureSource(
38 TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
40 virtual TimeStamp GetLastCompositionEndTime() const = 0;
42 virtual void TryUnlockTextures() {}
44 // If overridden, make sure to call the base function.
45 virtual void Destroy();
47 // If this provider is also a Compositor, return the compositor. Otherwise
48 // return null.
49 virtual Compositor* AsCompositor() { return nullptr; }
51 // If this provider is also a CompositorOGL, return the compositor. Otherwise
52 // return nullptr.
53 virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
55 #ifdef XP_WIN
56 // On Windows, if this provides Direct3D textures, it must expose the device.
57 virtual ID3D11Device* GetD3D11Device() const { return nullptr; }
58 #endif
60 // If this provides OpenGL textures, it must expose the GLContext.
61 virtual gl::GLContext* GetGLContext() const { return nullptr; }
63 virtual int32_t GetMaxTextureSize() const = 0;
65 // Return whether or not this provider is still valid (i.e., is still being
66 // used to composite).
67 virtual bool IsValid() const = 0;
69 protected:
70 virtual ~TextureSourceProvider();
73 } // namespace layers
74 } // namespace mozilla
76 #endif // mozilla_gfx_layers_TextureSourceProvider_h