Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef MOZILLA_GFX_WEBRENDERIMAGEHOST_H
7 : #define MOZILLA_GFX_WEBRENDERIMAGEHOST_H
8 :
9 : #include "CompositableHost.h" // for CompositableHost
10 : #include "mozilla/layers/ImageComposite.h" // for ImageComposite
11 :
12 : namespace mozilla {
13 : namespace layers {
14 :
15 : class WebRenderBridgeParent;
16 :
17 : /**
18 : * ImageHost. Works with ImageClientSingle and ImageClientBuffered
19 : */
20 : class WebRenderImageHost : public CompositableHost,
21 : public ImageComposite
22 : {
23 : public:
24 : explicit WebRenderImageHost(const TextureInfo& aTextureInfo);
25 : ~WebRenderImageHost();
26 :
27 0 : virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
28 :
29 : virtual void Composite(Compositor* aCompositor,
30 : LayerComposite* aLayer,
31 : EffectChain& aEffectChain,
32 : float aOpacity,
33 : const gfx::Matrix4x4& aTransform,
34 : const gfx::SamplingFilter aSamplingFilter,
35 : const gfx::IntRect& aClipRect,
36 : const nsIntRegion* aVisibleRegion = nullptr,
37 : const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
38 :
39 : virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
40 : virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
41 : TextureHost* aTextureOnWhite) override;
42 : virtual void RemoveTextureHost(TextureHost* aTexture) override;
43 :
44 : virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
45 :
46 : virtual void Attach(Layer* aLayer,
47 : TextureSourceProvider* aProvider,
48 : AttachFlags aFlags = NO_FLAGS) override;
49 :
50 : virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
51 :
52 : gfx::IntSize GetImageSize() const override;
53 :
54 : virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
55 :
56 : virtual void Dump(std::stringstream& aStream,
57 : const char* aPrefix = "",
58 : bool aDumpHtml = false) override;
59 :
60 : virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
61 :
62 : virtual bool Lock() override;
63 :
64 : virtual void Unlock() override;
65 :
66 : virtual void CleanupResources() override;
67 :
68 0 : virtual WebRenderImageHost* AsWebRenderImageHost() override { return this; }
69 :
70 : TextureHost* GetAsTextureHostForComposite();
71 :
72 : void SetWrBridge(WebRenderBridgeParent* aWrBridge);
73 :
74 : void ClearWrBridge();
75 :
76 : TextureHost* GetCurrentTextureHost() { return mCurrentTextureHost; }
77 :
78 : protected:
79 : // ImageComposite
80 : virtual TimeStamp GetCompositionTime() const override;
81 :
82 : void SetCurrentTextureHost(TextureHost* aTexture);
83 :
84 : WebRenderBridgeParent* MOZ_NON_OWNING_REF mWrBridge;
85 :
86 : uint32_t mWrBridgeBindings;
87 :
88 : CompositableTextureHostRef mCurrentTextureHost;
89 : };
90 :
91 : } // namespace layers
92 : } // namespace mozilla
93 :
94 : #endif // MOZILLA_GFX_WEBRENDERIMAGEHOST_H
|