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"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsSize.h" // for nsIntSize
|
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
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// EGLImageTextureClient
|
|
|
|
|
|
|
|
EGLImageTextureClient::EGLImageTextureClient(TextureFlags aFlags,
|
|
|
|
EGLImage aImage,
|
|
|
|
gfx::IntSize aSize,
|
|
|
|
bool aInverted)
|
2013-08-28 00:16:54 +04:00
|
|
|
: TextureClient(aFlags)
|
2014-09-17 17:13:29 +04:00
|
|
|
, mImage(aImage)
|
|
|
|
, mSize(aSize)
|
2014-08-27 20:12:51 +04:00
|
|
|
, mIsLocked(false)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2014-09-17 17:13:29 +04:00
|
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
|
|
|
|
"Can't pass an `EGLImage` between processes.");
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
// Our data is always owned externally.
|
|
|
|
AddFlags(TextureFlags::DEALLOCATE_CLIENT);
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
if (aInverted) {
|
|
|
|
AddFlags(TextureFlags::NEEDS_Y_FLIP);
|
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
EGLImageTextureClient::~EGLImageTextureClient()
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2014-09-17 17:13:29 +04:00
|
|
|
// Our data is always owned externally.
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-09-17 17:13:29 +04:00
|
|
|
EGLImageTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2013-09-06 13:04:50 +04:00
|
|
|
MOZ_ASSERT(IsValid());
|
2014-09-17 17:13:29 +04:00
|
|
|
MOZ_ASSERT(IsAllocated());
|
|
|
|
|
|
|
|
aOutDescriptor = EGLImageDescriptor((uintptr_t)mImage, mSize);
|
2013-07-30 13:59:51 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
bool
|
|
|
|
EGLImageTextureClient::Lock(OpenMode mode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
void
|
2014-09-17 17:13:29 +04:00
|
|
|
EGLImageTextureClient::Unlock()
|
2013-07-30 13:59:51 +04:00
|
|
|
{
|
2014-09-17 17:13:29 +04:00
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// SurfaceTextureClient
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
|
|
|
|
SurfaceTextureClient::SurfaceTextureClient(TextureFlags aFlags,
|
2014-10-21 17:53:00 +04:00
|
|
|
AndroidSurfaceTexture* aSurfTex,
|
2014-09-17 17:13:29 +04:00
|
|
|
gfx::IntSize aSize,
|
|
|
|
bool aInverted)
|
|
|
|
: TextureClient(aFlags)
|
|
|
|
, mSurfTex(aSurfTex)
|
|
|
|
, mSize(aSize)
|
|
|
|
, mIsLocked(false)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
|
|
|
|
"Can't pass pointers between processes.");
|
|
|
|
|
|
|
|
// Our data is always owned externally.
|
|
|
|
AddFlags(TextureFlags::DEALLOCATE_CLIENT);
|
|
|
|
|
|
|
|
if (aInverted) {
|
2014-04-26 06:34:05 +04:00
|
|
|
AddFlags(TextureFlags::NEEDS_Y_FLIP);
|
2013-10-10 05:20:57 +04:00
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
}
|
2014-10-08 08:15:39 +04:00
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
SurfaceTextureClient::~SurfaceTextureClient()
|
|
|
|
{
|
|
|
|
// Our data is always owned externally.
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SurfaceTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsValid());
|
|
|
|
MOZ_ASSERT(IsAllocated());
|
|
|
|
|
|
|
|
aOutDescriptor = SurfaceTextureDescriptor((uintptr_t)mSurfTex.get(),
|
|
|
|
mSize);
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2014-01-24 18:25:04 +04:00
|
|
|
bool
|
2014-09-17 17:13:29 +04:00
|
|
|
SurfaceTextureClient::Lock(OpenMode mode)
|
2014-01-24 18:25:04 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-17 17:13:29 +04:00
|
|
|
SurfaceTextureClient::Unlock()
|
2014-01-24 18:25:04 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
2014-09-17 17:13:29 +04:00
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
2013-07-30 13:59:51 +04:00
|
|
|
|
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
|
|
|
} // namespace
|
|
|
|
} // namespace
|