Bug 1833753 [wpt PR 40065] - Allow newly-added test to also pass when mutation events...
[gecko.git] / gfx / webrender_bindings / RenderTextureHost.h
blob57e47a1c75f49c9c525e708681c7a9608cf35231
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/. */
7 #ifndef MOZILLA_GFX_RENDERTEXTUREHOST_H
8 #define MOZILLA_GFX_RENDERTEXTUREHOST_H
10 #include "GLConsts.h"
11 #include "GLTypes.h"
12 #include "nsISupportsImpl.h"
13 #include "mozilla/gfx/2D.h"
14 #include "mozilla/layers/LayersSurfaces.h"
15 #include "mozilla/RefPtr.h"
16 #include "mozilla/webrender/webrender_ffi.h"
17 #include "mozilla/webrender/WebRenderTypes.h"
19 namespace mozilla {
21 namespace gl {
22 class GLContext;
25 namespace wr {
27 class RenderAndroidHardwareBufferTextureHost;
28 class RenderAndroidSurfaceTextureHost;
29 class RenderCompositor;
30 class RenderDXGITextureHost;
31 class RenderDXGIYCbCrTextureHost;
32 class RenderDcompSurfaceTextureHost;
33 class RenderMacIOSurfaceTextureHost;
34 class RenderBufferTextureHost;
35 class RenderTextureHostSWGL;
36 class RenderTextureHostWrapper;
38 void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
39 GLenum aBindTarget, GLuint aBindTexture);
41 class RenderTextureHost {
42 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RenderTextureHost)
44 public:
45 RenderTextureHost();
47 virtual wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL);
49 virtual void Unlock() {}
51 virtual wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
52 RenderCompositor* aCompositor);
54 virtual void UnlockSWGL() {}
56 virtual void ClearCachedResources() {}
58 // Called asynchronouly when corresponding TextureHost's mCompositableCount
59 // becomes from 0 to 1. For now, it is used only for
60 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
61 virtual void PrepareForUse() {}
62 // Called asynchronouly when corresponding TextureHost's is actually going to
63 // be used by WebRender. For now, it is used only for
64 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
65 virtual void NotifyForUse() {}
66 // Called asynchronouly when corresponding TextureHost's mCompositableCount
67 // becomes 0. For now, it is used only for
68 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
69 virtual void NotifyNotUsed() {}
70 // Returns true when RenderTextureHost needs SyncObjectHost::Synchronize()
71 // call, before its usage.
72 virtual bool SyncObjectNeeded() { return false; }
73 // Returns true when this texture was generated from a DRM-protected source.
74 bool IsFromDRMSource() { return mIsFromDRMSource; }
75 void SetIsFromDRMSource(bool aIsFromDRMSource) {
76 mIsFromDRMSource = aIsFromDRMSource;
79 virtual size_t Bytes() = 0;
81 virtual RenderDXGITextureHost* AsRenderDXGITextureHost() { return nullptr; }
82 virtual RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() {
83 return nullptr;
86 virtual RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() {
87 return nullptr;
90 virtual RenderAndroidHardwareBufferTextureHost*
91 AsRenderAndroidHardwareBufferTextureHost() {
92 return nullptr;
95 virtual RenderAndroidSurfaceTextureHost* AsRenderAndroidSurfaceTextureHost() {
96 return nullptr;
99 virtual RenderTextureHostSWGL* AsRenderTextureHostSWGL() { return nullptr; }
101 virtual RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() {
102 return nullptr;
105 virtual bool IsWrappingAsyncRemoteTexture() { return false; }
107 virtual void Destroy();
109 protected:
110 virtual ~RenderTextureHost();
112 // Returns the UV coordinates to be used when sampling the texture, in pixels.
113 // For most implementations these will be (0, 0) and (size.x, size.y), but
114 // some texture types (such as RenderAndroidSurfaceTextureHost) require an
115 // additional transform to be applied to the coordinates.
116 virtual std::pair<gfx::Point, gfx::Point> GetUvCoords(
117 gfx::IntSize aTextureSize) const;
119 bool mIsFromDRMSource;
121 friend class RenderTextureHostWrapper;
124 } // namespace wr
125 } // namespace mozilla
127 #endif // MOZILLA_GFX_RENDERTEXTUREHOST_H