diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /gfx/layers/opengl/TextureClientOGL.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/layers/opengl/TextureClientOGL.cpp')
-rw-r--r-- | gfx/layers/opengl/TextureClientOGL.cpp | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp new file mode 100644 index 000000000..78d4e6d9c --- /dev/null +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "GLContext.h" // for GLContext, etc +#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc +#include "mozilla/layers/ISurfaceAllocator.h" +#include "mozilla/layers/TextureClientOGL.h" +#include "mozilla/gfx/Point.h" // for IntSize +#include "GLLibraryEGL.h" + +using namespace mozilla::gl; + +namespace mozilla { +namespace layers { + +class CompositableForwarder; + +//////////////////////////////////////////////////////////////////////// +// EGLImage + +EGLImageTextureData::EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize) +: mImage(aImage) +, mSize(aSize) +{ + MOZ_ASSERT(aImage); +} + +already_AddRefed<TextureClient> +EGLImageTextureData::CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize, + LayersIPCChannel* aAllocator, TextureFlags aFlags) +{ + MOZ_ASSERT(XRE_IsParentProcess(), + "Can't pass an `EGLImage` between processes."); + + if (!aImage || !XRE_IsParentProcess()) { + return nullptr; + } + + // XXX - This is quite sad and slow. + aFlags |= TextureFlags::DEALLOCATE_CLIENT; + + if (aImage->GetOriginPos() == gl::OriginPos::BottomLeft) { + aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT; + } + + return TextureClient::CreateWithData( + new EGLImageTextureData(aImage, aSize), + aFlags, aAllocator + ); +} + +void +EGLImageTextureData::FillInfo(TextureData::Info& aInfo) const +{ + aInfo.size = mSize; + aInfo.format = gfx::SurfaceFormat::UNKNOWN; + aInfo.hasIntermediateBuffer = false; + aInfo.hasSynchronization = false; + aInfo.supportsMoz2D = false; + aInfo.canExposeMappedData = false; +} + +bool +EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) +{ + const bool hasAlpha = true; + aOutDescriptor = + EGLImageDescriptor((uintptr_t)mImage->GetImage(), + (uintptr_t)mImage->GetSync(), + mImage->GetSize(), hasAlpha); + return true; +} + +//////////////////////////////////////////////////////////////////////// +// AndroidSurface + +#ifdef MOZ_WIDGET_ANDROID + +already_AddRefed<TextureClient> +AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTexture* aSurfTex, + gfx::IntSize aSize, + gl::OriginPos aOriginPos, + LayersIPCChannel* aAllocator, + TextureFlags aFlags) +{ + MOZ_ASSERT(XRE_IsParentProcess(), + "Can't pass an android surfaces between processes."); + + if (!aSurfTex || !XRE_IsParentProcess()) { + return nullptr; + } + + if (aOriginPos == gl::OriginPos::BottomLeft) { + aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT; + } + + return TextureClient::CreateWithData( + new AndroidSurfaceTextureData(aSurfTex, aSize), + aFlags, aAllocator + ); +} + +AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTexture* aSurfTex, + gfx::IntSize aSize) + : mSurfTex(aSurfTex) + , mSize(aSize) +{} + +AndroidSurfaceTextureData::~AndroidSurfaceTextureData() +{} + +void +AndroidSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const +{ + aInfo.size = mSize; + aInfo.format = gfx::SurfaceFormat::UNKNOWN; + aInfo.hasIntermediateBuffer = false; + aInfo.hasSynchronization = false; + aInfo.supportsMoz2D = false; + aInfo.canExposeMappedData = false; +} + +bool +AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) +{ + aOutDescriptor = SurfaceTextureDescriptor((uintptr_t)mSurfTex.get(), + mSize); + return true; +} + +#endif // MOZ_WIDGET_ANDROID + +} // namespace layers +} // namespace mozilla |