no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / gfx / webrender_bindings / RenderTextureHost.h
blob5798cf94f5c5131b9c9eeb31d1b4803ee606a514
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 gfx::SurfaceFormat GetFormat() const {
48 return gfx::SurfaceFormat::UNKNOWN;
51 virtual gfx::YUVRangedColorSpace GetYUVColorSpace() const {
52 return gfx::YUVRangedColorSpace::Default;
55 virtual wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL);
57 virtual void Unlock() {}
59 virtual wr::WrExternalImage LockSWGL(uint8_t aChannelIndex, void* aContext,
60 RenderCompositor* aCompositor);
62 virtual void UnlockSWGL() {}
64 virtual void ClearCachedResources() {}
66 // Called asynchronouly when corresponding TextureHost's mCompositableCount
67 // becomes from 0 to 1. For now, it is used only for
68 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
69 virtual void PrepareForUse() {}
70 // Called asynchronouly when corresponding TextureHost's is actually going to
71 // be used by WebRender. For now, it is used only for
72 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
73 virtual void NotifyForUse() {}
74 // Called asynchronouly when corresponding TextureHost's mCompositableCount
75 // becomes 0. For now, it is used only for
76 // SurfaceTextureHost/RenderAndroidSurfaceTextureHost.
77 virtual void NotifyNotUsed() {}
78 // Returns true when RenderTextureHost needs SyncObjectHost::Synchronize()
79 // call, before its usage.
80 virtual bool SyncObjectNeeded() { return false; }
81 // Returns true when this texture was generated from a DRM-protected source.
82 bool IsFromDRMSource() { return mIsFromDRMSource; }
83 void SetIsFromDRMSource(bool aIsFromDRMSource) {
84 mIsFromDRMSource = aIsFromDRMSource;
87 virtual size_t Bytes() = 0;
89 virtual RenderDXGITextureHost* AsRenderDXGITextureHost() { return nullptr; }
90 virtual RenderDXGIYCbCrTextureHost* AsRenderDXGIYCbCrTextureHost() {
91 return nullptr;
94 virtual RenderMacIOSurfaceTextureHost* AsRenderMacIOSurfaceTextureHost() {
95 return nullptr;
98 virtual RenderAndroidHardwareBufferTextureHost*
99 AsRenderAndroidHardwareBufferTextureHost() {
100 return nullptr;
103 virtual RenderAndroidSurfaceTextureHost* AsRenderAndroidSurfaceTextureHost() {
104 return nullptr;
107 virtual RenderTextureHostSWGL* AsRenderTextureHostSWGL() { return nullptr; }
109 virtual RenderDcompSurfaceTextureHost* AsRenderDcompSurfaceTextureHost() {
110 return nullptr;
113 virtual void Destroy();
115 virtual void SetIsSoftwareDecodedVideo() {
116 MOZ_ASSERT_UNREACHABLE("unexpected to be called");
118 virtual bool IsSoftwareDecodedVideo() {
119 MOZ_ASSERT_UNREACHABLE("unexpected to be called");
120 return false;
123 protected:
124 virtual ~RenderTextureHost();
126 // Returns the UV coordinates to be used when sampling the texture, in pixels.
127 // For most implementations these will be (0, 0) and (size.x, size.y), but
128 // some texture types (such as RenderAndroidSurfaceTextureHost) require an
129 // additional transform to be applied to the coordinates.
130 virtual std::pair<gfx::Point, gfx::Point> GetUvCoords(
131 gfx::IntSize aTextureSize) const;
133 bool mIsFromDRMSource;
135 friend class RenderTextureHostWrapper;
138 } // namespace wr
139 } // namespace mozilla
141 #endif // MOZILLA_GFX_RENDERTEXTUREHOST_H