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 7 #ifndef MOZILLA_GFX_GPUVIDEOTEXTUREHOST_H 8 #define MOZILLA_GFX_GPUVIDEOTEXTUREHOST_H 9 10 #include "mozilla/layers/TextureHost.h" 11 12 namespace mozilla { 13 namespace layers { 14 15 class GPUVideoTextureHost : public TextureHost { 16 public: 17 static GPUVideoTextureHost* CreateFromDescriptor( 18 TextureFlags aFlags, const SurfaceDescriptorGPUVideo& aDescriptor); 19 20 virtual ~GPUVideoTextureHost(); 21 DeallocateDeviceData()22 void DeallocateDeviceData() override {} 23 24 virtual void SetTextureSourceProvider( 25 TextureSourceProvider* aProvider) override; 26 27 bool Lock() override; 28 29 void Unlock() override; 30 31 gfx::SurfaceFormat GetFormat() const override; 32 33 void PrepareTextureSource(CompositableTextureSourceRef& aTexture) override; 34 35 bool BindTextureSource(CompositableTextureSourceRef& aTexture) override; 36 bool AcquireTextureSource(CompositableTextureSourceRef& aTexture) override; 37 GetAsSurface()38 already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override { 39 return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING) 40 } 41 42 gfx::YUVColorSpace GetYUVColorSpace() const override; 43 gfx::ColorRange GetColorRange() const override; 44 45 gfx::IntSize GetSize() const override; 46 47 #ifdef MOZ_LAYERS_HAVE_LOG Name()48 const char* Name() override { return "GPUVideoTextureHost"; } 49 #endif 50 51 bool HasIntermediateBuffer() const override; 52 53 void CreateRenderTexture( 54 const wr::ExternalImageId& aExternalImageId) override; 55 56 void MaybeDestroyRenderTexture() override; 57 58 uint32_t NumSubTextures() override; 59 60 void PushResourceUpdates(wr::TransactionBuilder& aResources, 61 ResourceUpdateOp aOp, 62 const Range<wr::ImageKey>& aImageKeys, 63 const wr::ExternalImageId& aExtID) override; 64 65 void PushDisplayItems(wr::DisplayListBuilder& aBuilder, 66 const wr::LayoutRect& aBounds, 67 const wr::LayoutRect& aClip, wr::ImageRendering aFilter, 68 const Range<wr::ImageKey>& aImageKeys, 69 const bool aPreferCompositorSurface) override; 70 71 protected: 72 GPUVideoTextureHost(TextureFlags aFlags, 73 const SurfaceDescriptorGPUVideo& aDescriptor); 74 75 TextureHost* EnsureWrappedTextureHost(); 76 77 void UpdatedInternal(const nsIntRegion* Region) override; 78 79 RefPtr<TextureHost> mWrappedTextureHost; 80 SurfaceDescriptorGPUVideo mDescriptor; 81 }; 82 83 } // namespace layers 84 } // namespace mozilla 85 86 #endif // MOZILLA_GFX_GPUVIDEOTEXTUREHOST_H 87