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
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" // for wr::ImageRendering
17 #include "mozilla/webrender/WebRenderTypes.h"
27 class RenderCompositor
;
28 class RenderDXGITextureHost
;
29 class RenderDXGIYCbCrTextureHost
;
30 class RenderMacIOSurfaceTextureHost
;
31 class RenderBufferTextureHost
;
32 class RenderTextureHostSWGL
;
34 void ActivateBindAndTexParameteri(gl::GLContext
* aGL
, GLenum aActiveTexture
,
35 GLenum aBindTarget
, GLuint aBindTexture
,
36 wr::ImageRendering aRendering
);
38 class RenderTextureHost
{
39 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RenderTextureHost
)
44 virtual wr::WrExternalImage
Lock(uint8_t aChannelIndex
, gl::GLContext
* aGL
,
45 wr::ImageRendering aRendering
);
47 virtual void Unlock() {}
49 virtual wr::WrExternalImage
LockSWGL(uint8_t aChannelIndex
, void* aContext
,
50 RenderCompositor
* aCompositor
,
51 wr::ImageRendering aRendering
);
53 virtual void UnlockSWGL() {}
55 virtual void ClearCachedResources() {}
57 // Called asynchronouly when corresponding TextureHost's mCompositableCount
58 // becomes from 0 to 1. For now, it is used only for
59 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
60 virtual void PrepareForUse() {}
61 // Called asynchronouly when corresponding TextureHost's is actually going to
62 // be used by WebRender. For now, it is used only for
63 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
64 virtual void NotifyForUse() {}
65 // Called asynchronouly when corresponding TextureHost's mCompositableCount
66 // becomes 0. For now, it is used only for
67 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
68 virtual void NotifyNotUsed() {}
69 // Returns true when RenderTextureHost needs SyncObjectHost::Synchronize()
70 // call, before its usage.
71 virtual bool SyncObjectNeeded() { return false; }
73 virtual size_t Bytes() = 0;
75 virtual RenderDXGITextureHost
* AsRenderDXGITextureHost() { return nullptr; }
76 virtual RenderDXGIYCbCrTextureHost
* AsRenderDXGIYCbCrTextureHost() {
80 virtual RenderMacIOSurfaceTextureHost
* AsRenderMacIOSurfaceTextureHost() {
84 virtual RenderTextureHostSWGL
* AsRenderTextureHostSWGL() { return nullptr; }
87 virtual ~RenderTextureHost();
89 bool IsFilterUpdateNecessary(wr::ImageRendering aRendering
);
91 wr::ImageRendering mCachedRendering
;
95 } // namespace mozilla
97 #endif // MOZILLA_GFX_RENDERTEXTUREHOST_H