mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989904 - Remove some of the deprecated backend-independent textures. r=mattwoodrow
This commit is contained in:
parent
2f7b2c6f99
commit
2ceec21089
@ -137,24 +137,6 @@ enum EffectTypes
|
||||
EFFECT_MAX //sentinel for the count of all effect types
|
||||
};
|
||||
|
||||
/**
|
||||
* The kind of memory held by the texture client/host pair. This will
|
||||
* determine how the texture client is drawn into and how the memory
|
||||
* is shared between client and host.
|
||||
*/
|
||||
enum DeprecatedTextureClientType
|
||||
{
|
||||
TEXTURE_CONTENT, // dynamically drawn content
|
||||
TEXTURE_SHMEM, // shared memory
|
||||
TEXTURE_YCBCR, // Deprecated YCbCr texture
|
||||
TEXTURE_SHARED_GL, // GLContext::SharedTextureHandle
|
||||
TEXTURE_SHARED_GL_EXTERNAL, // GLContext::SharedTextureHandle, the ownership of
|
||||
// the SurfaceDescriptor passed to the texture
|
||||
// remains with whoever passed it.
|
||||
TEXTURE_STREAM_GL, // WebGL streaming buffer
|
||||
TEXTURE_FALLBACK // A fallback path appropriate for the platform
|
||||
};
|
||||
|
||||
/**
|
||||
* How the Compositable should manage textures.
|
||||
*/
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "mozilla/gfx/Rect.h" // for Rect, IntRect
|
||||
#include "mozilla/gfx/Types.h" // for ExtendMode::ExtendMode::CLAMP, etc
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowableLayer
|
||||
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient
|
||||
#include "mozilla/layers/TextureClient.h" // for TextureClient
|
||||
#include "nsSize.h" // for nsIntSize
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
@ -289,9 +289,6 @@ BorrowDrawTarget::ReturnDrawTarget(gfx::DrawTarget*& aReturned)
|
||||
gfxContentType
|
||||
RotatedContentBuffer::BufferContentType()
|
||||
{
|
||||
if (mDeprecatedBufferProvider) {
|
||||
return mDeprecatedBufferProvider->GetContentType();
|
||||
}
|
||||
if (mBufferProvider || mDTBuffer) {
|
||||
SurfaceFormat format;
|
||||
|
||||
@ -319,9 +316,7 @@ RotatedContentBuffer::EnsureBuffer()
|
||||
{
|
||||
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
||||
if (!mDTBuffer) {
|
||||
if (mDeprecatedBufferProvider) {
|
||||
mDTBuffer = mDeprecatedBufferProvider->LockDrawTarget();
|
||||
} else if (mBufferProvider) {
|
||||
if (mBufferProvider) {
|
||||
mDTBuffer = mBufferProvider->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
}
|
||||
@ -335,9 +330,7 @@ RotatedContentBuffer::EnsureBufferOnWhite()
|
||||
{
|
||||
NS_ASSERTION(!mLoanedDrawTarget, "Loaned draw target must be returned");
|
||||
if (!mDTBufferOnWhite) {
|
||||
if (mDeprecatedBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = mDeprecatedBufferProviderOnWhite->LockDrawTarget();
|
||||
} else if (mBufferProviderOnWhite) {
|
||||
if (mBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite =
|
||||
mBufferProviderOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
||||
}
|
||||
@ -350,13 +343,13 @@ RotatedContentBuffer::EnsureBufferOnWhite()
|
||||
bool
|
||||
RotatedContentBuffer::HaveBuffer() const
|
||||
{
|
||||
return mDTBuffer || mDeprecatedBufferProvider || mBufferProvider;
|
||||
return mDTBuffer || mBufferProvider;
|
||||
}
|
||||
|
||||
bool
|
||||
RotatedContentBuffer::HaveBufferOnWhite() const
|
||||
{
|
||||
return mDTBufferOnWhite || mDeprecatedBufferProviderOnWhite || mBufferProviderOnWhite;
|
||||
return mDTBufferOnWhite || mBufferProviderOnWhite;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -30,7 +30,6 @@ class Matrix;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class DeprecatedTextureClient;
|
||||
class TextureClient;
|
||||
class ThebesLayer;
|
||||
|
||||
@ -174,9 +173,7 @@ public:
|
||||
};
|
||||
|
||||
RotatedContentBuffer(BufferSizePolicy aBufferSizePolicy)
|
||||
: mDeprecatedBufferProvider(nullptr)
|
||||
, mDeprecatedBufferProviderOnWhite(nullptr)
|
||||
, mBufferProvider(nullptr)
|
||||
: mBufferProvider(nullptr)
|
||||
, mBufferProviderOnWhite(nullptr)
|
||||
, mBufferSizePolicy(aBufferSizePolicy)
|
||||
{
|
||||
@ -195,8 +192,6 @@ public:
|
||||
{
|
||||
mDTBuffer = nullptr;
|
||||
mDTBufferOnWhite = nullptr;
|
||||
mDeprecatedBufferProvider = nullptr;
|
||||
mDeprecatedBufferProviderOnWhite = nullptr;
|
||||
mBufferProvider = nullptr;
|
||||
mBufferProviderOnWhite = nullptr;
|
||||
mBufferRect.SetEmpty();
|
||||
@ -316,47 +311,12 @@ protected:
|
||||
return tmp.forget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the texture client only. This is used with surfaces that
|
||||
* require explicit lock/unlock, which |aClient| is used to do on
|
||||
* demand in this code.
|
||||
*
|
||||
* It's the caller's responsibility to ensure |aClient| is valid
|
||||
* for the duration of operations it requests of this
|
||||
* RotatedContentBuffer. It's also the caller's responsibility to
|
||||
* unset the provider when inactive, by calling
|
||||
* SetBufferProvider(nullptr).
|
||||
*/
|
||||
void SetDeprecatedBufferProvider(DeprecatedTextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBuffer) && !mBufferProvider);
|
||||
|
||||
mDeprecatedBufferProvider = aClient;
|
||||
if (!mDeprecatedBufferProvider) {
|
||||
mDTBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SetDeprecatedBufferProviderOnWhite(DeprecatedTextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBufferOnWhite) && !mBufferProviderOnWhite);
|
||||
|
||||
mDeprecatedBufferProviderOnWhite = aClient;
|
||||
if (!mDeprecatedBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// new texture client versions
|
||||
void SetBufferProvider(TextureClient* aClient)
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBuffer) && !mDeprecatedBufferProvider);
|
||||
MOZ_ASSERT(!aClient || !mDTBuffer);
|
||||
|
||||
mBufferProvider = aClient;
|
||||
if (!mBufferProvider) {
|
||||
@ -368,12 +328,12 @@ protected:
|
||||
{
|
||||
// Only this buffer provider can give us a buffer. If we
|
||||
// already have one, something has gone wrong.
|
||||
MOZ_ASSERT((!aClient || !mDTBufferOnWhite) && !mDeprecatedBufferProviderOnWhite);
|
||||
MOZ_ASSERT(!aClient || !mDTBufferOnWhite);
|
||||
|
||||
mBufferProviderOnWhite = aClient;
|
||||
if (!mBufferProviderOnWhite) {
|
||||
mDTBufferOnWhite = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,8 +392,6 @@ protected:
|
||||
* when we're using surfaces that require explicit map/unmap. Only one
|
||||
* may be used at a time.
|
||||
*/
|
||||
DeprecatedTextureClient* mDeprecatedBufferProvider;
|
||||
DeprecatedTextureClient* mDeprecatedBufferProviderOnWhite;
|
||||
TextureClient* mBufferProvider;
|
||||
TextureClient* mBufferProviderOnWhite;
|
||||
|
||||
|
@ -92,74 +92,6 @@ CompositableChild::Destroy()
|
||||
Send__delete__(this);
|
||||
}
|
||||
|
||||
TemporaryRef<DeprecatedTextureClient>
|
||||
CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
|
||||
gfxContentType aContentType)
|
||||
{
|
||||
MOZ_ASSERT(GetForwarder(), "Can't create a texture client if the compositable is not connected to the compositor.");
|
||||
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
|
||||
RefPtr<DeprecatedTextureClient> result;
|
||||
|
||||
switch (aDeprecatedTextureClientType) {
|
||||
case TEXTURE_SHARED_GL:
|
||||
case TEXTURE_SHARED_GL_EXTERNAL:
|
||||
case TEXTURE_STREAM_GL:
|
||||
case TEXTURE_YCBCR:
|
||||
MOZ_CRASH("Unsupported. this should not be reached");
|
||||
break;
|
||||
case TEXTURE_CONTENT:
|
||||
#ifdef XP_WIN
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D11 && gfxWindowsPlatform::GetPlatform()->GetD2DDevice()) {
|
||||
result = new DeprecatedTextureClientD3D11(GetForwarder(), GetTextureInfo());
|
||||
break;
|
||||
}
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D9 &&
|
||||
GetForwarder()->IsSameProcess()) {
|
||||
// We can't use a d3d9 texture for an RGBA surface because we cannot get a DC for
|
||||
// for a gfxWindowsSurface.
|
||||
// We have to wait for the compositor thread to create a d3d9 device before we
|
||||
// can create d3d9 textures on the main thread (because we need to reset on the
|
||||
// compositor thread, and the d3d9 device must be reset on the same thread it was
|
||||
// created on).
|
||||
if (aContentType == gfxContentType::COLOR_ALPHA ||
|
||||
!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
|
||||
result = new DeprecatedTextureClientDIB(GetForwarder(), GetTextureInfo());
|
||||
} else {
|
||||
result = new DeprecatedTextureClientD3D9(GetForwarder(), GetTextureInfo());
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
// fall through to TEXTURE_SHMEM
|
||||
case TEXTURE_SHMEM:
|
||||
result = new DeprecatedTextureClientShmem(GetForwarder(), GetTextureInfo());
|
||||
break;
|
||||
case TEXTURE_FALLBACK:
|
||||
#ifdef XP_WIN
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D11 ||
|
||||
parentBackend == LayersBackend::LAYERS_D3D9) {
|
||||
result = new DeprecatedTextureClientShmem(GetForwarder(), GetTextureInfo());
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unhandled texture client type");
|
||||
}
|
||||
|
||||
// If we couldn't create an appropriate texture client,
|
||||
// then return nullptr so the caller can chose another
|
||||
// type.
|
||||
if (!result) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(result->SupportsType(aDeprecatedTextureClientType),
|
||||
"Created the wrong texture client?");
|
||||
result->SetFlags(GetTextureInfo().mTextureFlags);
|
||||
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags,
|
||||
|
@ -81,10 +81,6 @@ public:
|
||||
|
||||
LayersBackend GetCompositorBackendType() const;
|
||||
|
||||
TemporaryRef<DeprecatedTextureClient>
|
||||
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
|
||||
gfxContentType aContentType = gfxContentType::SENTINEL);
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
|
||||
|
@ -869,341 +869,5 @@ BufferTextureClient::AllocateForYCbCr(gfx::IntSize aYSize,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DeprecatedTextureClient::DeprecatedTextureClient(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo)
|
||||
: mForwarder(aForwarder)
|
||||
, mTextureInfo(aTextureInfo)
|
||||
, mAccessMode(ACCESS_READ_WRITE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(DeprecatedTextureClient);
|
||||
}
|
||||
|
||||
DeprecatedTextureClient::~DeprecatedTextureClient()
|
||||
{
|
||||
MOZ_COUNT_DTOR(DeprecatedTextureClient);
|
||||
MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::T__None, "Need to release surface!");
|
||||
}
|
||||
|
||||
DeprecatedTextureClientShmem::DeprecatedTextureClientShmem(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo)
|
||||
: DeprecatedTextureClient(aForwarder, aTextureInfo)
|
||||
{
|
||||
}
|
||||
|
||||
DeprecatedTextureClientShmem::~DeprecatedTextureClientShmem()
|
||||
{
|
||||
ReleaseResources();
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureClientShmem::ReleaseResources()
|
||||
{
|
||||
if (mSurface) {
|
||||
mSurface = nullptr;
|
||||
mSurfaceAsImage = nullptr;
|
||||
|
||||
ShadowLayerForwarder::CloseDescriptor(mDescriptor);
|
||||
}
|
||||
|
||||
if (!(mTextureInfo.mTextureFlags & TEXTURE_DEALLOCATE_CLIENT)) {
|
||||
mDescriptor = SurfaceDescriptor();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSurfaceDescriptorValid(mDescriptor)) {
|
||||
mForwarder->DestroySharedSurface(&mDescriptor);
|
||||
mDescriptor = SurfaceDescriptor();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
DeprecatedTextureClientShmem::EnsureAllocated(gfx::IntSize aSize,
|
||||
gfxContentType aContentType)
|
||||
{
|
||||
if (aSize != mSize ||
|
||||
aContentType != mContentType ||
|
||||
!IsSurfaceDescriptorValid(mDescriptor)) {
|
||||
ReleaseResources();
|
||||
|
||||
mContentType = aContentType;
|
||||
mSize = aSize;
|
||||
|
||||
if (!mForwarder->AllocSurfaceDescriptor(mSize, mContentType,
|
||||
&mDescriptor)) {
|
||||
NS_WARNING("creating SurfaceDescriptor failed!");
|
||||
}
|
||||
if (mContentType == gfxContentType::COLOR_ALPHA) {
|
||||
gfxASurface* surface = GetSurface();
|
||||
if (!surface) {
|
||||
return false;
|
||||
}
|
||||
nsRefPtr<gfxContext> context = new gfxContext(surface);
|
||||
context->SetColor(gfxRGBA(0, 0, 0, 0));
|
||||
context->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
context->Paint();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureClientShmem::SetDescriptor(const SurfaceDescriptor& aDescriptor)
|
||||
{
|
||||
if (aDescriptor.type() == SurfaceDescriptor::Tnull_t) {
|
||||
EnsureAllocated(mSize, mContentType);
|
||||
return;
|
||||
}
|
||||
|
||||
ReleaseResources();
|
||||
mDescriptor = aDescriptor;
|
||||
|
||||
MOZ_ASSERT(!mSurface);
|
||||
NS_ASSERTION(mDescriptor.type() == SurfaceDescriptor::T__None ||
|
||||
mDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc ||
|
||||
mDescriptor.type() == SurfaceDescriptor::TShmem ||
|
||||
mDescriptor.type() == SurfaceDescriptor::TMemoryImage ||
|
||||
mDescriptor.type() == SurfaceDescriptor::TRGBImage,
|
||||
"Invalid surface descriptor");
|
||||
}
|
||||
|
||||
gfxASurface*
|
||||
DeprecatedTextureClientShmem::GetSurface()
|
||||
{
|
||||
if (!mSurface) {
|
||||
if (!IsSurfaceDescriptorValid(mDescriptor)) {
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(mAccessMode == ACCESS_READ_WRITE || mAccessMode == ACCESS_READ_ONLY);
|
||||
OpenMode mode = mAccessMode == ACCESS_READ_WRITE
|
||||
? OPEN_READ_WRITE
|
||||
: OPEN_READ_ONLY;
|
||||
mSurface = ShadowLayerForwarder::OpenDescriptor(mode, mDescriptor);
|
||||
MOZ_ASSERT(!mSurface || mSurface->GetContentType() == mContentType);
|
||||
}
|
||||
|
||||
return mSurface.get();
|
||||
}
|
||||
|
||||
|
||||
gfx::DrawTarget*
|
||||
DeprecatedTextureClientShmem::LockDrawTarget()
|
||||
{
|
||||
if (mDrawTarget) {
|
||||
return mDrawTarget;
|
||||
}
|
||||
|
||||
gfxASurface* surface = GetSurface();
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mDrawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surface, mSize);
|
||||
|
||||
return mDrawTarget;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureClientShmem::Unlock()
|
||||
{
|
||||
if (mSurface) {
|
||||
mSurface = nullptr;
|
||||
mSurfaceAsImage = nullptr;
|
||||
ShadowLayerForwarder::CloseDescriptor(mDescriptor);
|
||||
}
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
DeprecatedTextureClientShmem::LockImageSurface()
|
||||
{
|
||||
if (!mSurfaceAsImage) {
|
||||
gfxASurface* surface = GetSurface();
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
mSurfaceAsImage = surface->GetAsImageSurface();
|
||||
}
|
||||
|
||||
return mSurfaceAsImage.get();
|
||||
}
|
||||
|
||||
DeprecatedTextureClientTile::DeprecatedTextureClientTile(const DeprecatedTextureClientTile& aOther)
|
||||
: DeprecatedTextureClient(aOther.mForwarder, aOther.mTextureInfo)
|
||||
, mSurface(aOther.mSurface)
|
||||
{}
|
||||
|
||||
DeprecatedTextureClientTile::~DeprecatedTextureClientTile()
|
||||
{}
|
||||
|
||||
DeprecatedTextureClientTile::DeprecatedTextureClientTile(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo,
|
||||
gfxReusableSurfaceWrapper* aSurface)
|
||||
: DeprecatedTextureClient(aForwarder, aTextureInfo)
|
||||
, mSurface(aSurface)
|
||||
{
|
||||
mTextureInfo.mDeprecatedTextureHostFlags = TEXTURE_HOST_TILED;
|
||||
}
|
||||
|
||||
bool
|
||||
DeprecatedTextureClientTile::EnsureAllocated(gfx::IntSize aSize, gfxContentType aType)
|
||||
{
|
||||
if (!mSurface ||
|
||||
mSurface->Format() != gfxPlatform::GetPlatform()->OptimalFormatForContent(aType)) {
|
||||
#ifdef MOZ_ANDROID_OMTC
|
||||
// If we're using OMTC, we can save some cycles by not using shared
|
||||
// memory. Using shared memory here is a small, but significant
|
||||
// performance regression.
|
||||
gfxImageSurface* tmpTile = new gfxImageSurface(gfxIntSize(aSize.width, aSize.height),
|
||||
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType),
|
||||
aType != gfxContentType::COLOR);
|
||||
mSurface = new gfxReusableImageSurfaceWrapper(tmpTile);
|
||||
#else
|
||||
nsRefPtr<gfxSharedImageSurface> sharedImage =
|
||||
gfxSharedImageSurface::CreateUnsafe(mForwarder,
|
||||
gfxIntSize(aSize.width, aSize.height),
|
||||
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType));
|
||||
mSurface = new gfxReusableSharedImageSurfaceWrapper(mForwarder, sharedImage);
|
||||
#endif
|
||||
mContentType = aType;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
gfxImageSurface*
|
||||
DeprecatedTextureClientTile::LockImageSurface()
|
||||
{
|
||||
// Use the gfxReusableSurfaceWrapper, which will reuse the surface
|
||||
// if the compositor no longer has a read lock, otherwise the surface
|
||||
// will be copied into a new writable surface.
|
||||
gfxImageSurface* writableSurface = nullptr;
|
||||
mSurface = mSurface->GetWritable(&writableSurface);
|
||||
return writableSurface;
|
||||
}
|
||||
|
||||
// XXX - All the code below can be removed as soon as we remove
|
||||
// DeprecatedImageClientSingle (which has already been ported to the new
|
||||
// textures).
|
||||
|
||||
bool AutoLockShmemClient::Update(Image* aImage,
|
||||
uint32_t aContentFlags,
|
||||
gfxASurface *aSurface)
|
||||
{
|
||||
if (!aImage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::IntSize size = aImage->GetSize();
|
||||
|
||||
gfxContentType contentType = aSurface->GetContentType();
|
||||
bool isOpaque = (aContentFlags & Layer::CONTENT_OPAQUE);
|
||||
if (contentType != gfxContentType::ALPHA &&
|
||||
isOpaque) {
|
||||
contentType = gfxContentType::COLOR;
|
||||
}
|
||||
mDeprecatedTextureClient->EnsureAllocated(size, contentType);
|
||||
|
||||
OpenMode mode = mDeprecatedTextureClient->GetAccessMode() == DeprecatedTextureClient::ACCESS_READ_WRITE
|
||||
? OPEN_READ_WRITE
|
||||
: OPEN_READ_ONLY;
|
||||
nsRefPtr<gfxASurface> tmpASurface =
|
||||
ShadowLayerForwarder::OpenDescriptor(mode,
|
||||
*mDeprecatedTextureClient->LockSurfaceDescriptor());
|
||||
if (!tmpASurface) {
|
||||
return false;
|
||||
}
|
||||
nsRefPtr<gfxContext> tmpCtx = new gfxContext(tmpASurface.get());
|
||||
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
tmpCtx->DrawSurface(aSurface, gfxSize(size.width, size.height));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AutoLockYCbCrClient::Update(PlanarYCbCrImage* aImage)
|
||||
{
|
||||
MOZ_ASSERT(aImage);
|
||||
MOZ_ASSERT(mDescriptor);
|
||||
|
||||
const PlanarYCbCrData *data = aImage->GetData();
|
||||
NS_ASSERTION(data, "Must be able to retrieve yuv data from image!");
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureDeprecatedTextureClient(aImage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ipc::Shmem& shmem = mDescriptor->get_YCbCrImage().data();
|
||||
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>(), shmem.Size<uint8_t>());
|
||||
if (!serializer.CopyData(data->mYChannel, data->mCbChannel, data->mCrChannel,
|
||||
data->mYSize, data->mYStride,
|
||||
data->mCbCrSize, data->mCbCrStride,
|
||||
data->mYSkip, data->mCbSkip)) {
|
||||
NS_WARNING("Failed to copy image data!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AutoLockYCbCrClient::EnsureDeprecatedTextureClient(PlanarYCbCrImage* aImage)
|
||||
{
|
||||
MOZ_ASSERT(aImage);
|
||||
if (!aImage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const PlanarYCbCrData *data = aImage->GetData();
|
||||
NS_ASSERTION(data, "Must be able to retrieve yuv data from image!");
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool needsAllocation = false;
|
||||
if (mDescriptor->type() != SurfaceDescriptor::TYCbCrImage) {
|
||||
needsAllocation = true;
|
||||
} else {
|
||||
ipc::Shmem& shmem = mDescriptor->get_YCbCrImage().data();
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>(), shmem.Size<uint8_t>());
|
||||
if (serializer.GetYSize() != data->mYSize ||
|
||||
serializer.GetCbCrSize() != data->mCbCrSize) {
|
||||
needsAllocation = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!needsAllocation) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mDeprecatedTextureClient->ReleaseResources();
|
||||
|
||||
ipc::SharedMemory::SharedMemoryType shmType = OptimalShmemType();
|
||||
size_t size = YCbCrImageDataSerializer::ComputeMinBufferSize(data->mYSize,
|
||||
data->mCbCrSize);
|
||||
ipc::Shmem shmem;
|
||||
if (!mDeprecatedTextureClient->GetForwarder()->AllocUnsafeShmem(size, shmType, &shmem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YCbCrImageDataSerializer serializer(shmem.get<uint8_t>(), shmem.Size<uint8_t>());
|
||||
serializer.InitializeBufferInfo(data->mYSize,
|
||||
data->mCbCrSize,
|
||||
data->mStereoMode);
|
||||
|
||||
*mDescriptor = YCbCrImage(shmem, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -550,267 +550,6 @@ struct TextureClientAutoUnlock
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* XXX - This class is deprecated, will be removed soon.
|
||||
*
|
||||
* This class allows texture clients to draw into textures through Azure or
|
||||
* thebes and applies locking semantics to allow GPU or CPU level
|
||||
* synchronization.
|
||||
* DeprecatedTextureClient's purpose is for the texture data to be
|
||||
* forwarded to the right place on the compositor side and with correct locking
|
||||
* semantics.
|
||||
*
|
||||
* When modifying a DeprecatedTextureClient's data, first call LockDescriptor, modify the
|
||||
* data in the descriptor, and then call Unlock. This makes sure that if the
|
||||
* data is shared with the compositor, the later will not try to read while the
|
||||
* data is being modified (on the other side, DeprecatedTextureHost also has Lock/Unlock
|
||||
* semantics).
|
||||
* After unlocking, call Updated in order to add the modification to the current
|
||||
* layer transaction.
|
||||
* Depending on whether the data is shared or copied, Lock/Unlock and Updated
|
||||
* can be no-ops. What's important is that the Client/Host pair implement the
|
||||
* same semantics.
|
||||
*
|
||||
* Ownership of the surface descriptor depends on how the DeprecatedTextureClient/Host is
|
||||
* used by the CompositableClient/Host.
|
||||
*/
|
||||
class DeprecatedTextureClient : public RefCounted<DeprecatedTextureClient>
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(DeprecatedTextureClient)
|
||||
typedef gl::SharedTextureHandle SharedTextureHandle;
|
||||
typedef gl::GLContext GLContext;
|
||||
typedef gl::TextureImage TextureImage;
|
||||
|
||||
virtual ~DeprecatedTextureClient();
|
||||
|
||||
/* This will return an identifier that can be sent accross a process or
|
||||
* thread boundary and used to construct a DeprecatedTextureHost object
|
||||
* which can then be used as a texture for rendering by a compatible
|
||||
* compositor. This texture should have been created with the
|
||||
* DeprecatedTextureHostIdentifier specified by the compositor that this identifier
|
||||
* is to be used with.
|
||||
*/
|
||||
virtual const TextureInfo& GetTextureInfo() const
|
||||
{
|
||||
return mTextureInfo;
|
||||
}
|
||||
|
||||
virtual bool SupportsType(DeprecatedTextureClientType aType) { return false; }
|
||||
|
||||
/**
|
||||
* The Lock* methods lock the texture client for drawing into, providing some
|
||||
* object that can be used for drawing to. Once the user is finished
|
||||
* with the object it should call Unlock.
|
||||
*/
|
||||
virtual gfxImageSurface* LockImageSurface() { return nullptr; }
|
||||
virtual gfxASurface* LockSurface() { return nullptr; }
|
||||
// If you implement LockDrawTarget, you MUST implement BackendType()
|
||||
virtual gfx::DrawTarget* LockDrawTarget() { return nullptr; }
|
||||
|
||||
// The type of draw target returned by LockDrawTarget.
|
||||
virtual gfx::BackendType BackendType()
|
||||
{
|
||||
return gfx::BackendType::NONE;
|
||||
}
|
||||
|
||||
virtual void ReleaseResources() {}
|
||||
/**
|
||||
* This unlocks the current DrawableTexture and allows the host to composite
|
||||
* it directly.
|
||||
*/
|
||||
virtual void Unlock() {}
|
||||
|
||||
/**
|
||||
* Ensure that the texture client is suitable for the given size and content
|
||||
* type and that any initialisation has taken place.
|
||||
* Returns true if succeeded, false if failed.
|
||||
*/
|
||||
virtual bool EnsureAllocated(gfx::IntSize aSize,
|
||||
gfxContentType aType) = 0;
|
||||
|
||||
/**
|
||||
* _Only_ used at the end of the layer transaction when receiving a reply from
|
||||
* the compositor.
|
||||
*/
|
||||
virtual void SetDescriptorFromReply(const SurfaceDescriptor& aDescriptor)
|
||||
{
|
||||
// default implementation
|
||||
SetDescriptor(aDescriptor);
|
||||
}
|
||||
virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor)
|
||||
{
|
||||
mDescriptor = aDescriptor;
|
||||
}
|
||||
SurfaceDescriptor* GetDescriptor() { return &mDescriptor; }
|
||||
/**
|
||||
* Use LockSurfaceDescriptor to get the descriptor if it will be sent across IPC.
|
||||
* Use GetDescriptor if you want to keep the descriptor on one thread.
|
||||
*/
|
||||
virtual SurfaceDescriptor* LockSurfaceDescriptor() { return GetDescriptor(); }
|
||||
|
||||
CompositableForwarder* GetForwarder() const
|
||||
{
|
||||
return mForwarder;
|
||||
}
|
||||
|
||||
void SetFlags(TextureFlags aFlags)
|
||||
{
|
||||
mTextureInfo.mTextureFlags = aFlags;
|
||||
}
|
||||
|
||||
enum AccessMode
|
||||
{
|
||||
ACCESS_NONE = 0x0,
|
||||
ACCESS_READ_ONLY = 0x1,
|
||||
ACCESS_READ_WRITE = 0x2
|
||||
};
|
||||
|
||||
void SetAccessMode(AccessMode aAccessMode)
|
||||
{
|
||||
mAccessMode = aAccessMode;
|
||||
}
|
||||
|
||||
AccessMode GetAccessMode() const
|
||||
{
|
||||
return mAccessMode;
|
||||
}
|
||||
|
||||
virtual gfxContentType GetContentType() = 0;
|
||||
|
||||
protected:
|
||||
DeprecatedTextureClient(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo);
|
||||
|
||||
CompositableForwarder* mForwarder;
|
||||
// So far all DeprecatedTextureClients use a SurfaceDescriptor, so it makes sense to
|
||||
// keep the reference here.
|
||||
SurfaceDescriptor mDescriptor;
|
||||
TextureInfo mTextureInfo;
|
||||
AccessMode mAccessMode;
|
||||
};
|
||||
|
||||
class DeprecatedTextureClientShmem : public DeprecatedTextureClient
|
||||
{
|
||||
public:
|
||||
DeprecatedTextureClientShmem(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo);
|
||||
~DeprecatedTextureClientShmem();
|
||||
virtual bool SupportsType(DeprecatedTextureClientType aType) MOZ_OVERRIDE
|
||||
{
|
||||
return aType == TEXTURE_SHMEM || aType == TEXTURE_CONTENT || aType == TEXTURE_FALLBACK;
|
||||
}
|
||||
virtual gfxImageSurface* LockImageSurface() MOZ_OVERRIDE;
|
||||
virtual gfxASurface* LockSurface() MOZ_OVERRIDE { return GetSurface(); }
|
||||
virtual gfx::DrawTarget* LockDrawTarget();
|
||||
virtual gfx::BackendType BackendType() MOZ_OVERRIDE
|
||||
{
|
||||
return gfx::BackendType::CAIRO;
|
||||
}
|
||||
virtual void Unlock() MOZ_OVERRIDE;
|
||||
virtual bool EnsureAllocated(gfx::IntSize aSize, gfxContentType aType) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ReleaseResources() MOZ_OVERRIDE;
|
||||
virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE;
|
||||
virtual gfxContentType GetContentType() MOZ_OVERRIDE { return mContentType; }
|
||||
private:
|
||||
gfxASurface* GetSurface();
|
||||
|
||||
nsRefPtr<gfxASurface> mSurface;
|
||||
nsRefPtr<gfxImageSurface> mSurfaceAsImage;
|
||||
RefPtr<gfx::DrawTarget> mDrawTarget;
|
||||
|
||||
gfxContentType mContentType;
|
||||
gfx::IntSize mSize;
|
||||
|
||||
friend class CompositingFactory;
|
||||
};
|
||||
|
||||
class DeprecatedTextureClientTile : public DeprecatedTextureClient
|
||||
{
|
||||
public:
|
||||
DeprecatedTextureClientTile(const DeprecatedTextureClientTile& aOther);
|
||||
DeprecatedTextureClientTile(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo,
|
||||
gfxReusableSurfaceWrapper* aSurface = nullptr);
|
||||
~DeprecatedTextureClientTile();
|
||||
|
||||
virtual bool EnsureAllocated(gfx::IntSize aSize,
|
||||
gfxContentType aType) MOZ_OVERRIDE;
|
||||
|
||||
virtual gfxImageSurface* LockImageSurface() MOZ_OVERRIDE;
|
||||
|
||||
gfxReusableSurfaceWrapper* GetReusableSurfaceWrapper()
|
||||
{
|
||||
return mSurface;
|
||||
}
|
||||
|
||||
virtual void SetDescriptor(const SurfaceDescriptor& aDescriptor) MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(false, "Tiled texture clients don't use SurfaceDescriptors.");
|
||||
}
|
||||
|
||||
|
||||
virtual gfxContentType GetContentType() { return mContentType; }
|
||||
|
||||
private:
|
||||
gfxContentType mContentType;
|
||||
nsRefPtr<gfxReusableSurfaceWrapper> mSurface;
|
||||
|
||||
friend class CompositingFactory;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for AutoLock*Client.
|
||||
* handles lock/unlock
|
||||
* XXX - this can be removed as soon as we remove DeprecatedImageClientSingle
|
||||
*/
|
||||
class AutoLockDeprecatedTextureClient
|
||||
{
|
||||
public:
|
||||
AutoLockDeprecatedTextureClient(DeprecatedTextureClient* aTexture)
|
||||
{
|
||||
mDeprecatedTextureClient = aTexture;
|
||||
mDescriptor = aTexture->LockSurfaceDescriptor();
|
||||
}
|
||||
|
||||
SurfaceDescriptor* GetSurfaceDescriptor()
|
||||
{
|
||||
return mDescriptor;
|
||||
}
|
||||
|
||||
virtual ~AutoLockDeprecatedTextureClient()
|
||||
{
|
||||
mDeprecatedTextureClient->Unlock();
|
||||
}
|
||||
protected:
|
||||
DeprecatedTextureClient* mDeprecatedTextureClient;
|
||||
SurfaceDescriptor* mDescriptor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes the content of a PlanarYCbCrImage into a SurfaceDescriptor.
|
||||
* XXX - this can be removed as soon as we remove DeprecatedImageClientSingle
|
||||
*/
|
||||
class AutoLockYCbCrClient : public AutoLockDeprecatedTextureClient
|
||||
{
|
||||
public:
|
||||
AutoLockYCbCrClient(DeprecatedTextureClient* aTexture) : AutoLockDeprecatedTextureClient(aTexture) {}
|
||||
bool Update(PlanarYCbCrImage* aImage);
|
||||
protected:
|
||||
bool EnsureDeprecatedTextureClient(PlanarYCbCrImage* aImage);
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes the content of a gfxASurface into a SurfaceDescriptor.
|
||||
* XXX - this can be removed as soon as we remove DeprecatedImageClientSingle
|
||||
*/
|
||||
class AutoLockShmemClient : public AutoLockDeprecatedTextureClient
|
||||
{
|
||||
public:
|
||||
AutoLockShmemClient(DeprecatedTextureClient* aTexture) : AutoLockDeprecatedTextureClient(aTexture) {}
|
||||
bool Update(Image* aImage, uint32_t aContentFlags, gfxASurface *aSurface);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -201,29 +201,6 @@ public:
|
||||
MOZ_ASSERT(false, "should be implemented or not used");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a suitable texture host exists in this compositable. The
|
||||
* compositable host may or may not create a new texture host. If a texture
|
||||
* host is replaced, then the compositable is responsible for enusring it is
|
||||
* destroyed correctly (without leaking resources).
|
||||
* aTextureId - identifies the texture within the compositable, how the
|
||||
* compositable chooses to use this is between the compositable client and
|
||||
* host and will vary between types of compositable.
|
||||
* aSurface - the new or existing texture host should support surface
|
||||
* descriptors of the same type and, if necessary, this specific surface
|
||||
* descriptor. Whether it is necessary or not depends on the protocol between
|
||||
* the compositable client and host.
|
||||
* aAllocator - the allocator used to allocate and de-allocate resources.
|
||||
* aTextureInfo - contains flags for the texture.
|
||||
*/
|
||||
virtual void EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
ISurfaceAllocator* aAllocator,
|
||||
const TextureInfo& aTextureInfo)
|
||||
{
|
||||
MOZ_ASSERT(false, "should be implemented or not used");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a suitable texture host exists in this compsitable.
|
||||
*
|
||||
|
@ -274,14 +274,6 @@ public:
|
||||
const TextureInfo& aTextureInfo,
|
||||
const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
|
||||
virtual void EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
ISurfaceAllocator* aAllocator,
|
||||
const TextureInfo& aTextureInfo)
|
||||
{
|
||||
NS_RUNTIMEABORT("Shouldn't call this");
|
||||
}
|
||||
|
||||
virtual void UpdateIncremental(TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor& aSurface,
|
||||
const nsIntRegion& aUpdated,
|
||||
|
@ -235,14 +235,6 @@ public:
|
||||
|
||||
virtual TiledLayerComposer* AsTiledLayerComposer() MOZ_OVERRIDE { return this; }
|
||||
|
||||
virtual void EnsureDeprecatedTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
ISurfaceAllocator* aAllocator,
|
||||
const TextureInfo& aTextureInfo) MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_CRASH("Does nothing");
|
||||
}
|
||||
|
||||
virtual void Attach(Layer* aLayer,
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
|
||||
|
@ -27,7 +27,6 @@ class TextureFactoryIdentifier;
|
||||
class SurfaceDescriptor;
|
||||
class SurfaceDescriptorTiles;
|
||||
class ThebesBufferData;
|
||||
class DeprecatedTextureClient;
|
||||
class ClientTiledLayerBuffer;
|
||||
class PTextureChild;
|
||||
|
||||
@ -44,7 +43,6 @@ class PTextureChild;
|
||||
class CompositableForwarder : public ISurfaceAllocator
|
||||
{
|
||||
friend class AutoOpenSurface;
|
||||
friend class DeprecatedTextureClientShmem;
|
||||
public:
|
||||
|
||||
CompositableForwarder()
|
||||
@ -57,26 +55,6 @@ public:
|
||||
*/
|
||||
virtual void Connect(CompositableClient* aCompositable) = 0;
|
||||
|
||||
/**
|
||||
* When using the Thebes layer pattern of swapping or updating
|
||||
* TextureClient/Host pairs without sending SurfaceDescriptors,
|
||||
* use these messages to assign the single or double buffer
|
||||
* (TextureClient/Host pairs) to the CompositableHost.
|
||||
* We expect the textures to already have been created.
|
||||
* With these messages, the ownership of the SurfaceDescriptor(s)
|
||||
* moves to the compositor.
|
||||
*/
|
||||
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aDescriptorOnWhite = nullptr) = 0;
|
||||
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aFrontDescriptor,
|
||||
const SurfaceDescriptor& aBackDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aFrontDescriptorOnWhite = nullptr,
|
||||
const SurfaceDescriptor* aBackDescriptorOnWhite = nullptr) = 0;
|
||||
|
||||
/**
|
||||
* Notify the CompositableHost that it should create host-side-only
|
||||
* texture(s), that we will update incrementally using UpdateTextureIncremental.
|
||||
@ -97,21 +75,6 @@ public:
|
||||
*/
|
||||
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData, TextureFlags aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that the texture identified by aCompositable
|
||||
* and aTextureId has been updated to aImage.
|
||||
*/
|
||||
virtual void UpdateTexture(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) = 0;
|
||||
|
||||
/**
|
||||
* Same as UpdateTexture, but performs an asynchronous layer transaction (if possible)
|
||||
*/
|
||||
virtual void UpdateTextureNoSwap(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) = 0;
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that aRegion in the texture identified by
|
||||
* aCompositable and aIdentifier has been updated to aThebesBuffer.
|
||||
|
@ -70,19 +70,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
EditReplyVector& replyv)
|
||||
{
|
||||
switch (aEdit.type()) {
|
||||
case CompositableOperation::TOpCreatedTexture: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] Created texture"));
|
||||
const OpCreatedTexture& op = aEdit.get_OpCreatedTexture();
|
||||
CompositableParent* compositableParent =
|
||||
static_cast<CompositableParent*>(op.compositableParent());
|
||||
CompositableHost* compositable = compositableParent->GetCompositableHost();
|
||||
|
||||
compositable->EnsureDeprecatedTextureHost(op.textureId(), op.descriptor(),
|
||||
compositableParent->GetCompositableManager(),
|
||||
op.textureInfo());
|
||||
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpCreatedIncrementalTexture: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] Created texture"));
|
||||
const OpCreatedIncrementalTexture& op = aEdit.get_OpCreatedIncrementalTexture();
|
||||
@ -96,60 +83,6 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
op.bufferRect());
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpPaintTexture: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] Paint Texture X"));
|
||||
const OpPaintTexture& op = aEdit.get_OpPaintTexture();
|
||||
|
||||
CompositableParent* compositableParent =
|
||||
static_cast<CompositableParent*>(op.compositableParent());
|
||||
CompositableHost* compositable =
|
||||
compositableParent->GetCompositableHost();
|
||||
|
||||
Layer* layer = compositable ? compositable->GetLayer() : nullptr;
|
||||
LayerComposite* shadowLayer = layer ? layer->AsLayerComposite() : nullptr;
|
||||
if (shadowLayer) {
|
||||
Compositor* compositor = static_cast<LayerManagerComposite*>(layer->Manager())->GetCompositor();
|
||||
compositable->SetCompositor(compositor);
|
||||
compositable->SetLayer(layer);
|
||||
} else {
|
||||
// if we reach this branch, it most likely means that async textures
|
||||
// are coming in before we had time to attach the compositable to a
|
||||
// layer. Don't panic, it is okay in this case. it should not be
|
||||
// happening continuously, though.
|
||||
}
|
||||
|
||||
if (layer) {
|
||||
RenderTraceInvalidateStart(layer, "FF00FF", layer->GetVisibleRegion().GetBounds());
|
||||
}
|
||||
|
||||
if (compositable) {
|
||||
const SurfaceDescriptor& descriptor = op.image();
|
||||
compositable->EnsureDeprecatedTextureHost(op.textureId(),
|
||||
descriptor,
|
||||
compositableParent->GetCompositableManager(),
|
||||
TextureInfo());
|
||||
MOZ_ASSERT(compositable->GetDeprecatedTextureHost());
|
||||
|
||||
SurfaceDescriptor newBack;
|
||||
bool shouldRecomposite = compositable->Update(descriptor, &newBack);
|
||||
if (IsSurfaceDescriptorValid(newBack)) {
|
||||
replyv.push_back(OpTextureSwap(compositableParent, nullptr,
|
||||
op.textureId(), newBack));
|
||||
}
|
||||
|
||||
if (IsAsync() && shouldRecomposite) {
|
||||
ScheduleComposition(op);
|
||||
}
|
||||
}
|
||||
|
||||
if (layer) {
|
||||
RenderTraceInvalidateEnd(layer, "FF00FF");
|
||||
}
|
||||
|
||||
// return texure data to client if necessary
|
||||
ReturnTextureDataIfNecessary(compositable, replyv, op.compositableParent());
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpPaintTextureRegion: {
|
||||
MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer"));
|
||||
|
||||
|
@ -137,40 +137,6 @@ ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
|
||||
region));
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::UpdateTexture(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor)
|
||||
{
|
||||
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
||||
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
||||
MOZ_ASSERT(aCompositable);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
mTxn->AddEdit(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
||||
SurfaceDescriptor(*aDescriptor)));
|
||||
*aDescriptor = SurfaceDescriptor();
|
||||
} else {
|
||||
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::UpdateTextureNoSwap(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor)
|
||||
{
|
||||
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
||||
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
||||
MOZ_ASSERT(aCompositable);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
mTxn->AddNoSwapEdit(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
||||
SurfaceDescriptor(*aDescriptor)));
|
||||
*aDescriptor = SurfaceDescriptor();
|
||||
} else {
|
||||
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::UpdatePictureRect(CompositableClient* aCompositable,
|
||||
const nsIntRect& aRect)
|
||||
|
@ -248,17 +248,6 @@ public:
|
||||
NS_RUNTIMEABORT("should not be called");
|
||||
}
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that the texture identified by aCompositable
|
||||
* and aTextureId has been updated to aDescriptor.
|
||||
*/
|
||||
virtual void UpdateTexture(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void UpdateTextureNoSwap(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
|
||||
virtual void UpdateTextureIncremental(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor& aDescriptor,
|
||||
@ -276,28 +265,12 @@ public:
|
||||
const nsIntRect& aRect) MOZ_OVERRIDE;
|
||||
|
||||
|
||||
// at the moment we don't need to implement these. They are only used for
|
||||
// thebes layers which don't support async updates.
|
||||
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aDescriptorOnWhite = nullptr) MOZ_OVERRIDE {
|
||||
NS_RUNTIMEABORT("should not be called");
|
||||
}
|
||||
virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const nsIntRect& aBufferRect) MOZ_OVERRIDE
|
||||
{
|
||||
NS_RUNTIMEABORT("should not be called");
|
||||
}
|
||||
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aFrontDescriptor,
|
||||
const SurfaceDescriptor& aBackDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aFrontDescriptorOnWhite = nullptr,
|
||||
const SurfaceDescriptor* aBackDescriptorOnWhite = nullptr) MOZ_OVERRIDE {
|
||||
NS_RUNTIMEABORT("should not be called");
|
||||
}
|
||||
virtual void UpdateTextureRegion(CompositableClient* aCompositable,
|
||||
const ThebesBufferData& aThebesBufferData,
|
||||
const nsIntRegion& aUpdatedRegion) MOZ_OVERRIDE {
|
||||
|
@ -295,25 +295,12 @@ struct OpUseTiledLayerBuffer {
|
||||
SurfaceDescriptorTiles tileLayerDescriptor;
|
||||
};
|
||||
|
||||
struct OpCreatedTexture {
|
||||
PCompositable compositable;
|
||||
uint32_t textureId;
|
||||
SurfaceDescriptor descriptor;
|
||||
TextureInfo textureInfo;
|
||||
};
|
||||
|
||||
struct OpCreatedIncrementalTexture {
|
||||
PCompositable compositable;
|
||||
TextureInfo textureInfo;
|
||||
nsIntRect bufferRect;
|
||||
};
|
||||
|
||||
struct OpPaintTexture {
|
||||
PCompositable compositable;
|
||||
uint32_t textureId;
|
||||
SurfaceDescriptor image;
|
||||
};
|
||||
|
||||
struct OpPaintTextureRegion {
|
||||
PCompositable compositable;
|
||||
ThebesBufferData bufferData;
|
||||
@ -371,10 +358,8 @@ struct OpUpdateTexture {
|
||||
union CompositableOperation {
|
||||
OpUpdatePictureRect;
|
||||
|
||||
OpCreatedTexture;
|
||||
OpCreatedIncrementalTexture;
|
||||
|
||||
OpPaintTexture;
|
||||
OpPaintTextureRegion;
|
||||
OpPaintTextureIncremental;
|
||||
|
||||
|
@ -26,7 +26,6 @@ namespace layers {
|
||||
class MaybeMagicGrallocBufferHandle;
|
||||
class SurfaceDescriptorGralloc;
|
||||
class TextureHost;
|
||||
class DeprecatedTextureHost;
|
||||
|
||||
/**
|
||||
* This class exists to share the underlying GraphicBuffer resources
|
||||
@ -101,10 +100,6 @@ private:
|
||||
// BufferActor. This will be used for the memory reporter.
|
||||
size_t mAllocBytes;
|
||||
|
||||
// used only for hacky fix in gecko 23 for bug 862324
|
||||
// see bug 865908 about fixing this.
|
||||
nsAutoTArray<DeprecatedTextureHost*, 2> mDeprecatedTextureHosts;
|
||||
|
||||
// Used only for hacky fix for bug 966446.
|
||||
TextureHost* mTextureHost;
|
||||
|
||||
|
@ -333,42 +333,6 @@ ShadowLayerForwarder::UseTiledLayerBuffer(CompositableClient* aCompositable,
|
||||
aTileLayerDescriptor));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::UpdateTexture(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor)
|
||||
{
|
||||
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
||||
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
||||
CheckSurfaceDescriptor(aDescriptor);
|
||||
MOZ_ASSERT(aCompositable);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
mTxn->AddPaint(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
||||
SurfaceDescriptor(*aDescriptor)));
|
||||
*aDescriptor = SurfaceDescriptor();
|
||||
} else {
|
||||
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::UpdateTextureNoSwap(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor)
|
||||
{
|
||||
if (aDescriptor->type() != SurfaceDescriptor::T__None &&
|
||||
aDescriptor->type() != SurfaceDescriptor::Tnull_t) {
|
||||
CheckSurfaceDescriptor(aDescriptor);
|
||||
MOZ_ASSERT(aCompositable);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
mTxn->AddNoSwapPaint(OpPaintTexture(nullptr, aCompositable->GetIPDLActor(), 1,
|
||||
SurfaceDescriptor(*aDescriptor)));
|
||||
*aDescriptor = SurfaceDescriptor();
|
||||
} else {
|
||||
NS_WARNING("Trying to send a null SurfaceDescriptor.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::UpdateTextureRegion(CompositableClient* aCompositable,
|
||||
const ThebesBufferData& aThebesBufferData,
|
||||
@ -904,29 +868,6 @@ ShadowLayerForwarder::Connect(CompositableClient* aCompositable)
|
||||
child->SetClient(aCompositable);
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedSingleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aDescriptorOnWhite)
|
||||
{
|
||||
CheckSurfaceDescriptor(&aDescriptor);
|
||||
CheckSurfaceDescriptor(aDescriptorOnWhite);
|
||||
|
||||
MOZ_ASSERT(aDescriptor.type() != SurfaceDescriptor::T__None &&
|
||||
aDescriptor.type() != SurfaceDescriptor::Tnull_t);
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureFront,
|
||||
aDescriptor,
|
||||
aTextureInfo));
|
||||
if (aDescriptorOnWhite) {
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureOnWhiteFront,
|
||||
*aDescriptorOnWhite,
|
||||
aTextureInfo));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedIncrementalBuffer(CompositableClient* aCompositable,
|
||||
const TextureInfo& aTextureInfo,
|
||||
@ -936,43 +877,6 @@ ShadowLayerForwarder::CreatedIncrementalBuffer(CompositableClient* aCompositable
|
||||
aTextureInfo, aBufferRect));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::CreatedDoubleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aFrontDescriptor,
|
||||
const SurfaceDescriptor& aBackDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aFrontDescriptorOnWhite,
|
||||
const SurfaceDescriptor* aBackDescriptorOnWhite)
|
||||
{
|
||||
CheckSurfaceDescriptor(&aFrontDescriptor);
|
||||
CheckSurfaceDescriptor(&aBackDescriptor);
|
||||
CheckSurfaceDescriptor(aFrontDescriptorOnWhite);
|
||||
CheckSurfaceDescriptor(aBackDescriptorOnWhite);
|
||||
MOZ_ASSERT(aFrontDescriptor.type() != SurfaceDescriptor::T__None &&
|
||||
aBackDescriptor.type() != SurfaceDescriptor::T__None &&
|
||||
aFrontDescriptor.type() != SurfaceDescriptor::Tnull_t &&
|
||||
aBackDescriptor.type() != SurfaceDescriptor::Tnull_t);
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureFront,
|
||||
aFrontDescriptor,
|
||||
aTextureInfo));
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureBack,
|
||||
aBackDescriptor,
|
||||
aTextureInfo));
|
||||
if (aFrontDescriptorOnWhite) {
|
||||
MOZ_ASSERT(aBackDescriptorOnWhite);
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureOnWhiteFront,
|
||||
*aFrontDescriptorOnWhite,
|
||||
aTextureInfo));
|
||||
mTxn->AddEdit(OpCreatedTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
TextureOnWhiteBack,
|
||||
*aBackDescriptorOnWhite,
|
||||
aTextureInfo));
|
||||
}
|
||||
}
|
||||
|
||||
void ShadowLayerForwarder::Attach(CompositableClient* aCompositable,
|
||||
ShadowableLayer* aLayer)
|
||||
{
|
||||
|
@ -135,7 +135,6 @@ class Transaction;
|
||||
class ShadowLayerForwarder : public CompositableForwarder
|
||||
{
|
||||
friend class AutoOpenSurface;
|
||||
friend class DeprecatedTextureClientShmem;
|
||||
friend class ContentClientIncremental;
|
||||
friend class ClientLayerManager;
|
||||
|
||||
@ -151,19 +150,9 @@ public:
|
||||
virtual PTextureChild* CreateTexture(const SurfaceDescriptor& aSharedData,
|
||||
TextureFlags aFlags) MOZ_OVERRIDE;
|
||||
|
||||
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aDescriptorOnWhite = nullptr) MOZ_OVERRIDE;
|
||||
virtual void CreatedIncrementalBuffer(CompositableClient* aCompositable,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
virtual void CreatedDoubleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aFrontDescriptor,
|
||||
const SurfaceDescriptor& aBackDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
const SurfaceDescriptor* aFrontDescriptorOnWhite = nullptr,
|
||||
const SurfaceDescriptor* aBackDescriptorOnWhite = nullptr) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Adds an edit in the layers transaction in order to attach
|
||||
@ -266,26 +255,11 @@ public:
|
||||
*/
|
||||
void AttachAsyncCompositable(PLayerTransactionChild* aLayer, uint64_t aID);
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that the texture identified by aLayer
|
||||
* and aIdentifier has been updated to aImage.
|
||||
*/
|
||||
virtual void UpdateTexture(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTextureFromCompositable(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTexture(TextureClient* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Same as above, but performs an asynchronous layer transaction
|
||||
*/
|
||||
virtual void UpdateTextureNoSwap(CompositableClient* aCompositable,
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that aRegion in the texture identified by aLayer
|
||||
* and aIdentifier has been updated to aThebesBuffer.
|
||||
|
Loading…
Reference in New Issue
Block a user