diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp')
-rw-r--r-- | gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp b/gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp new file mode 100644 index 0000000000..c2ff39ba24 --- /dev/null +++ b/gfx/angle/checkout/src/libANGLE/renderer/d3d/EGLImageD3D.cpp @@ -0,0 +1,93 @@ +// +// Copyright 2015 The ANGLE Project Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// + +// EGLImageD3D.cpp: Implements the rx::EGLImageD3D class, the D3D implementation of EGL images + +#include "libANGLE/renderer/d3d/EGLImageD3D.h" + +#include "common/debug.h" +#include "common/utilities.h" +#include "libANGLE/AttributeMap.h" +#include "libANGLE/Context.h" +#include "libANGLE/Texture.h" +#include "libANGLE/renderer/d3d/RenderTargetD3D.h" +#include "libANGLE/renderer/d3d/RenderbufferD3D.h" +#include "libANGLE/renderer/d3d/RendererD3D.h" +#include "libANGLE/renderer/d3d/TextureD3D.h" +#include "libANGLE/renderer/d3d/TextureStorage.h" + +#include <EGL/eglext.h> + +namespace rx +{ + +EGLImageD3D::EGLImageD3D(const egl::ImageState &state, + EGLenum target, + const egl::AttributeMap &attribs, + RendererD3D *renderer) + : ImageImpl(state), mRenderer(renderer), mRenderTarget(nullptr) +{ + ASSERT(renderer != nullptr); +} + +EGLImageD3D::~EGLImageD3D() +{ + SafeDelete(mRenderTarget); +} + +egl::Error EGLImageD3D::initialize(const egl::Display *display) +{ + return egl::NoError(); +} + +angle::Result EGLImageD3D::orphan(const gl::Context *context, egl::ImageSibling *sibling) +{ + if (sibling == mState.source) + { + ANGLE_TRY(copyToLocalRendertarget(context)); + } + + return angle::Result::Continue; +} + +angle::Result EGLImageD3D::getRenderTarget(const gl::Context *context, + RenderTargetD3D **outRT) const +{ + if (mState.source != nullptr) + { + ASSERT(!mRenderTarget); + FramebufferAttachmentRenderTarget *rt = nullptr; + ANGLE_TRY( + mState.source->getAttachmentRenderTarget(context, GL_NONE, mState.imageIndex, 0, &rt)); + *outRT = static_cast<RenderTargetD3D *>(rt); + return angle::Result::Continue; + } + + ASSERT(mRenderTarget); + *outRT = mRenderTarget; + return angle::Result::Continue; +} + +angle::Result EGLImageD3D::copyToLocalRendertarget(const gl::Context *context) +{ + ASSERT(mState.source != nullptr); + ASSERT(mRenderTarget == nullptr); + + RenderTargetD3D *curRenderTarget = nullptr; + ANGLE_TRY(getRenderTarget(context, &curRenderTarget)); + + { + std::unique_lock lock(mState.targetsLock); + // Invalidate FBOs with this Image attached. Only currently applies to D3D11. + for (egl::ImageSibling *target : mState.targets) + { + target->onStateChange(angle::SubjectMessage::SubjectChanged); + } + } + + return mRenderer->createRenderTargetCopy(context, curRenderTarget, &mRenderTarget); +} +} // namespace rx |