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 02:20:52 -07: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-11 16:17:23 -07:00
|
|
|
#include "GLContext.h" // for GLContext, etc
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
2014-01-10 05:06:06 -08:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsSize.h" // for nsIntSize
|
2014-11-26 13:16:07 -08: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 02:20:52 -07:00
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
class CompositableForwarder;
|
|
|
|
|
2014-09-17 06:13:29 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// EGLImageTextureClient
|
|
|
|
|
2014-12-22 00:49:00 -08:00
|
|
|
EGLImageTextureClient::EGLImageTextureClient(ISurfaceAllocator* aAllocator,
|
|
|
|
TextureFlags aFlags,
|
2014-11-26 13:16:07 -08:00
|
|
|
EGLImageImage* aImage,
|
|
|
|
gfx::IntSize aSize)
|
2014-12-22 00:49:00 -08:00
|
|
|
: TextureClient(aAllocator, aFlags)
|
2014-09-17 06:13:29 -07:00
|
|
|
, mImage(aImage)
|
|
|
|
, mSize(aSize)
|
2014-08-27 09:12:51 -07:00
|
|
|
, mIsLocked(false)
|
2013-07-30 02:59:51 -07:00
|
|
|
{
|
2014-09-17 06:13:29 -07:00
|
|
|
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
|
|
|
|
"Can't pass an `EGLImage` between processes.");
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2014-09-17 06:13:29 -07:00
|
|
|
AddFlags(TextureFlags::DEALLOCATE_CLIENT);
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2014-11-17 17:02:19 -08:00
|
|
|
if (aImage->GetData()->mOriginPos == gl::OriginPos::BottomLeft) {
|
|
|
|
AddFlags(TextureFlags::ORIGIN_BOTTOM_LEFT);
|
2014-09-17 06:13:29 -07:00
|
|
|
}
|
2013-07-30 02:59:51 -07:00
|
|
|
}
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
bool
|
2014-09-17 06:13:29 -07:00
|
|
|
EGLImageTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
2013-07-30 02:59:51 -07:00
|
|
|
{
|
2013-09-06 02:04:50 -07:00
|
|
|
MOZ_ASSERT(IsValid());
|
2014-09-17 06:13:29 -07:00
|
|
|
MOZ_ASSERT(IsAllocated());
|
|
|
|
|
2014-11-26 13:16:07 -08:00
|
|
|
const EGLImageImage::Data* data = mImage->GetData();
|
|
|
|
aOutDescriptor = EGLImageDescriptor((uintptr_t)data->mImage, (uintptr_t)data->mSync, mSize);
|
2013-07-30 02:59:51 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-17 06:13:29 -07:00
|
|
|
bool
|
|
|
|
EGLImageTextureClient::Lock(OpenMode mode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2013-07-30 02:59:51 -07:00
|
|
|
void
|
2014-09-17 06:13:29 -07:00
|
|
|
EGLImageTextureClient::Unlock()
|
2013-07-30 02:59:51 -07:00
|
|
|
{
|
2014-09-17 06:13:29 -07:00
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2014-09-17 06:13:29 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// SurfaceTextureClient
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
|
2014-12-22 00:49:00 -08:00
|
|
|
SurfaceTextureClient::SurfaceTextureClient(ISurfaceAllocator* aAllocator,
|
|
|
|
TextureFlags aFlags,
|
2014-10-21 06:53:00 -07:00
|
|
|
AndroidSurfaceTexture* aSurfTex,
|
2014-09-17 06:13:29 -07:00
|
|
|
gfx::IntSize aSize,
|
2014-11-17 17:02:19 -08:00
|
|
|
gl::OriginPos aOriginPos)
|
2014-12-22 00:49:00 -08:00
|
|
|
: TextureClient(aAllocator, aFlags)
|
2014-09-17 06:13:29 -07:00
|
|
|
, 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);
|
|
|
|
|
2014-11-17 17:02:19 -08:00
|
|
|
if (aOriginPos == gl::OriginPos::BottomLeft) {
|
|
|
|
AddFlags(TextureFlags::ORIGIN_BOTTOM_LEFT);
|
2013-10-09 18:20:57 -07:00
|
|
|
}
|
2013-07-30 02:59:51 -07:00
|
|
|
}
|
2014-10-07 21:15:39 -07:00
|
|
|
|
2014-09-17 06:13:29 -07: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 02:59:51 -07:00
|
|
|
|
2014-01-24 06:25:04 -08:00
|
|
|
bool
|
2014-09-17 06:13:29 -07:00
|
|
|
SurfaceTextureClient::Lock(OpenMode mode)
|
2014-01-24 06:25:04 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-09-17 06:13:29 -07:00
|
|
|
SurfaceTextureClient::Unlock()
|
2014-01-24 06:25:04 -08:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
2014-09-17 06:13:29 -07:00
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
2013-07-30 02:59:51 -07: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 02:20:52 -07:00
|
|
|
} // namespace
|
|
|
|
} // namespace
|