TextureSourceProvider.h (2320B)
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 8 9 #include "nsISupportsImpl.h" 10 #include "mozilla/AlreadyAddRefed.h" 11 #include "mozilla/TimeStamp.h" 12 #include "mozilla/layers/CompositorTypes.h" 13 #include "nsTArray.h" 14 15 struct ID3D11Device; 16 17 namespace mozilla { 18 namespace gfx { 19 class DataSourceSurface; 20 } // namespace gfx 21 namespace gl { 22 class GLContext; 23 } // namespace gl 24 namespace layers { 25 26 class TextureHost; 27 class DataTextureSource; 28 class Compositor; 29 class CompositorOGL; 30 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) 36 37 virtual already_AddRefed<DataTextureSource> CreateDataTextureSource( 38 TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0; 39 40 virtual TimeStamp GetLastCompositionEndTime() const = 0; 41 42 virtual void TryUnlockTextures() {} 43 44 // If overridden, make sure to call the base function. 45 virtual void Destroy(); 46 47 // If this provider is also a Compositor, return the compositor. Otherwise 48 // return null. 49 virtual Compositor* AsCompositor() { return nullptr; } 50 51 // If this provider is also a CompositorOGL, return the compositor. Otherwise 52 // return nullptr. 53 virtual CompositorOGL* AsCompositorOGL() { return nullptr; } 54 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 59 60 // If this provides OpenGL textures, it must expose the GLContext. 61 virtual gl::GLContext* GetGLContext() const { return nullptr; } 62 63 virtual int32_t GetMaxTextureSize() const = 0; 64 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; 68 69 protected: 70 virtual ~TextureSourceProvider(); 71 }; 72 73 } // namespace layers 74 } // namespace mozilla 75 76 #endif // mozilla_gfx_layers_TextureSourceProvider_h