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 09:20:52 +00: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 23:17:23 +00:00
|
|
|
#include "GLContext.h" // for GLContext, etc
|
2014-01-10 13:06:06 +00:00
|
|
|
#include "SurfaceStream.h"
|
2013-08-11 23:17:23 +00:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
2014-01-10 13:06:06 +00:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
2013-08-11 23:17:23 +00: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 09:20:52 +00:00
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-11 23:17:23 +00:00
|
|
|
class CompositableForwarder;
|
|
|
|
|
2013-08-27 20:16:54 +00:00
|
|
|
SharedTextureClientOGL::SharedTextureClientOGL(TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
|
|
|
, mHandle(0)
|
2013-08-08 12:53:12 +00:00
|
|
|
, mInverted(false)
|
2013-07-30 09:59:51 +00:00
|
|
|
{
|
2013-10-02 20:52:04 +00:00
|
|
|
// SharedTextureClient is always owned externally.
|
|
|
|
mFlags |= TEXTURE_DEALLOCATE_CLIENT;
|
2013-07-30 09:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SharedTextureClientOGL::~SharedTextureClientOGL()
|
|
|
|
{
|
2013-10-02 20:52:04 +00:00
|
|
|
// the shared data is owned externally.
|
2013-07-30 09:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SharedTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
2013-09-06 09:04:50 +00:00
|
|
|
MOZ_ASSERT(IsValid());
|
2013-07-30 09:59:51 +00:00
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-31 09:06:12 +00:00
|
|
|
aOutDescriptor = SharedTextureDescriptor(mShareType, mHandle, mSize, mInverted);
|
2013-07-30 09:59:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedTextureClientOGL::InitWith(gl::SharedTextureHandle aHandle,
|
|
|
|
gfx::IntSize aSize,
|
2013-09-04 12:14:52 +00:00
|
|
|
gl::SharedTextureShareType aShareType,
|
2013-07-30 09:59:51 +00:00
|
|
|
bool aInverted)
|
|
|
|
{
|
2013-09-06 09:04:50 +00:00
|
|
|
MOZ_ASSERT(IsValid());
|
2013-07-30 09:59:51 +00:00
|
|
|
MOZ_ASSERT(!IsAllocated());
|
|
|
|
mHandle = aHandle;
|
|
|
|
mSize = aSize;
|
2013-08-27 20:16:54 +00:00
|
|
|
mShareType = aShareType;
|
2013-07-30 09:59:51 +00:00
|
|
|
mInverted = aInverted;
|
2013-10-10 01:20:57 +00:00
|
|
|
if (mInverted) {
|
|
|
|
AddFlags(TEXTURE_NEEDS_Y_FLIP);
|
|
|
|
}
|
2013-07-30 09:59:51 +00:00
|
|
|
}
|
|
|
|
|
2014-01-24 14:25:04 +00:00
|
|
|
bool
|
|
|
|
SharedTextureClientOGL::Lock(OpenMode mode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SharedTextureClientOGL::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
2013-07-30 09:59:51 +00:00
|
|
|
bool
|
|
|
|
SharedTextureClientOGL::IsAllocated() const
|
|
|
|
{
|
|
|
|
return mHandle != 0;
|
|
|
|
}
|
|
|
|
|
2014-01-10 13:06:06 +00:00
|
|
|
StreamTextureClientOGL::StreamTextureClientOGL(TextureFlags aFlags)
|
|
|
|
: TextureClient(aFlags)
|
2014-01-24 14:25:04 +00:00
|
|
|
, mIsLocked(false)
|
2014-01-10 13:06:06 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamTextureClientOGL::~StreamTextureClientOGL()
|
|
|
|
{
|
|
|
|
// the data is owned externally.
|
|
|
|
}
|
|
|
|
|
2014-01-24 14:25:04 +00:00
|
|
|
bool
|
|
|
|
StreamTextureClientOGL::Lock(OpenMode mode)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsLocked);
|
|
|
|
if (!IsValid() || !IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mIsLocked = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamTextureClientOGL::Unlock()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mIsLocked);
|
|
|
|
mIsLocked = false;
|
|
|
|
}
|
|
|
|
|
2014-01-10 13:06:06 +00:00
|
|
|
bool
|
|
|
|
StreamTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
|
|
|
{
|
|
|
|
if (!IsAllocated()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::SurfaceStreamHandle handle = mStream->GetShareHandle();
|
|
|
|
aOutDescriptor = SurfaceStreamDescriptor(handle, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamTextureClientOGL::InitWith(gfx::SurfaceStream* aStream)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!IsAllocated());
|
|
|
|
mStream = aStream;
|
2014-03-05 21:49:37 +00:00
|
|
|
mGL = mStream->GLContext();
|
2014-01-10 13:06:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StreamTextureClientOGL::IsAllocated() const
|
|
|
|
{
|
|
|
|
return mStream != 0;
|
|
|
|
}
|
|
|
|
|
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 09:20:52 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|