Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "GLContext.h" // for GLContext, etc
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
2014-01-10 17:06:06 +04:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
2015-05-29 18:01:46 +03:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2014-11-27 00:16:07 +03:00
|
|
|
#include "GLLibraryEGL.h"
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class CompositableForwarder;
|
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2015-11-20 16:24:49 +03:00
|
|
|
// EGLImage
|
2015-11-24 21:07:02 +03:00
|
|
|
|
2015-11-20 16:24:49 +03:00
|
|
|
EGLImageTextureData::EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize)
|
|
|
|
: mImage(aImage)
|
|
|
|
, mSize(aSize)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<TextureClient>
|
|
|
|
EGLImageTextureData::CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize,
|
2016-09-27 06:22:20 +03:00
|
|
|
LayersIPCChannel* aAllocator, TextureFlags aFlags)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
MOZ_ASSERT(XRE_IsParentProcess(),
|
2014-09-17 17:13:29 +04:00
|
|
|
"Can't pass an `EGLImage` between processes.");
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2015-11-20 16:24:49 +03:00
|
|
|
if (!aImage || !XRE_IsParentProcess()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX - This is quite sad and slow.
|
|
|
|
aFlags |= TextureFlags::DEALLOCATE_CLIENT;
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2015-11-17 11:09:00 +03:00
|
|
|
if (aImage->GetOriginPos() == gl::OriginPos::BottomLeft) {
|
2015-11-20 16:24:49 +03:00
|
|
|
aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
|
2014-09-17 17:13:29 +04:00
|
|
|
}
|
2015-11-20 16:24:49 +03:00
|
|
|
|
|
|
|
return TextureClient::CreateWithData(
|
|
|
|
new EGLImageTextureData(aImage, aSize),
|
|
|
|
aFlags, aAllocator
|
|
|
|
);
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2016-04-22 19:05:26 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
bool
|
2015-11-20 16:24:49 +03:00
|
|
|
EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2015-06-05 03:15:38 +03:00
|
|
|
const bool hasAlpha = true;
|
2015-11-17 11:09:00 +03:00
|
|
|
aOutDescriptor =
|
|
|
|
EGLImageDescriptor((uintptr_t)mImage->GetImage(),
|
|
|
|
(uintptr_t)mImage->GetSync(),
|
|
|
|
mImage->GetSize(), hasAlpha);
|
2013-07-30 13:59:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2015-11-20 16:24:52 +03:00
|
|
|
// AndroidSurface
|
2014-09-17 17:13:29 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
|
2015-11-20 16:24:52 +03:00
|
|
|
already_AddRefed<TextureClient>
|
|
|
|
AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTexture* aSurfTex,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
gl::OriginPos aOriginPos,
|
2016-09-27 06:22:20 +03:00
|
|
|
LayersIPCChannel* aAllocator,
|
2015-11-20 16:24:52 +03:00
|
|
|
TextureFlags aFlags)
|
2014-09-17 17:13:29 +04:00
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
MOZ_ASSERT(XRE_IsParentProcess(),
|
2015-11-20 16:24:52 +03:00
|
|
|
"Can't pass an android surfaces between processes.");
|
2014-09-17 17:13:29 +04:00
|
|
|
|
2015-11-20 16:24:52 +03:00
|
|
|
if (!aSurfTex || !XRE_IsParentProcess()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-11-18 04:02:19 +03:00
|
|
|
if (aOriginPos == gl::OriginPos::BottomLeft) {
|
2015-11-20 16:24:52 +03:00
|
|
|
aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
|
2013-10-10 05:20:57 +04:00
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-11-20 16:24:52 +03:00
|
|
|
return TextureClient::CreateWithData(
|
|
|
|
new AndroidSurfaceTextureData(aSurfTex, aSize),
|
|
|
|
aFlags, aAllocator
|
|
|
|
);
|
2015-11-24 21:07:02 +03:00
|
|
|
}
|
2014-01-24 18:25:04 +04:00
|
|
|
|
2015-11-20 16:24:52 +03:00
|
|
|
AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTexture* aSurfTex,
|
|
|
|
gfx::IntSize aSize)
|
|
|
|
: mSurfTex(aSurfTex)
|
|
|
|
, mSize(aSize)
|
|
|
|
{}
|
2015-11-24 21:07:02 +03:00
|
|
|
|
2015-11-20 16:24:52 +03:00
|
|
|
AndroidSurfaceTextureData::~AndroidSurfaceTextureData()
|
|
|
|
{}
|
2015-11-20 18:55:26 +03:00
|
|
|
|
2016-04-22 19:05:26 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-11-24 21:07:02 +03:00
|
|
|
bool
|
2015-11-20 16:24:52 +03:00
|
|
|
AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
2015-11-24 21:07:02 +03:00
|
|
|
{
|
2015-11-20 16:24:52 +03:00
|
|
|
aOutDescriptor = SurfaceTextureDescriptor((uintptr_t)mSurfTex.get(),
|
|
|
|
mSize);
|
2015-11-24 21:07:02 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|