Backed out changeset 0c01a856e4c3 (bug 1870427) as requested by Emilio CLOSED TREE
[gecko.git] / gfx / webrender_bindings / RenderTextureHost.cpp
blob11b6469745ccd9320e6e3942b79cee8cc08eda3d
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 #include "RenderTextureHost.h"
9 #include "GLContext.h"
10 #include "mozilla/layers/CompositorThread.h"
11 #include "RenderThread.h"
13 namespace mozilla {
14 namespace wr {
16 void ActivateBindAndTexParameteri(gl::GLContext* aGL, GLenum aActiveTexture,
17 GLenum aBindTarget, GLuint aBindTexture) {
18 aGL->fActiveTexture(aActiveTexture);
19 aGL->fBindTexture(aBindTarget, aBindTexture);
20 // Initialize the mip filters to linear by default.
21 aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MIN_FILTER,
22 LOCAL_GL_LINEAR);
23 aGL->fTexParameteri(aBindTarget, LOCAL_GL_TEXTURE_MAG_FILTER,
24 LOCAL_GL_LINEAR);
27 RenderTextureHost::RenderTextureHost() : mIsFromDRMSource(false) {
28 MOZ_COUNT_CTOR(RenderTextureHost);
31 RenderTextureHost::~RenderTextureHost() {
32 MOZ_ASSERT(RenderThread::IsInRenderThread());
33 MOZ_COUNT_DTOR(RenderTextureHost);
36 wr::WrExternalImage RenderTextureHost::Lock(uint8_t aChannelIndex,
37 gl::GLContext* aGL) {
38 return InvalidToWrExternalImage();
41 wr::WrExternalImage RenderTextureHost::LockSWGL(uint8_t aChannelIndex,
42 void* aContext,
43 RenderCompositor* aCompositor) {
44 return InvalidToWrExternalImage();
47 void RenderTextureHost::Destroy() {
48 MOZ_ASSERT_UNREACHABLE("unexpected to be called");
51 RefPtr<RenderTextureHostUsageInfo> RenderTextureHost::GetOrMergeUsageInfo(
52 const MutexAutoLock& aProofOfMapLock,
53 RefPtr<RenderTextureHostUsageInfo> aUsageInfo) {
54 MOZ_ASSERT(layers::CompositorThreadHolder::IsInCompositorThread());
56 if (mRenderTextureHostUsageInfo && aUsageInfo) {
57 if (mRenderTextureHostUsageInfo == aUsageInfo) {
58 return mRenderTextureHostUsageInfo;
61 // Merge 2 RenderTextureHostUsageInfos to one RenderTextureHostUsageInfo.
63 const bool overlayDisabled =
64 mRenderTextureHostUsageInfo->VideoOverlayDisabled() ||
65 aUsageInfo->VideoOverlayDisabled();
67 // If mRenderTextureHostUsageInfo and aUsageInfo are different objects, keep
68 // the older one.
69 RefPtr<RenderTextureHostUsageInfo> usageInfo = [&]() {
70 if (aUsageInfo->mCreationTimeStamp <
71 mRenderTextureHostUsageInfo->mCreationTimeStamp) {
72 return aUsageInfo;
74 return mRenderTextureHostUsageInfo;
75 }();
77 // Merge info.
78 if (overlayDisabled) {
79 usageInfo->DisableVideoOverlay();
81 mRenderTextureHostUsageInfo = usageInfo;
82 } else if (aUsageInfo && !mRenderTextureHostUsageInfo) {
83 mRenderTextureHostUsageInfo = aUsageInfo;
86 if (!mRenderTextureHostUsageInfo) {
87 MOZ_ASSERT(!aUsageInfo);
88 mRenderTextureHostUsageInfo = new RenderTextureHostUsageInfo;
91 MOZ_ASSERT(mRenderTextureHostUsageInfo);
92 MOZ_ASSERT_IF(aUsageInfo && aUsageInfo->VideoOverlayDisabled(),
93 mRenderTextureHostUsageInfo->VideoOverlayDisabled());
95 return mRenderTextureHostUsageInfo;
98 RefPtr<RenderTextureHostUsageInfo> RenderTextureHost::GetTextureHostUsageInfo(
99 const MutexAutoLock& aProofOfMapLock) {
100 MOZ_ASSERT(RenderThread::IsInRenderThread());
102 return mRenderTextureHostUsageInfo;
105 } // namespace wr
106 } // namespace mozilla