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"
19 class DataSourceSurface
;
27 class DataTextureSource
;
31 // Provided by a HostLayerManager or Compositor for allocating backend-specific
33 class TextureSourceProvider
{
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
49 virtual Compositor
* AsCompositor() { return nullptr; }
51 // If this provider is also a CompositorOGL, return the compositor. Otherwise
53 virtual CompositorOGL
* AsCompositorOGL() { return nullptr; }
56 // On Windows, if this provides Direct3D textures, it must expose the device.
57 virtual ID3D11Device
* GetD3D11Device() const { return nullptr; }
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;
70 virtual ~TextureSourceProvider();
74 } // namespace mozilla
76 #endif // mozilla_gfx_layers_TextureSourceProvider_h