/src/mozilla-central/gfx/layers/wr/WebRenderTextureHost.h
Line | Count | Source (jump to first uncovered line) |
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_WEBRENDERTEXTUREHOST_H |
8 | | #define MOZILLA_GFX_WEBRENDERTEXTUREHOST_H |
9 | | |
10 | | #include "mozilla/layers/TextureHost.h" |
11 | | #include "mozilla/webrender/WebRenderTypes.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace layers { |
15 | | |
16 | | class SurfaceDescriptor; |
17 | | |
18 | | // This textureHost is specialized for WebRender usage. With WebRender, there is |
19 | | // no Compositor during composition. Instead, we use RendererOGL for composition. |
20 | | // So, there are some UNREACHABLE asserts for the original Compositor related |
21 | | // code path in this class. Furthermore, the RendererOGL runs at RenderThead |
22 | | // instead of Compositor thread. This class is also creating the corresponding |
23 | | // RenderXXXTextureHost used by RendererOGL at RenderThread. |
24 | | class WebRenderTextureHost : public TextureHost |
25 | | { |
26 | | public: |
27 | | WebRenderTextureHost(const SurfaceDescriptor& aDesc, |
28 | | TextureFlags aFlags, |
29 | | TextureHost* aTexture, |
30 | | wr::ExternalImageId& aExternalImageId); |
31 | | virtual ~WebRenderTextureHost(); |
32 | | |
33 | 0 | virtual void DeallocateDeviceData() override {} |
34 | | |
35 | | virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override; |
36 | | |
37 | | virtual bool Lock() override; |
38 | | |
39 | | virtual void Unlock() override; |
40 | | |
41 | | virtual gfx::SurfaceFormat GetFormat() const override; |
42 | | |
43 | | // Return the format used for reading the texture. Some hardware specific |
44 | | // textureHosts use their special data representation internally, but we could |
45 | | // treat these textureHost as the read-format when we read them. |
46 | | // Please check TextureHost::GetReadFormat(). |
47 | | virtual gfx::SurfaceFormat GetReadFormat() const override; |
48 | | |
49 | | virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override; |
50 | | |
51 | | virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override; |
52 | | |
53 | | virtual YUVColorSpace GetYUVColorSpace() const override; |
54 | | |
55 | | virtual gfx::IntSize GetSize() const override; |
56 | | |
57 | | #ifdef MOZ_LAYERS_HAVE_LOG |
58 | 0 | virtual const char* Name() override { return "WebRenderTextureHost"; } |
59 | | #endif |
60 | | |
61 | 0 | virtual WebRenderTextureHost* AsWebRenderTextureHost() override { return this; } |
62 | | |
63 | | wr::ExternalImageId GetExternalImageKey() { return mExternalImageId; } |
64 | | |
65 | | int32_t GetRGBStride(); |
66 | | |
67 | | virtual uint32_t NumSubTextures() const override; |
68 | | |
69 | | virtual void PushResourceUpdates(wr::TransactionBuilder& aResources, |
70 | | ResourceUpdateOp aOp, |
71 | | const Range<wr::ImageKey>& aImageKeys, |
72 | | const wr::ExternalImageId& aExtID) override; |
73 | | |
74 | | virtual void PushDisplayItems(wr::DisplayListBuilder& aBuilder, |
75 | | const wr::LayoutRect& aBounds, |
76 | | const wr::LayoutRect& aClip, |
77 | | wr::ImageRendering aFilter, |
78 | | const Range<wr::ImageKey>& aImageKeys) override; |
79 | | |
80 | | virtual bool SupportsWrNativeTexture() override; |
81 | | |
82 | | protected: |
83 | | void CreateRenderTextureHost(const SurfaceDescriptor& aDesc, TextureHost* aTexture); |
84 | | |
85 | | RefPtr<TextureHost> mWrappedTextureHost; |
86 | | wr::ExternalImageId mExternalImageId; |
87 | | }; |
88 | | |
89 | | } // namespace layers |
90 | | } // namespace mozilla |
91 | | |
92 | | #endif // MOZILLA_GFX_WEBRENDERTEXTUREHOST_H |