mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 02:47:31 +09:00
Issue #1053 - Part 3a: Remove Android conditionals from /gfx
This commit is contained in:
parent
7167c960d0
commit
753251e54c
43 changed files with 32 additions and 1708 deletions
|
|
@ -43,10 +43,6 @@
|
|||
#include "GLBlitTextureImageHelper.h"
|
||||
#include "HeapCopyOfStackArray.h"
|
||||
|
||||
#if MOZ_WIDGET_ANDROID
|
||||
#include "TexturePoolOGL.h"
|
||||
#endif
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
@ -229,13 +225,6 @@ CompositorOGL::Initialize(nsCString* const out_failureReason)
|
|||
|
||||
mGLContext = CreateContext();
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (!mGLContext){
|
||||
*out_failureReason = "FEATURE_FAILURE_OPENGL_NO_ANDROID_CONTEXT";
|
||||
NS_RUNTIMEABORT("We need a context on Android");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mGLContext){
|
||||
*out_failureReason = "FEATURE_FAILURE_OPENGL_CREATE_CONTEXT";
|
||||
return false;
|
||||
|
|
@ -673,10 +662,6 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
|
|||
mPixelsPerFrame = width * height;
|
||||
mPixelsFilled = 0;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
TexturePoolOGL::Fill(gl());
|
||||
#endif
|
||||
|
||||
// Default blend function implements "OVER"
|
||||
mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
|
@ -1707,19 +1692,13 @@ CompositorOGL::CopyToTarget(DrawTarget* aTarget, const nsIntPoint& aTopLeft, con
|
|||
void
|
||||
CompositorOGL::Pause()
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (!gl() || gl()->IsDestroyed())
|
||||
return;
|
||||
|
||||
// ReleaseSurface internally calls MakeCurrent.
|
||||
gl()->ReleaseSurface();
|
||||
#endif
|
||||
// This was only used on Android
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorOGL::Resume()
|
||||
{
|
||||
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_UIKIT)
|
||||
#if defined(MOZ_WIDGET_UIKIT)
|
||||
if (!gl() || gl()->IsDestroyed())
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -73,64 +73,5 @@ EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -48,41 +48,6 @@ protected:
|
|||
const gfx::IntSize mSize;
|
||||
};
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
class AndroidSurfaceTextureData : public TextureData
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<TextureClient>
|
||||
CreateTextureClient(gl::AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::IntSize aSize,
|
||||
gl::OriginPos aOriginPos,
|
||||
LayersIPCChannel* aAllocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
~AndroidSurfaceTextureData();
|
||||
|
||||
virtual void FillInfo(TextureData::Info& aInfo) const override;
|
||||
|
||||
virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
|
||||
|
||||
// Useless functions.
|
||||
virtual bool Lock(OpenMode) override { return true; }
|
||||
|
||||
virtual void Unlock() override {}
|
||||
|
||||
// Our data is always owned externally.
|
||||
virtual void Deallocate(LayersIPCChannel*) override {}
|
||||
|
||||
protected:
|
||||
AndroidSurfaceTextureData(gl::AndroidSurfaceTexture* aSurfTex, gfx::IntSize aSize);
|
||||
|
||||
const RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
|
||||
const gfx::IntSize mSize;
|
||||
};
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
|||
|
|
@ -40,16 +40,6 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
|||
{
|
||||
RefPtr<TextureHost> result;
|
||||
switch (aDesc.type()) {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
case SurfaceDescriptor::TSurfaceTextureDescriptor: {
|
||||
const SurfaceTextureDescriptor& desc = aDesc.get_SurfaceTextureDescriptor();
|
||||
result = new SurfaceTextureHost(aFlags,
|
||||
(AndroidSurfaceTexture*)desc.surfTex(),
|
||||
desc.size());
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case SurfaceDescriptor::TEGLImageDescriptor: {
|
||||
const EGLImageDescriptor& desc = aDesc.get_EGLImageDescriptor();
|
||||
result = new EGLImageTextureHost(aFlags,
|
||||
|
|
@ -346,177 +336,6 @@ GLTextureSource::gl() const
|
|||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SurfaceTextureHost
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
SurfaceTextureSource::SurfaceTextureSource(CompositorOGL* aCompositor,
|
||||
AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
GLenum aWrapMode,
|
||||
gfx::IntSize aSize)
|
||||
: mCompositor(aCompositor)
|
||||
, mSurfTex(aSurfTex)
|
||||
, mFormat(aFormat)
|
||||
, mTextureTarget(aTarget)
|
||||
, mWrapMode(aWrapMode)
|
||||
, mSize(aSize)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureSource::BindTexture(GLenum aTextureUnit,
|
||||
gfx::SamplingFilter aSamplingFilter)
|
||||
{
|
||||
MOZ_ASSERT(mSurfTex);
|
||||
GLContext* gl = this->gl();
|
||||
if (!gl || !gl->MakeCurrent()) {
|
||||
NS_WARNING("Trying to bind a texture without a GLContext");
|
||||
return;
|
||||
}
|
||||
|
||||
gl->fActiveTexture(aTextureUnit);
|
||||
|
||||
// SurfaceTexture spams us if there are any existing GL errors, so
|
||||
// we'll clear them here in order to avoid that.
|
||||
gl->FlushErrors();
|
||||
|
||||
mSurfTex->UpdateTexImage();
|
||||
|
||||
ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, mTextureTarget);
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureSource::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
if (mCompositor != glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
}
|
||||
|
||||
mCompositor = glCompositor;
|
||||
}
|
||||
|
||||
bool
|
||||
SurfaceTextureSource::IsValid() const
|
||||
{
|
||||
return !!gl();
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
SurfaceTextureSource::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
gfx::Matrix4x4
|
||||
SurfaceTextureSource::GetTextureTransform()
|
||||
{
|
||||
MOZ_ASSERT(mSurfTex);
|
||||
|
||||
gfx::Matrix4x4 ret;
|
||||
mSurfTex->GetTransformMatrix(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureSource::DeallocateDeviceData()
|
||||
{
|
||||
mSurfTex = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
|
||||
AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::IntSize aSize)
|
||||
: TextureHost(aFlags)
|
||||
, mSurfTex(aSurfTex)
|
||||
, mSize(aSize)
|
||||
, mCompositor(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SurfaceTextureHost::~SurfaceTextureHost()
|
||||
{
|
||||
}
|
||||
|
||||
gl::GLContext*
|
||||
SurfaceTextureHost::gl() const
|
||||
{
|
||||
return mCompositor ? mCompositor->gl() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
SurfaceTextureHost::Lock()
|
||||
{
|
||||
MOZ_ASSERT(mSurfTex);
|
||||
GLContext* gl = this->gl();
|
||||
if (!gl || !gl->MakeCurrent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mTextureSource) {
|
||||
gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
|
||||
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL;
|
||||
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
|
||||
mTextureSource = new SurfaceTextureSource(mCompositor,
|
||||
mSurfTex,
|
||||
format,
|
||||
target,
|
||||
wrapMode,
|
||||
mSize);
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(mSurfTex->Attach(gl));
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureHost::Unlock()
|
||||
{
|
||||
MOZ_ASSERT(mSurfTex);
|
||||
mSurfTex->Detach();
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
|
||||
if (!glCompositor) {
|
||||
DeallocateDeviceData();
|
||||
return;
|
||||
}
|
||||
mCompositor = glCompositor;
|
||||
if (mTextureSource) {
|
||||
mTextureSource->SetCompositor(glCompositor);
|
||||
}
|
||||
}
|
||||
|
||||
gfx::SurfaceFormat
|
||||
SurfaceTextureHost::GetFormat() const
|
||||
{
|
||||
return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
|
||||
}
|
||||
|
||||
void
|
||||
SurfaceTextureHost::DeallocateDeviceData()
|
||||
{
|
||||
if (mTextureSource) {
|
||||
mTextureSource->DeallocateDeviceData();
|
||||
}
|
||||
mSurfTex = nullptr;
|
||||
}
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EGLImage
|
||||
|
|
|
|||
|
|
@ -335,103 +335,6 @@ protected:
|
|||
RefPtr<GLTextureSource> mTextureSource;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// SurfaceTexture
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
|
||||
class SurfaceTextureSource : public TextureSource
|
||||
, public TextureSourceOGL
|
||||
{
|
||||
public:
|
||||
SurfaceTextureSource(CompositorOGL* aCompositor,
|
||||
mozilla::gl::AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
GLenum aTarget,
|
||||
GLenum aWrapMode,
|
||||
gfx::IntSize aSize);
|
||||
|
||||
virtual const char* Name() const override { return "SurfaceTextureSource"; }
|
||||
|
||||
virtual TextureSourceOGL* AsSourceOGL() override { return this; }
|
||||
|
||||
virtual void BindTexture(GLenum activetex,
|
||||
gfx::SamplingFilter aSamplingFilter) override;
|
||||
|
||||
virtual bool IsValid() const override;
|
||||
|
||||
virtual gfx::IntSize GetSize() const override { return mSize; }
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
|
||||
|
||||
virtual gfx::Matrix4x4 GetTextureTransform() override;
|
||||
|
||||
virtual GLenum GetTextureTarget() const override { return mTextureTarget; }
|
||||
|
||||
virtual GLenum GetWrapMode() const override { return mWrapMode; }
|
||||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
protected:
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
|
||||
const gfx::SurfaceFormat mFormat;
|
||||
const GLenum mTextureTarget;
|
||||
const GLenum mWrapMode;
|
||||
const gfx::IntSize mSize;
|
||||
};
|
||||
|
||||
class SurfaceTextureHost : public TextureHost
|
||||
{
|
||||
public:
|
||||
SurfaceTextureHost(TextureFlags aFlags,
|
||||
mozilla::gl::AndroidSurfaceTexture* aSurfTex,
|
||||
gfx::IntSize aSize);
|
||||
|
||||
virtual ~SurfaceTextureHost();
|
||||
|
||||
virtual void DeallocateDeviceData() override;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) override;
|
||||
|
||||
virtual Compositor* GetCompositor() override { return mCompositor; }
|
||||
|
||||
virtual bool Lock() override;
|
||||
|
||||
virtual void Unlock() override;
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const override;
|
||||
|
||||
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
|
||||
{
|
||||
aTexture = mTextureSource;
|
||||
return !!aTexture;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override
|
||||
{
|
||||
return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
|
||||
}
|
||||
|
||||
gl::GLContext* gl() const;
|
||||
|
||||
virtual gfx::IntSize GetSize() const override { return mSize; }
|
||||
|
||||
virtual const char* Name() override { return "SurfaceTextureHost"; }
|
||||
|
||||
protected:
|
||||
RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
|
||||
const gfx::IntSize mSize;
|
||||
RefPtr<CompositorOGL> mCompositor;
|
||||
RefPtr<SurfaceTextureSource> mTextureSource;
|
||||
};
|
||||
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// EGLImage
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue