mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
merge
This commit is contained in:
commit
1f5a3fb130
@ -8,6 +8,7 @@
|
||||
#include "GLUploadHelpers.h"
|
||||
#include "DecomposeIntoNoRepeatTriangles.h"
|
||||
#include "GLContext.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
#include "nsRect.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxUtils.h"
|
||||
@ -143,7 +144,8 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect&
|
||||
}
|
||||
}
|
||||
|
||||
TextureImage::ScopedBindTexture texBind(aSrc, LOCAL_GL_TEXTURE0);
|
||||
ScopedBindTextureUnit autoTexUnit(mGL, LOCAL_GL_TEXTURE0);
|
||||
ScopedBindTexture autoTex(mGL, aSrc->GetTextureID());
|
||||
|
||||
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
|
||||
|
||||
|
@ -1189,24 +1189,6 @@ GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLContext::ApplyFilterToBoundTexture(GraphicsFilter aFilter)
|
||||
{
|
||||
ApplyFilterToBoundTexture(LOCAL_GL_TEXTURE_2D, aFilter);
|
||||
}
|
||||
|
||||
void GLContext::ApplyFilterToBoundTexture(GLuint aTarget,
|
||||
GraphicsFilter aFilter)
|
||||
{
|
||||
if (aFilter == GraphicsFilter::FILTER_NEAREST) {
|
||||
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
|
||||
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
|
||||
} else {
|
||||
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
|
||||
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GLContext::DetermineCaps()
|
||||
{
|
||||
|
@ -2482,25 +2482,6 @@ public:
|
||||
*/
|
||||
virtual bool ReleaseTexImage() { return false; }
|
||||
|
||||
/**
|
||||
* Applies aFilter to the texture currently bound to GL_TEXTURE_2D.
|
||||
*/
|
||||
void ApplyFilterToBoundTexture(GraphicsFilter aFilter);
|
||||
|
||||
/**
|
||||
* Applies aFilter to the texture currently bound to aTarget.
|
||||
*/
|
||||
void ApplyFilterToBoundTexture(GLuint aTarget,
|
||||
GraphicsFilter aFilter);
|
||||
|
||||
virtual bool BindExternalBuffer(GLuint texture, void* buffer) { return false; }
|
||||
virtual bool UnbindExternalBuffer(GLuint texture) { return false; }
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
virtual EGLImage CreateEGLImageForNativeBuffer(void* buffer) = 0;
|
||||
virtual void DestroyEGLImage(EGLImage image) = 0;
|
||||
#endif
|
||||
|
||||
// Before reads from offscreen texture
|
||||
void GuaranteeResolve();
|
||||
|
||||
|
@ -408,25 +408,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
EGLImage CreateEGLImageForNativeBuffer(void* buffer) MOZ_OVERRIDE
|
||||
{
|
||||
EGLint attrs[] = {
|
||||
LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
|
||||
LOCAL_EGL_NONE, LOCAL_EGL_NONE
|
||||
};
|
||||
return sEGLLibrary.fCreateImage(EGL_DISPLAY(),
|
||||
EGL_NO_CONTEXT,
|
||||
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
|
||||
buffer, attrs);
|
||||
}
|
||||
|
||||
void DestroyEGLImage(EGLImage image) MOZ_OVERRIDE
|
||||
{
|
||||
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), image);
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void SetEGLSurfaceOverride(EGLSurface surf) MOZ_OVERRIDE {
|
||||
if (Screen()) {
|
||||
/* Blit `draw` to `read` if we need to, before we potentially juggle
|
||||
|
@ -205,13 +205,6 @@ BasicTextureImage::BindTexture(GLenum aTextureUnit)
|
||||
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
|
||||
void
|
||||
BasicTextureImage::ApplyFilter()
|
||||
{
|
||||
mGLContext->ApplyFilterToBoundTexture(mFilter);
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
BasicTextureImage::GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
|
||||
{
|
||||
@ -637,12 +630,6 @@ TiledTextureImage::BindTexture(GLenum aTextureUnit)
|
||||
mImages[mCurrentImage]->BindTexture(aTextureUnit);
|
||||
}
|
||||
|
||||
void
|
||||
TiledTextureImage::ApplyFilter()
|
||||
{
|
||||
mGL->ApplyFilterToBoundTexture(mFilter);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize, trying to reuse tiles. The reuse strategy is to decide on reuse per
|
||||
* column. A tile on a column is reused if it hasn't changed size, otherwise it
|
||||
@ -745,16 +732,6 @@ uint32_t TiledTextureImage::GetTileCount()
|
||||
return mImages.Length();
|
||||
}
|
||||
|
||||
TextureImage::ScopedBindTexture::ScopedBindTexture(TextureImage* aTexture,
|
||||
GLenum aTextureUnit)
|
||||
: mTexture(aTexture)
|
||||
{
|
||||
if (mTexture) {
|
||||
MOZ_ASSERT(aTextureUnit >= LOCAL_GL_TEXTURE0);
|
||||
mTexture->BindTexture(aTextureUnit);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<TextureImage>
|
||||
CreateBasicTextureImage(GLContext* aGL,
|
||||
const nsIntSize& aSize,
|
||||
|
@ -185,41 +185,6 @@ public:
|
||||
const gfx::IntPoint* aSrcOffset = nullptr);
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit) = 0;
|
||||
virtual void ReleaseTexture() {}
|
||||
|
||||
void BindTextureAndApplyFilter(GLenum aTextureUnit) {
|
||||
BindTexture(aTextureUnit);
|
||||
ApplyFilter();
|
||||
}
|
||||
|
||||
class ScopedBindTexture
|
||||
{
|
||||
public:
|
||||
ScopedBindTexture(TextureImage *aTexture, GLenum aTextureUnit);
|
||||
|
||||
~ScopedBindTexture()
|
||||
{
|
||||
if (mTexture) {
|
||||
mTexture->ReleaseTexture();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TextureImage *mTexture;
|
||||
};
|
||||
|
||||
class ScopedBindTextureAndApplyFilter
|
||||
: public ScopedBindTexture
|
||||
{
|
||||
public:
|
||||
ScopedBindTextureAndApplyFilter(TextureImage *aTexture, GLenum aTextureUnit) :
|
||||
ScopedBindTexture(aTexture, aTextureUnit)
|
||||
{
|
||||
if (mTexture) {
|
||||
mTexture->ApplyFilter();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the image format of the texture. Only valid after a matching
|
||||
@ -247,12 +212,6 @@ public:
|
||||
|
||||
void SetFilter(GraphicsFilter aFilter) { mFilter = aFilter; }
|
||||
|
||||
/**
|
||||
* Applies this TextureImage's filter, assuming that its texture is
|
||||
* the currently bound texture.
|
||||
*/
|
||||
virtual void ApplyFilter() = 0;
|
||||
|
||||
protected:
|
||||
friend class GLContext;
|
||||
|
||||
@ -345,9 +304,7 @@ public:
|
||||
|
||||
virtual void Resize(const nsIntSize& aSize);
|
||||
|
||||
virtual void ApplyFilter();
|
||||
protected:
|
||||
|
||||
GLuint mTexture;
|
||||
TextureState mTextureState;
|
||||
nsRefPtr<GLContext> mGLContext;
|
||||
@ -390,7 +347,6 @@ public:
|
||||
virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
|
||||
virtual bool InUpdate() const { return mInUpdate; }
|
||||
virtual void BindTexture(GLenum);
|
||||
virtual void ApplyFilter();
|
||||
|
||||
protected:
|
||||
virtual gfx::IntRect GetSrcTileRect();
|
||||
|
@ -311,12 +311,6 @@ TextureImageEGL::DestroyEGLSurface(void)
|
||||
mSurface = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
TextureImageEGL::ApplyFilter()
|
||||
{
|
||||
mGLContext->ApplyFilterToBoundTexture(mFilter);
|
||||
}
|
||||
|
||||
already_AddRefed<TextureImage>
|
||||
CreateTextureImageEGL(GLContext *gl,
|
||||
const nsIntSize& aSize,
|
||||
|
@ -75,8 +75,6 @@ protected:
|
||||
TextureState mTextureState;
|
||||
|
||||
bool mBound;
|
||||
|
||||
virtual void ApplyFilter();
|
||||
};
|
||||
|
||||
already_AddRefed<TextureImage>
|
||||
|
47
gfx/layers/AtomicRefCountedWithFinalize.h
Normal file
47
gfx/layers/AtomicRefCountedWithFinalize.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef MOZILLA_ATOMICREFCOUNTEDWITHFINALIZE_H_
|
||||
#define MOZILLA_ATOMICREFCOUNTEDWITHFINALIZE_H_
|
||||
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template<typename T>
|
||||
class AtomicRefCountedWithFinalize
|
||||
{
|
||||
protected:
|
||||
AtomicRefCountedWithFinalize()
|
||||
: mRefCount(0)
|
||||
{}
|
||||
|
||||
~AtomicRefCountedWithFinalize() {}
|
||||
|
||||
public:
|
||||
void AddRef() {
|
||||
MOZ_ASSERT(mRefCount >= 0);
|
||||
++mRefCount;
|
||||
}
|
||||
|
||||
void Release() {
|
||||
MOZ_ASSERT(mRefCount > 0);
|
||||
if (0 == --mRefCount) {
|
||||
#ifdef DEBUG
|
||||
mRefCount = detail::DEAD;
|
||||
#endif
|
||||
T* derived = static_cast<T*>(this);
|
||||
derived->Finalize();
|
||||
delete derived;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Atomic<int> mRefCount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -217,6 +217,7 @@ ImageContainer::ClearAllImages()
|
||||
ImageBridgeChild::FlushAllImages(mImageClient, this, false);
|
||||
return;
|
||||
}
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
SetCurrentImageInternal(nullptr);
|
||||
}
|
||||
|
@ -35,11 +35,10 @@ MacIOSurfaceTextureSourceBasic::GetFormat() const
|
||||
}
|
||||
|
||||
MacIOSurfaceTextureHostBasic::MacIOSurfaceTextureHostBasic(
|
||||
uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor
|
||||
)
|
||||
: TextureHost(aID, aFlags)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
|
||||
aDescriptor.scaleFactor(),
|
||||
|
@ -56,9 +56,8 @@ protected:
|
||||
class MacIOSurfaceTextureHostBasic : public TextureHost
|
||||
{
|
||||
public:
|
||||
MacIOSurfaceTextureHostBasic(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor);
|
||||
MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor);
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -13,8 +13,7 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
TemporaryRef<TextureHost>
|
||||
CreateTextureHostBasic(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
@ -24,12 +23,12 @@ CreateTextureHostBasic(uint64_t aID,
|
||||
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
|
||||
const SurfaceDescriptorMacIOSurface& desc =
|
||||
aDesc.get_SurfaceDescriptorMacIOSurface();
|
||||
result = new MacIOSurfaceTextureHostBasic(aID, aFlags, desc);
|
||||
result = new MacIOSurfaceTextureHostBasic(aFlags, desc);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
result = CreateBackendIndependentTextureHost(aID, aDesc, aDeallocator, aFlags);
|
||||
result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
{
|
||||
if (mBuffer &&
|
||||
(mBuffer->IsImmutable() || mBuffer->GetSize() != aSize)) {
|
||||
RemoveTextureClient(mBuffer);
|
||||
mBuffer->ForceRemove();
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
@ -106,14 +106,6 @@ CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFla
|
||||
mTextureInfo.mTextureFlags | aFlags);
|
||||
}
|
||||
|
||||
void
|
||||
CanvasClient2D::OnActorDestroy()
|
||||
{
|
||||
if (mBuffer) {
|
||||
mBuffer->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedCanvasClient2D::Updated()
|
||||
{
|
||||
@ -165,14 +157,6 @@ DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
mDeprecatedTextureClient->Unlock();
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedCanvasClient2D::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedCanvasClientSurfaceStream::Updated()
|
||||
{
|
||||
@ -241,13 +225,5 @@ DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLaye
|
||||
aLayer->Painted();
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedCanvasClientSurfaceStream::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,6 @@ public:
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
RefPtr<TextureClient> mBuffer;
|
||||
};
|
||||
@ -117,8 +115,6 @@ public:
|
||||
mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
|
||||
};
|
||||
@ -145,8 +141,6 @@ public:
|
||||
mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor);
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
|
||||
};
|
||||
|
@ -368,17 +368,6 @@ ClientLayerManager::ForwardTransaction()
|
||||
->SetDescriptorFromReply(ots.textureId(), ots.image());
|
||||
break;
|
||||
}
|
||||
case EditReply::TReplyTextureRemoved: {
|
||||
// XXX - to manage reuse of gralloc buffers, we'll need to add some
|
||||
// glue code here to find the TextureClient and invoke a callback to
|
||||
// let the camera know that the gralloc buffer is not used anymore on
|
||||
// the compositor side and that it can reuse it.
|
||||
const ReplyTextureRemoved& rep = reply.get_ReplyTextureRemoved();
|
||||
CompositableClient* compositable
|
||||
= static_cast<CompositableChild*>(rep.compositableChild())->GetCompositableClient();
|
||||
compositable->OnReplyTextureRemoved(rep.textureId());
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NS_RUNTIMEABORT("not reached");
|
||||
|
@ -24,8 +24,7 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
CompositableClient::CompositableClient(CompositableForwarder* aForwarder)
|
||||
: mNextTextureID(1)
|
||||
, mCompositableChild(nullptr)
|
||||
: mCompositableChild(nullptr)
|
||||
, mForwarder(aForwarder)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositableClient);
|
||||
@ -36,23 +35,6 @@ CompositableClient::~CompositableClient()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CompositableClient);
|
||||
Destroy();
|
||||
|
||||
FlushTexturesToRemoveCallbacks();
|
||||
MOZ_ASSERT(mTexturesToRemove.Length() == 0, "would leak textures pending for deletion");
|
||||
}
|
||||
|
||||
void
|
||||
CompositableClient::FlushTexturesToRemoveCallbacks()
|
||||
{
|
||||
std::map<uint64_t,TextureClientData*>::iterator it
|
||||
= mTexturesToRemoveCallbacks.begin();
|
||||
std::map<uint64_t,TextureClientData*>::iterator stop
|
||||
= mTexturesToRemoveCallbacks.end();
|
||||
for (; it != stop; ++it) {
|
||||
it->second->DeallocateSharedData(GetForwarder());
|
||||
delete it->second;
|
||||
}
|
||||
mTexturesToRemoveCallbacks.clear();
|
||||
}
|
||||
|
||||
LayersBackend
|
||||
@ -251,70 +233,16 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CompositableClient::NextTextureID()
|
||||
{
|
||||
++mNextTextureID;
|
||||
// 0 is always an invalid ID
|
||||
if (mNextTextureID == 0) {
|
||||
++mNextTextureID;
|
||||
}
|
||||
|
||||
return mNextTextureID;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositableClient::AddTextureClient(TextureClient* aClient)
|
||||
{
|
||||
aClient->SetID(NextTextureID());
|
||||
return mForwarder->AddTexture(this, aClient);
|
||||
}
|
||||
|
||||
void
|
||||
CompositableClient::RemoveTextureClient(TextureClient* aClient)
|
||||
{
|
||||
MOZ_ASSERT(aClient);
|
||||
mTexturesToRemove.AppendElement(TextureIDAndFlags(aClient->GetID(),
|
||||
aClient->GetFlags()));
|
||||
if (aClient->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
|
||||
TextureClientData* data = aClient->DropTextureData();
|
||||
if (data) {
|
||||
mTexturesToRemoveCallbacks[aClient->GetID()] = data;
|
||||
}
|
||||
}
|
||||
aClient->ClearID();
|
||||
aClient->MarkInvalid();
|
||||
}
|
||||
|
||||
void
|
||||
CompositableClient::OnReplyTextureRemoved(uint64_t aTextureID)
|
||||
{
|
||||
std::map<uint64_t,TextureClientData*>::iterator it
|
||||
= mTexturesToRemoveCallbacks.find(aTextureID);
|
||||
if (it != mTexturesToRemoveCallbacks.end()) {
|
||||
it->second->DeallocateSharedData(GetForwarder());
|
||||
delete it->second;
|
||||
mTexturesToRemoveCallbacks.erase(it);
|
||||
}
|
||||
return aClient->InitIPDLActor(mForwarder);
|
||||
}
|
||||
|
||||
void
|
||||
CompositableClient::OnTransaction()
|
||||
{
|
||||
for (unsigned i = 0; i < mTexturesToRemove.Length(); ++i) {
|
||||
const TextureIDAndFlags& texture = mTexturesToRemove[i];
|
||||
mForwarder->RemoveTexture(this, texture.mID, texture.mFlags);
|
||||
}
|
||||
mTexturesToRemove.Clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompositableChild::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (mCompositableClient && why == AbnormalShutdown) {
|
||||
mCompositableClient->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -132,12 +132,6 @@ public:
|
||||
*/
|
||||
virtual bool AddTextureClient(TextureClient* aClient);
|
||||
|
||||
/**
|
||||
* Tells the Compositor to delete the TextureHost corresponding to this
|
||||
* TextureClient.
|
||||
*/
|
||||
virtual void RemoveTextureClient(TextureClient* aClient);
|
||||
|
||||
/**
|
||||
* A hook for the Compositable to execute whatever it held off for next transaction.
|
||||
*/
|
||||
@ -148,47 +142,11 @@ public:
|
||||
*/
|
||||
virtual void OnDetach() {}
|
||||
|
||||
/**
|
||||
* When texture deallocation must happen on the client side, we need to first
|
||||
* ensure that the compositor has already let go of the data in order
|
||||
* to safely deallocate it.
|
||||
*
|
||||
* This is implemented by registering a callback to postpone deallocation or
|
||||
* recycling of the shared data.
|
||||
*
|
||||
* This hook is called when the compositor notifies the client that it is not
|
||||
* holding any more references to the shared data so that this compositable
|
||||
* can run the corresponding callback.
|
||||
*/
|
||||
void OnReplyTextureRemoved(uint64_t aTextureID);
|
||||
|
||||
/**
|
||||
* Run all he registered callbacks (see the comment for OnReplyTextureRemoved).
|
||||
* Only call this if you know what you are doing.
|
||||
*/
|
||||
void FlushTexturesToRemoveCallbacks();
|
||||
|
||||
/**
|
||||
* Our IPDL actor is being destroyed, get rid of any shmem resources now.
|
||||
*/
|
||||
virtual void OnActorDestroy() = 0;
|
||||
|
||||
protected:
|
||||
// return the next texture ID
|
||||
uint64_t NextTextureID();
|
||||
|
||||
struct TextureIDAndFlags {
|
||||
TextureIDAndFlags(uint64_t aID, TextureFlags aFlags)
|
||||
: mID(aID), mFlags(aFlags) {}
|
||||
uint64_t mID;
|
||||
TextureFlags mFlags;
|
||||
};
|
||||
// The textures to destroy in the next transaction;
|
||||
nsTArray<TextureIDAndFlags> mTexturesToRemove;
|
||||
std::map<uint64_t, TextureClientData*> mTexturesToRemoveCallbacks;
|
||||
uint64_t mNextTextureID;
|
||||
CompositableChild* mCompositableChild;
|
||||
CompositableForwarder* mForwarder;
|
||||
|
||||
friend class CompositableChild;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -222,7 +180,11 @@ public:
|
||||
return mCompositableClient;
|
||||
}
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
virtual void ActorDestroy(ActorDestroyReason) MOZ_OVERRIDE {
|
||||
if (mCompositableClient) {
|
||||
mCompositableClient->mCompositableChild = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void SetAsyncID(uint64_t aID) { mID = aID; }
|
||||
uint64_t GetAsyncID() const
|
||||
|
@ -148,9 +148,6 @@ ContentClientRemoteBuffer::EndPaint()
|
||||
// decided we didn't need one yet because the region to draw was empty.
|
||||
SetBufferProvider(nullptr);
|
||||
SetBufferProviderOnWhite(nullptr);
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
RemoveTextureClient(mOldTextures[i]);
|
||||
}
|
||||
mOldTextures.Clear();
|
||||
|
||||
if (mTextureClient) {
|
||||
@ -298,20 +295,6 @@ ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion)
|
||||
mFrontAndBackBufferDiffer = true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientRemoteBuffer::OnActorDestroy()
|
||||
{
|
||||
if (mTextureClient) {
|
||||
mTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
mTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::DestroyBuffers()
|
||||
{
|
||||
@ -497,21 +480,6 @@ DeprecatedContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeprecatedContentClientRemoteBuffer::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mDeprecatedTextureClientOnWhite) {
|
||||
mDeprecatedTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::CreateFrontBuffer(const nsIntRect& aBufferRect)
|
||||
{
|
||||
@ -666,26 +634,6 @@ ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentClientDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mTextureClient) {
|
||||
mTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mTextureClientOnWhite) {
|
||||
mTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClient) {
|
||||
mFrontClient->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClientOnWhite) {
|
||||
mFrontClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedContentClientDoubleBuffered::~DeprecatedContentClientDoubleBuffered()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
@ -786,26 +734,6 @@ DeprecatedContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpda
|
||||
DeprecatedContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion);
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentClientDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
if (mDeprecatedTextureClientOnWhite) {
|
||||
mDeprecatedTextureClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
for (size_t i = 0; i < mOldTextures.Length(); ++i) {
|
||||
mOldTextures[i]->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClient) {
|
||||
mFrontClient->OnActorDestroy();
|
||||
}
|
||||
if (mFrontClientOnWhite) {
|
||||
mFrontClientOnWhite->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
struct AutoDeprecatedTextureClient {
|
||||
AutoDeprecatedTextureClient()
|
||||
: mTexture(nullptr)
|
||||
|
@ -159,8 +159,6 @@ public:
|
||||
{
|
||||
MOZ_CRASH("Should not be called on non-remote ContentClient");
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE {}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -238,8 +236,6 @@ public:
|
||||
return mTextureInfo;
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void DestroyBuffers();
|
||||
|
||||
@ -340,8 +336,6 @@ public:
|
||||
return mTextureInfo;
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void DestroyBuffers();
|
||||
|
||||
@ -402,8 +396,6 @@ public:
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void CreateFrontBuffer(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
|
||||
@ -441,8 +433,6 @@ public:
|
||||
|
||||
virtual void SyncFrontBufferToBackBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void CreateFrontBufferAndNotify(const nsIntRect& aBufferRect) MOZ_OVERRIDE;
|
||||
virtual void DestroyFrontBuffer() MOZ_OVERRIDE;
|
||||
@ -549,8 +539,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE {}
|
||||
|
||||
private:
|
||||
|
||||
enum BufferType{
|
||||
|
@ -101,7 +101,7 @@ void
|
||||
ImageClientSingle::FlushAllImages(bool aExceptFront)
|
||||
{
|
||||
if (!aExceptFront && mFrontBuffer) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
@ -110,11 +110,11 @@ void
|
||||
ImageClientBuffered::FlushAllImages(bool aExceptFront)
|
||||
{
|
||||
if (!aExceptFront && mFrontBuffer) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
if (mBackBuffer) {
|
||||
RemoveTextureClient(mBackBuffer);
|
||||
mBackBuffer->ForceRemove();
|
||||
mBackBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
||||
}
|
||||
|
||||
if (mFrontBuffer) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
}
|
||||
mFrontBuffer = texture;
|
||||
if (!AddTextureClient(texture)) {
|
||||
@ -162,7 +162,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
||||
}
|
||||
|
||||
if (mFrontBuffer && mFrontBuffer->IsImmutable()) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
||||
gfx::IntSize size = gfx::IntSize(image->GetSize().width, image->GetSize().height);
|
||||
|
||||
if (mFrontBuffer) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer,
|
||||
|
||||
if (mFrontBuffer &&
|
||||
(mFrontBuffer->IsImmutable() || mFrontBuffer->GetSize() != size)) {
|
||||
RemoveTextureClient(mFrontBuffer);
|
||||
mFrontBuffer->ForceRemove();
|
||||
mFrontBuffer = nullptr;
|
||||
}
|
||||
|
||||
@ -280,25 +280,6 @@ ImageClientBuffered::UpdateImage(ImageContainer* aContainer,
|
||||
return ImageClientSingle::UpdateImage(aContainer, aContentFlags);
|
||||
}
|
||||
|
||||
void
|
||||
ImageClientSingle::OnActorDestroy()
|
||||
{
|
||||
if (mFrontBuffer) {
|
||||
mFrontBuffer->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageClientBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mFrontBuffer) {
|
||||
mFrontBuffer->OnActorDestroy();
|
||||
}
|
||||
if (mBackBuffer) {
|
||||
mBackBuffer->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ImageClientSingle::AddTextureClient(TextureClient* aTexture)
|
||||
{
|
||||
@ -484,14 +465,6 @@ ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedImageClientSingle::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureClient) {
|
||||
mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags)
|
||||
{
|
||||
|
@ -102,8 +102,6 @@ public:
|
||||
|
||||
virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
RefPtr<TextureClient> mFrontBuffer;
|
||||
// Some layers may want to enforce some flags to all their textures
|
||||
@ -127,8 +125,6 @@ public:
|
||||
|
||||
virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
RefPtr<TextureClient> mBackBuffer;
|
||||
};
|
||||
@ -173,8 +169,6 @@ public:
|
||||
virtual already_AddRefed<Image> CreateImage(const uint32_t *aFormats,
|
||||
uint32_t aNumFormats) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
RefPtr<DeprecatedTextureClient> mDeprecatedTextureClient;
|
||||
TextureInfo mTextureInfo;
|
||||
@ -216,8 +210,6 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE {}
|
||||
|
||||
protected:
|
||||
uint64_t mAsyncContainerID;
|
||||
ShadowableLayer* mLayer;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
||||
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
#include "mozilla/layers/PTextureChild.h"
|
||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
||||
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "ImageContainer.h" // for PlanarYCbCrImage, etc
|
||||
@ -38,6 +39,126 @@ using namespace mozilla::gfx;
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* TextureChild is the content-side incarnation of the PTexture IPDL actor.
|
||||
*
|
||||
* TextureChild is used to synchronize a texture client and its corresponding
|
||||
* TextureHost if needed (a TextureClient that is not shared with the compositor
|
||||
* does not have a TextureChild)
|
||||
*
|
||||
* During the deallocation phase, a TextureChild may hold its recently destroyed
|
||||
* TextureClient's data until the compositor side confirmed that it is safe to
|
||||
* deallocte or recycle the it.
|
||||
*/
|
||||
class TextureChild : public PTextureChild
|
||||
{
|
||||
public:
|
||||
TextureChild()
|
||||
: mForwarder(nullptr)
|
||||
, mTextureData(nullptr)
|
||||
, mTextureClient(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextureChild);
|
||||
}
|
||||
|
||||
~TextureChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TextureChild);
|
||||
}
|
||||
|
||||
bool Recv__delete__() MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Only used during the deallocation phase iff we need synchronization between
|
||||
* the client and host side for deallocation (that is, when the data is going
|
||||
* to be deallocated or recycled on the client side).
|
||||
*/
|
||||
void SetTextureData(TextureClientData* aData)
|
||||
{
|
||||
mTextureData = aData;
|
||||
}
|
||||
|
||||
void DeleteTextureData();
|
||||
|
||||
CompositableForwarder* GetForwarder() { return mForwarder; }
|
||||
|
||||
ISurfaceAllocator* GetAllocator() { return mForwarder; }
|
||||
|
||||
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
CompositableForwarder* mForwarder;
|
||||
TextureClientData* mTextureData;
|
||||
TextureClient* mTextureClient;
|
||||
|
||||
friend class TextureClient;
|
||||
};
|
||||
|
||||
void
|
||||
TextureChild::DeleteTextureData()
|
||||
{
|
||||
if (mTextureData) {
|
||||
mTextureData->DeallocateSharedData(GetAllocator());
|
||||
delete mTextureData;
|
||||
mTextureData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TextureChild::Recv__delete__()
|
||||
{
|
||||
DeleteTextureData();
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TextureChild::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (mTextureClient) {
|
||||
mTextureClient->mActor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
PTextureChild*
|
||||
TextureClient::CreateIPDLActor()
|
||||
{
|
||||
return new TextureChild();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
TextureClient::DestroyIPDLActor(PTextureChild* actor)
|
||||
{
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TextureClient::InitIPDLActor(CompositableForwarder* aForwarder)
|
||||
{
|
||||
MOZ_ASSERT(!mActor);
|
||||
MOZ_ASSERT(aForwarder);
|
||||
|
||||
SurfaceDescriptor desc;
|
||||
if (!ToSurfaceDescriptor(desc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mActor = static_cast<TextureChild*>(aForwarder->CreateEmptyTextureChild());
|
||||
mActor->mForwarder = aForwarder;
|
||||
mActor->mTextureClient = this;
|
||||
mShared = true;
|
||||
return mActor->SendInit(desc, GetFlags());
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
TextureClient::GetIPDLActor()
|
||||
{
|
||||
return mActor;
|
||||
}
|
||||
|
||||
class ShmemTextureClientData : public TextureClientData
|
||||
{
|
||||
public:
|
||||
@ -80,6 +201,7 @@ public:
|
||||
virtual void DeallocateSharedData(ISurfaceAllocator*)
|
||||
{
|
||||
delete[] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -111,14 +233,43 @@ ShmemTextureClient::DropTextureData()
|
||||
}
|
||||
|
||||
TextureClient::TextureClient(TextureFlags aFlags)
|
||||
: mID(0)
|
||||
: mActor(nullptr)
|
||||
, mFlags(aFlags)
|
||||
, mShared(false)
|
||||
, mValid(true)
|
||||
{}
|
||||
|
||||
TextureClient::~TextureClient()
|
||||
{}
|
||||
{
|
||||
// All the destruction code that may lead to virtual method calls must
|
||||
// be in Finalize() which is called just before the destructor.
|
||||
}
|
||||
|
||||
void TextureClient::ForceRemove()
|
||||
{
|
||||
if (mValid && mActor) {
|
||||
if (GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {
|
||||
mActor->SetTextureData(DropTextureData());
|
||||
mActor->SendRemoveTextureSync();
|
||||
mActor->DeleteTextureData();
|
||||
} else {
|
||||
mActor->SendRemoveTexture();
|
||||
}
|
||||
}
|
||||
MarkInvalid();
|
||||
}
|
||||
|
||||
void
|
||||
TextureClient::Finalize()
|
||||
{
|
||||
if (mActor) {
|
||||
// this will call ForceRemove in the right thread, using a sync proxy if needed
|
||||
mActor->GetForwarder()->RemoveTexture(this);
|
||||
|
||||
// mActor has a raw pointer to us, mActor->mTextureClient. Null it before we die.
|
||||
mActor->mTextureClient = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
TextureClient::ShouldDeallocateInDestructor() const
|
||||
@ -237,8 +388,8 @@ MemoryTextureClient::MemoryTextureClient(CompositableClient* aCompositable,
|
||||
MemoryTextureClient::~MemoryTextureClient()
|
||||
{
|
||||
MOZ_COUNT_DTOR(MemoryTextureClient);
|
||||
if (ShouldDeallocateInDestructor() && mBuffer) {
|
||||
// if the buffer has never been shared we must deallocate it or ir would
|
||||
if (mBuffer && ShouldDeallocateInDestructor()) {
|
||||
// if the buffer has never been shared we must deallocate it or it would
|
||||
// leak.
|
||||
GfxMemoryImageReporter::WillFree(mBuffer);
|
||||
delete mBuffer;
|
||||
@ -413,15 +564,6 @@ DeprecatedTextureClient::~DeprecatedTextureClient()
|
||||
MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::T__None, "Need to release surface!");
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureClient::OnActorDestroy()
|
||||
{
|
||||
if (ISurfaceAllocator::IsShmem(&mDescriptor)) {
|
||||
mDescriptor = SurfaceDescriptor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DeprecatedTextureClientShmem::DeprecatedTextureClientShmem(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo)
|
||||
: DeprecatedTextureClient(aForwarder, aTextureInfo)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsISupportsImpl.h" // for TextureImage::AddRef, etc
|
||||
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
|
||||
|
||||
class gfxReusableSurfaceWrapper;
|
||||
class gfxASurface;
|
||||
@ -39,6 +40,8 @@ class CompositableClient;
|
||||
class PlanarYCbCrImage;
|
||||
class PlanarYCbCrData;
|
||||
class Image;
|
||||
class PTextureChild;
|
||||
class TextureChild;
|
||||
|
||||
/**
|
||||
* TextureClient is the abstraction that allows us to share data between the
|
||||
@ -111,14 +114,13 @@ public:
|
||||
* host side, there is nothing to do.
|
||||
* On the other hand, if the client data must be deallocated on the client
|
||||
* side, the CompositableClient will ask the TextureClient to drop its shared
|
||||
* data in the form of a TextureClientData object. The compositable will keep
|
||||
* this object until it has received from the host side the confirmation that
|
||||
* the compositor is not using the texture and that it is completely safe to
|
||||
* deallocate the shared data.
|
||||
* data in the form of a TextureClientData object. This data will be kept alive
|
||||
* until the host side confirms that it is not using the data anymore and that
|
||||
* it is completely safe to deallocate the shared data.
|
||||
*
|
||||
* See:
|
||||
* - CompositableClient::RemoveTextureClient
|
||||
* - CompositableClient::OnReplyTextureRemoved
|
||||
* - The PTexture IPDL protocol
|
||||
* - CompositableChild in TextureClient.cpp
|
||||
*/
|
||||
class TextureClientData {
|
||||
public:
|
||||
@ -149,7 +151,8 @@ public:
|
||||
* In order to send several different buffers to the compositor side, use
|
||||
* several TextureClients.
|
||||
*/
|
||||
class TextureClient : public AtomicRefCounted<TextureClient>
|
||||
class TextureClient
|
||||
: public AtomicRefCountedWithFinalize<TextureClient>
|
||||
{
|
||||
public:
|
||||
TextureClient(TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
||||
@ -177,28 +180,15 @@ public:
|
||||
virtual bool ImplementsLocking() const { return false; }
|
||||
|
||||
/**
|
||||
* Sets this texture's ID.
|
||||
* Allocate and deallocate a TextureChild actor.
|
||||
*
|
||||
* This ID is used to match a texture client with his corresponding TextureHost.
|
||||
* Only the CompositableClient should be allowed to set or clear the ID.
|
||||
* Zero is always an invalid ID.
|
||||
* For a given compositableClient, there can never be more than one texture
|
||||
* client with the same non-zero ID.
|
||||
* Texture clients from different compositables may have the same ID.
|
||||
* TextureChild is an implementation detail of TextureHost that is not
|
||||
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
|
||||
* are for use with the maging IPDL protocols only (so that they can
|
||||
* implement AllocPextureChild and DeallocPTextureChild).
|
||||
*/
|
||||
void SetID(uint64_t aID)
|
||||
{
|
||||
MOZ_ASSERT(mID == 0 && aID != 0);
|
||||
mID = aID;
|
||||
mShared = true;
|
||||
}
|
||||
void ClearID()
|
||||
{
|
||||
MOZ_ASSERT(mID != 0);
|
||||
mID = 0;
|
||||
}
|
||||
|
||||
uint64_t GetID() const { return mID; }
|
||||
static PTextureChild* CreateIPDLActor();
|
||||
static bool DestroyIPDLActor(PTextureChild* actor);
|
||||
|
||||
virtual bool IsAllocated() const = 0;
|
||||
|
||||
@ -249,9 +239,36 @@ public:
|
||||
*/
|
||||
void MarkInvalid() { mValid = false; }
|
||||
|
||||
// If a texture client holds a reference to shmem, it should override this
|
||||
// method to forget about the shmem _without_ releasing it.
|
||||
virtual void OnActorDestroy() {}
|
||||
/**
|
||||
* Create and init the TextureChild/Parent IPDL actor pair.
|
||||
*
|
||||
* Should be called only once per TextureClient.
|
||||
*/
|
||||
bool InitIPDLActor(CompositableForwarder* aForwarder);
|
||||
|
||||
/**
|
||||
* Return a pointer to the IPDLActor.
|
||||
*
|
||||
* This is to be used with IPDL messages only. Do not store the returned
|
||||
* pointer.
|
||||
*/
|
||||
PTextureChild* GetIPDLActor();
|
||||
|
||||
/**
|
||||
* TODO[nical] doc!
|
||||
*/
|
||||
void ForceRemove();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Called once, just before the destructor.
|
||||
*
|
||||
* Here goes the shut-down code that uses virtual methods.
|
||||
* Must only be called by Release().
|
||||
*/
|
||||
void Finalize();
|
||||
|
||||
friend class AtomicRefCountedWithFinalize<TextureClient>;
|
||||
|
||||
protected:
|
||||
void AddFlags(TextureFlags aFlags)
|
||||
@ -260,10 +277,12 @@ protected:
|
||||
mFlags |= aFlags;
|
||||
}
|
||||
|
||||
uint64_t mID;
|
||||
TextureChild* mActor;
|
||||
TextureFlags mFlags;
|
||||
bool mShared;
|
||||
bool mValid;
|
||||
|
||||
friend class TextureChild;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -361,11 +380,6 @@ public:
|
||||
|
||||
ipc::Shmem& GetShmem() { return mShmem; }
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE
|
||||
{
|
||||
mShmem = ipc::Shmem();
|
||||
}
|
||||
|
||||
protected:
|
||||
ipc::Shmem mShmem;
|
||||
RefPtr<ISurfaceAllocator> mAllocator;
|
||||
@ -542,8 +556,6 @@ public:
|
||||
|
||||
virtual gfxContentType GetContentType() = 0;
|
||||
|
||||
void OnActorDestroy();
|
||||
|
||||
protected:
|
||||
DeprecatedTextureClient(CompositableForwarder* aForwarder,
|
||||
const TextureInfo& aTextureInfo);
|
||||
|
@ -252,14 +252,6 @@ public:
|
||||
static BasicTiledLayerBuffer OpenDescriptor(ISurfaceAllocator* aAllocator,
|
||||
const SurfaceDescriptorTiles& aDescriptor);
|
||||
|
||||
void OnActorDestroy()
|
||||
{
|
||||
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
|
||||
if (mRetainedTiles[i].IsPlaceholderTile()) continue;
|
||||
mRetainedTiles[i].mDeprecatedTextureClient->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
BasicTiledLayerTile ValidateTile(BasicTiledLayerTile aTile,
|
||||
const nsIntPoint& aTileRect,
|
||||
@ -349,12 +341,6 @@ public:
|
||||
};
|
||||
void LockCopyAndWrite(TiledBufferType aType);
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE
|
||||
{
|
||||
mTiledBuffer.OnActorDestroy();
|
||||
mLowPrecisionTiledBuffer.OnActorDestroy();
|
||||
}
|
||||
|
||||
private:
|
||||
BasicTiledLayerBuffer mTiledBuffer;
|
||||
BasicTiledLayerBuffer mLowPrecisionTiledBuffer;
|
||||
|
@ -36,82 +36,22 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
|
||||
CompositableHost::~CompositableHost()
|
||||
{
|
||||
MOZ_COUNT_DTOR(CompositableHost);
|
||||
|
||||
RefPtr<TextureHost> it = mFirstTexture;
|
||||
while (it) {
|
||||
if (!(it->GetFlags() & TEXTURE_DEALLOCATE_CLIENT)) {
|
||||
it->DeallocateSharedData();
|
||||
}
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::AddTextureHost(TextureHost* aTexture)
|
||||
CompositableHost::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
MOZ_ASSERT(aTexture);
|
||||
MOZ_ASSERT(GetTextureHost(aTexture->GetID()) == nullptr,
|
||||
"A texture is already present with this ID");
|
||||
RefPtr<TextureHost> second = mFirstTexture;
|
||||
mFirstTexture = aTexture;
|
||||
aTexture->SetNextSibling(second);
|
||||
if (!aTexture) {
|
||||
return;
|
||||
}
|
||||
aTexture->SetCompositor(GetCompositor());
|
||||
aTexture->SetCompositableBackendSpecificData(GetCompositableBackendSpecificData());
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::RemoveTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
uint64_t textureID = aTexture->GetID();
|
||||
if (mFirstTexture && mFirstTexture->GetID() == textureID) {
|
||||
mFirstTexture = mFirstTexture->GetNextSibling();
|
||||
aTexture->SetNextSibling(nullptr);
|
||||
}
|
||||
RefPtr<TextureHost> it = mFirstTexture;
|
||||
while (it) {
|
||||
if (it->GetNextSibling() &&
|
||||
it->GetNextSibling()->GetID() == textureID) {
|
||||
it->SetNextSibling(it->GetNextSibling()->GetNextSibling());
|
||||
aTexture->SetNextSibling(nullptr);
|
||||
}
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
if (!mFirstTexture && mBackendData) {
|
||||
mBackendData->ClearData();
|
||||
}
|
||||
}
|
||||
|
||||
TextureHost*
|
||||
CompositableHost::GetTextureHost(uint64_t aTextureID)
|
||||
{
|
||||
RefPtr<TextureHost> it = mFirstTexture;
|
||||
while (it) {
|
||||
if (it->GetID() == aTextureID) {
|
||||
return it;
|
||||
}
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::OnActorDestroy()
|
||||
{
|
||||
TextureHost* it = mFirstTexture;
|
||||
while (it) {
|
||||
it->OnActorDestroy();
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CompositableHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
mCompositor = aCompositor;
|
||||
RefPtr<TextureHost> it = mFirstTexture;
|
||||
while (!!it) {
|
||||
it->SetCompositor(aCompositor);
|
||||
it = it->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -264,13 +204,6 @@ void
|
||||
CompositableParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (mHost) {
|
||||
// XXX: sadness warning. We should be able to do this whenever we get ActorDestroy,
|
||||
// not just for abnormal shutdowns (which is the only case we _need_ to - so that
|
||||
// we don't double release our shmems). But, for some reason, that causes a
|
||||
// crash, we don't know why. (Bug 925773).
|
||||
if (why == AbnormalShutdown) {
|
||||
mHost->OnActorDestroy();
|
||||
}
|
||||
mHost->Detach(nullptr, CompositableHost::FORCE_DETACH);
|
||||
}
|
||||
}
|
||||
|
@ -108,12 +108,6 @@ public:
|
||||
mBackendData = aBackendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our IPDL actor is being destroyed, get rid of any shmem resources now and
|
||||
* don't worry about compositing anymore.
|
||||
*/
|
||||
virtual void OnActorDestroy();
|
||||
|
||||
// If base class overrides, it should still call the parent implementation
|
||||
virtual void SetCompositor(Compositor* aCompositor);
|
||||
|
||||
@ -294,23 +288,13 @@ public:
|
||||
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
|
||||
|
||||
void AddTextureHost(TextureHost* aTexture);
|
||||
virtual void UseTextureHost(TextureHost* aTexture) {}
|
||||
// If a texture host is flagged for deferred removal, the compositable will
|
||||
// get an option to run any cleanup code early, that is when it would have
|
||||
// been run if the texture host was not marked deferred.
|
||||
// If the compositable does not cleanup the texture host now, it is the
|
||||
// compositable's responsibility to cleanup the texture host before the
|
||||
// texture host dies.
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture);
|
||||
TextureHost* GetTextureHost(uint64_t aTextureID);
|
||||
virtual void UseTextureHost(TextureHost* aTexture);
|
||||
|
||||
protected:
|
||||
TextureInfo mTextureInfo;
|
||||
Compositor* mCompositor;
|
||||
Layer* mLayer;
|
||||
RefPtr<CompositableBackendSpecificData> mBackendData;
|
||||
RefPtr<TextureHost> mFirstTexture;
|
||||
bool mAttached;
|
||||
bool mKeepAttached;
|
||||
};
|
||||
|
@ -32,8 +32,6 @@ ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo)
|
||||
|
||||
ContentHostBase::~ContentHostBase()
|
||||
{
|
||||
DestroyTextureHost();
|
||||
DestroyTextureHostOnWhite();
|
||||
}
|
||||
|
||||
TextureHost*
|
||||
@ -42,50 +40,6 @@ ContentHostBase::GetAsTextureHost()
|
||||
return mTextureHost;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::DestroyTextureHost()
|
||||
{
|
||||
// The third clause in the if statement checks that we are in fact done with
|
||||
// this texture. We don't want to prematurely deallocate a texture we might
|
||||
// use again or double deallocate. Deallocation will happen in
|
||||
// RemoveTextureHost.
|
||||
// Note that GetTextureHost is linear in the number of texture hosts, but as
|
||||
// long as that number is small (I expect a maximum of 6 for now) then it
|
||||
// should be ok.
|
||||
if (mTextureHost &&
|
||||
mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED &&
|
||||
!GetTextureHost(mTextureHost->GetID())) {
|
||||
MOZ_ASSERT(!(mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
mTextureHost->DeallocateSharedData();
|
||||
}
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::DestroyTextureHostOnWhite()
|
||||
{
|
||||
if (mTextureHostOnWhite &&
|
||||
mTextureHostOnWhite->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED &&
|
||||
!GetTextureHost(mTextureHostOnWhite->GetID())) {
|
||||
MOZ_ASSERT(!(mTextureHostOnWhite->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
mTextureHostOnWhite->DeallocateSharedData();
|
||||
}
|
||||
mTextureHostOnWhite = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ContentHostBase::RemoveTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if ((aTexture->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED) &&
|
||||
!(mTextureHost && mTextureHost == aTexture) &&
|
||||
!(mTextureHostOnWhite && mTextureHostOnWhite == aTexture)) {
|
||||
MOZ_ASSERT(!(aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
aTexture->DeallocateSharedData();
|
||||
}
|
||||
|
||||
CompositableHost::RemoveTextureHost(aTexture);
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS AutoLockTextureHost
|
||||
{
|
||||
public:
|
||||
@ -286,10 +240,10 @@ void
|
||||
ContentHostBase::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
if (aTexture->GetFlags() & TEXTURE_ON_WHITE) {
|
||||
DestroyTextureHost();
|
||||
mTextureHost = nullptr;
|
||||
mTextureHostOnWhite = aTexture;
|
||||
} else {
|
||||
DestroyTextureHostOnWhite();
|
||||
mTextureHostOnWhite = nullptr;
|
||||
mTextureHost = aTexture;
|
||||
}
|
||||
}
|
||||
@ -335,18 +289,6 @@ ContentHostBase::Dump(FILE* aFile,
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ContentHostBase::OnActorDestroy()
|
||||
{
|
||||
if (mTextureHost) {
|
||||
mTextureHost->OnActorDestroy();
|
||||
}
|
||||
if (mTextureHostOnWhite) {
|
||||
mTextureHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
CompositableHost::OnActorDestroy();
|
||||
}
|
||||
|
||||
DeprecatedContentHostBase::DeprecatedContentHostBase(const TextureInfo& aTextureInfo)
|
||||
: ContentHost(aTextureInfo)
|
||||
, mPaintWillResample(false)
|
||||
@ -373,23 +315,6 @@ DeprecatedContentHostBase::DestroyFrontHost()
|
||||
mDeprecatedTextureHostOnWhite = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->OnActorDestroy();
|
||||
}
|
||||
if (mDeprecatedTextureHostOnWhite) {
|
||||
mDeprecatedTextureHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
if (mNewFrontHost) {
|
||||
mNewFrontHost->OnActorDestroy();
|
||||
}
|
||||
if (mNewFrontHostOnWhite) {
|
||||
mNewFrontHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostBase::Composite(EffectChain& aEffectChain,
|
||||
float aOpacity,
|
||||
@ -848,29 +773,6 @@ DeprecatedContentHostDoubleBuffered::DestroyTextures()
|
||||
// don't touch mDeprecatedTextureHost, we might need it for compositing
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::OnActorDestroy()
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->OnActorDestroy();
|
||||
}
|
||||
if (mDeprecatedTextureHostOnWhite) {
|
||||
mDeprecatedTextureHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
if (mNewFrontHost) {
|
||||
mNewFrontHost->OnActorDestroy();
|
||||
}
|
||||
if (mNewFrontHostOnWhite) {
|
||||
mNewFrontHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
if (mBackHost) {
|
||||
mBackHost->OnActorDestroy();
|
||||
}
|
||||
if (mBackHostOnWhite) {
|
||||
mBackHostOnWhite->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
||||
const nsIntRegion& aUpdated,
|
||||
|
@ -117,12 +117,8 @@ public:
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; }
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual nsIntPoint GetOriginOffset()
|
||||
{
|
||||
@ -131,10 +127,6 @@ protected:
|
||||
|
||||
bool PaintWillResample() { return mPaintWillResample; }
|
||||
|
||||
// These must be called before forgetting mTextureHost or mTextureHostOnWhite
|
||||
void DestroyTextureHost();
|
||||
void DestroyTextureHostOnWhite();
|
||||
|
||||
nsIntRect mBufferRect;
|
||||
nsIntPoint mBufferRotation;
|
||||
RefPtr<TextureHost> mTextureHost;
|
||||
@ -185,8 +177,6 @@ public:
|
||||
// destroy our front buffer so that we can continue to composite.
|
||||
virtual void DestroyTextures() = 0;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual nsIntPoint GetOriginOffset()
|
||||
{
|
||||
@ -259,8 +249,6 @@ public:
|
||||
const TextureInfo& aTextureInfo) MOZ_OVERRIDE;
|
||||
virtual void DestroyTextures() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
|
@ -38,16 +38,14 @@ ImageHost::~ImageHost() {}
|
||||
void
|
||||
ImageHost::UseTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
mFrontBuffer = aTexture;
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::RemoveTextureHost(TextureHost* aTexture)
|
||||
{
|
||||
CompositableHost::RemoveTextureHost(aTexture);
|
||||
if (mFrontBuffer && mFrontBuffer->GetID() == aTexture->GetID()) {
|
||||
mFrontBuffer = nullptr;
|
||||
if (mFrontBuffer) {
|
||||
// XXX - When we implement sharing textures between several compositables
|
||||
// we will need to not remove the compositor if there is another compositable
|
||||
// using the texture.
|
||||
mFrontBuffer->SetCompositor(nullptr);
|
||||
}
|
||||
CompositableHost::UseTextureHost(aTexture);
|
||||
mFrontBuffer = aTexture;
|
||||
}
|
||||
|
||||
TextureHost*
|
||||
@ -74,6 +72,10 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
if (!mFrontBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the front buffer has a compositor
|
||||
mFrontBuffer->SetCompositor(GetCompositor());
|
||||
|
||||
if (!mFrontBuffer->Lock()) {
|
||||
NS_WARNING("failed to lock front buffer");
|
||||
return;
|
||||
@ -154,6 +156,15 @@ ImageHost::Composite(EffectChain& aEffectChain,
|
||||
mFrontBuffer->Unlock();
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
if (mFrontBuffer && mCompositor != aCompositor) {
|
||||
mFrontBuffer->SetCompositor(aCompositor);
|
||||
}
|
||||
CompositableHost::SetCompositor(aCompositor);
|
||||
}
|
||||
|
||||
void
|
||||
ImageHost::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
|
@ -55,10 +55,10 @@ public:
|
||||
|
||||
virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTextureHost(TextureHost* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureHost* GetAsTextureHost() MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetPictureRect(const nsIntRect& aPictureRect) MOZ_OVERRIDE
|
||||
{
|
||||
mPictureRect = aPictureRect;
|
||||
@ -67,13 +67,6 @@ public:
|
||||
|
||||
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE
|
||||
{
|
||||
if (mFrontBuffer) {
|
||||
mFrontBuffer->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
@ -134,13 +127,6 @@ public:
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE
|
||||
{
|
||||
if (mDeprecatedTextureHost) {
|
||||
mDeprecatedTextureHost->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
|
@ -18,12 +18,68 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsAutoPtr.h" // for nsRefPtr
|
||||
#include "nsPrintfCString.h" // for nsPrintfCString
|
||||
#include "mozilla/layers/PTextureParent.h"
|
||||
|
||||
struct nsIntPoint;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* TextureParent is the host-side IPDL glue between TextureClient and TextureHost.
|
||||
* It is an IPDL actor just like LayerParent, CompositableParent, etc.
|
||||
*/
|
||||
class TextureParent : public PTextureParent
|
||||
{
|
||||
public:
|
||||
TextureParent(ISurfaceAllocator* aAllocator);
|
||||
|
||||
~TextureParent();
|
||||
|
||||
bool RecvInit(const SurfaceDescriptor& aSharedData,
|
||||
const TextureFlags& aFlags) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvRemoveTexture() MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvRemoveTextureSync() MOZ_OVERRIDE;
|
||||
|
||||
TextureHost* GetTextureHost() { return mTextureHost; }
|
||||
|
||||
void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
ISurfaceAllocator* mAllocator;
|
||||
RefPtr<TextureHost> mTextureHost;
|
||||
};
|
||||
|
||||
// static
|
||||
PTextureParent*
|
||||
TextureHost::CreateIPDLActor(ISurfaceAllocator* aAllocator)
|
||||
{
|
||||
return new TextureParent(aAllocator);
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
TextureHost::DestroyIPDLActor(PTextureParent* actor)
|
||||
{
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
TextureHost::SendDeleteIPDLActor(PTextureParent* actor)
|
||||
{
|
||||
return PTextureParent::Send__delete__(actor);
|
||||
}
|
||||
|
||||
// static
|
||||
TextureHost*
|
||||
TextureHost::AsTextureHost(PTextureParent* actor)
|
||||
{
|
||||
return actor? static_cast<TextureParent*>(actor)->mTextureHost : nullptr;
|
||||
}
|
||||
|
||||
// implemented in TextureOGL.cpp
|
||||
TemporaryRef<DeprecatedTextureHost> CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
|
||||
uint32_t aDeprecatedTextureHostFlags,
|
||||
@ -81,35 +137,32 @@ DeprecatedTextureHost::CreateDeprecatedTextureHost(SurfaceDescriptorType aDescri
|
||||
}
|
||||
|
||||
// implemented in TextureHostOGL.cpp
|
||||
TemporaryRef<TextureHost> CreateTextureHostOGL(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
TemporaryRef<TextureHost> CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
// implemented in TextureHostBasic.cpp
|
||||
TemporaryRef<TextureHost> CreateTextureHostBasic(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
TemporaryRef<TextureHost> CreateTextureHostBasic(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
// static
|
||||
TemporaryRef<TextureHost>
|
||||
TextureHost::Create(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
TextureHost::Create(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
switch (Compositor::GetBackend()) {
|
||||
case LAYERS_OPENGL:
|
||||
return CreateTextureHostOGL(aID, aDesc, aDeallocator, aFlags);
|
||||
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
|
||||
case LAYERS_BASIC:
|
||||
return CreateTextureHostBasic(aID, aDesc, aDeallocator, aFlags);
|
||||
return CreateTextureHostBasic(aDesc, aDeallocator, aFlags);
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
case LAYERS_NONE:
|
||||
// Power on video reqests to allocate TextureHost,
|
||||
// when Compositor is still not present. This is a very hacky workaround.
|
||||
// See Bug 944420.
|
||||
return CreateTextureHostOGL(aID, aDesc, aDeallocator, aFlags);
|
||||
return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
case LAYERS_D3D11:
|
||||
@ -123,8 +176,7 @@ TextureHost::Create(uint64_t aID,
|
||||
}
|
||||
|
||||
TemporaryRef<TextureHost>
|
||||
CreateBackendIndependentTextureHost(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
@ -132,8 +184,7 @@ CreateBackendIndependentTextureHost(uint64_t aID,
|
||||
switch (aDesc.type()) {
|
||||
case SurfaceDescriptor::TSurfaceDescriptorShmem: {
|
||||
const SurfaceDescriptorShmem& descriptor = aDesc.get_SurfaceDescriptorShmem();
|
||||
result = new ShmemTextureHost(aID,
|
||||
descriptor.data(),
|
||||
result = new ShmemTextureHost(descriptor.data(),
|
||||
descriptor.format(),
|
||||
aDeallocator,
|
||||
aFlags);
|
||||
@ -141,8 +192,7 @@ CreateBackendIndependentTextureHost(uint64_t aID,
|
||||
}
|
||||
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
|
||||
const SurfaceDescriptorMemory& descriptor = aDesc.get_SurfaceDescriptorMemory();
|
||||
result = new MemoryTextureHost(aID,
|
||||
reinterpret_cast<uint8_t*>(descriptor.data()),
|
||||
result = new MemoryTextureHost(reinterpret_cast<uint8_t*>(descriptor.data()),
|
||||
descriptor.format(),
|
||||
aFlags);
|
||||
break;
|
||||
@ -161,17 +211,23 @@ TextureHost::SetCompositableBackendSpecificData(CompositableBackendSpecificData*
|
||||
}
|
||||
|
||||
|
||||
TextureHost::TextureHost(uint64_t aID,
|
||||
TextureFlags aFlags)
|
||||
: mID(aID)
|
||||
, mNextTexture(nullptr)
|
||||
, mFlags(aFlags)
|
||||
TextureHost::TextureHost(TextureFlags aFlags)
|
||||
: mFlags(aFlags)
|
||||
{}
|
||||
|
||||
TextureHost::~TextureHost()
|
||||
{
|
||||
}
|
||||
|
||||
void TextureHost::Finalize()
|
||||
{
|
||||
if (GetFlags() & TEXTURE_DEALLOCATE_DEFERRED) {
|
||||
MOZ_ASSERT(!(GetFlags() & TEXTURE_DEALLOCATE_CLIENT));
|
||||
DeallocateSharedData();
|
||||
DeallocateDeviceData();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextureHost::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
@ -253,7 +309,7 @@ DeprecatedTextureHost::SwapTextures(const SurfaceDescriptor& aImage,
|
||||
}
|
||||
|
||||
void
|
||||
DeprecatedTextureHost::OnActorDestroy()
|
||||
DeprecatedTextureHost::OnShutdown()
|
||||
{
|
||||
if (ISurfaceAllocator::IsShmem(mBuffer)) {
|
||||
*mBuffer = SurfaceDescriptor();
|
||||
@ -279,10 +335,9 @@ DeprecatedTextureHost::SetBuffer(SurfaceDescriptor* aBuffer, ISurfaceAllocator*
|
||||
mDeAllocator = aAllocator;
|
||||
}
|
||||
|
||||
BufferTextureHost::BufferTextureHost(uint64_t aID,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
BufferTextureHost::BufferTextureHost(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags)
|
||||
: TextureHost(aID, aFlags)
|
||||
: TextureHost(aFlags)
|
||||
, mCompositor(nullptr)
|
||||
, mFormat(aFormat)
|
||||
, mUpdateSerial(1)
|
||||
@ -384,6 +439,19 @@ BufferTextureHost::MaybeUpload(nsIntRegion *aRegion)
|
||||
bool
|
||||
BufferTextureHost::Upload(nsIntRegion *aRegion)
|
||||
{
|
||||
if (!GetBuffer()) {
|
||||
// We don't have a buffer; a possible cause is that the IPDL actor
|
||||
// is already dead. This inevitably happens as IPDL actors can die
|
||||
// at any time, so we want to silently return in this case.
|
||||
return false;
|
||||
}
|
||||
if (!mCompositor) {
|
||||
NS_WARNING("Tried to upload without a compositor. Skipping texture upload...");
|
||||
// If we are in this situation it means we should have called SetCompositor
|
||||
// earlier. It is conceivable that on certain rare conditions with async-video
|
||||
// we may end up here for the first frame, but this should not happen repeatedly.
|
||||
return false;
|
||||
}
|
||||
if (mFormat == gfx::FORMAT_UNKNOWN) {
|
||||
NS_WARNING("BufferTextureHost: unsupported format!");
|
||||
return false;
|
||||
@ -494,12 +562,11 @@ BufferTextureHost::GetAsSurface()
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
ShmemTextureHost::ShmemTextureHost(uint64_t aID,
|
||||
const ipc::Shmem& aShmem,
|
||||
ShmemTextureHost::ShmemTextureHost(const ipc::Shmem& aShmem,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureHost(aID, aFormat, aFlags)
|
||||
: BufferTextureHost(aFormat, aFlags)
|
||||
, mShmem(new ipc::Shmem(aShmem))
|
||||
, mDeallocator(aDeallocator)
|
||||
{
|
||||
@ -520,12 +587,22 @@ ShmemTextureHost::DeallocateSharedData()
|
||||
MOZ_ASSERT(mDeallocator,
|
||||
"Shared memory would leak without a ISurfaceAllocator");
|
||||
mDeallocator->DeallocShmem(*mShmem);
|
||||
delete mShmem;
|
||||
mShmem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShmemTextureHost::OnActorDestroy()
|
||||
ShmemTextureHost::ForgetSharedData()
|
||||
{
|
||||
if (mShmem) {
|
||||
delete mShmem;
|
||||
mShmem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShmemTextureHost::OnShutdown()
|
||||
{
|
||||
delete mShmem;
|
||||
mShmem = nullptr;
|
||||
@ -536,11 +613,10 @@ uint8_t* ShmemTextureHost::GetBuffer()
|
||||
return mShmem ? mShmem->get<uint8_t>() : nullptr;
|
||||
}
|
||||
|
||||
MemoryTextureHost::MemoryTextureHost(uint64_t aID,
|
||||
uint8_t* aBuffer,
|
||||
MemoryTextureHost::MemoryTextureHost(uint8_t* aBuffer,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureHost(aID, aFormat, aFlags)
|
||||
: BufferTextureHost(aFormat, aFlags)
|
||||
, mBuffer(aBuffer)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MemoryTextureHost);
|
||||
@ -564,10 +640,82 @@ MemoryTextureHost::DeallocateSharedData()
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
MemoryTextureHost::ForgetSharedData()
|
||||
{
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
|
||||
uint8_t* MemoryTextureHost::GetBuffer()
|
||||
{
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
TextureParent::TextureParent(ISurfaceAllocator* aAllocator)
|
||||
: mAllocator(aAllocator)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TextureParent);
|
||||
}
|
||||
|
||||
TextureParent::~TextureParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(TextureParent);
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
TextureParent::RecvInit(const SurfaceDescriptor& aSharedData,
|
||||
const TextureFlags& aFlags)
|
||||
{
|
||||
mTextureHost = TextureHost::Create(aSharedData,
|
||||
mAllocator,
|
||||
aFlags);
|
||||
return !!mTextureHost;
|
||||
}
|
||||
|
||||
bool
|
||||
TextureParent::RecvRemoveTexture()
|
||||
{
|
||||
return PTextureParent::Send__delete__(this);
|
||||
}
|
||||
|
||||
bool
|
||||
TextureParent::RecvRemoveTextureSync()
|
||||
{
|
||||
// we don't need to send a reply in the synchronous case since the child side
|
||||
// has the guarantee that this message has been handled synchronously.
|
||||
return PTextureParent::Send__delete__(this);
|
||||
}
|
||||
|
||||
void
|
||||
TextureParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
if (!mTextureHost) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (why) {
|
||||
case AncestorDeletion:
|
||||
NS_WARNING("PTexture deleted after ancestor");
|
||||
// fall-through to deletion path
|
||||
case Deletion:
|
||||
if (!(mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) &&
|
||||
!(mTextureHost->GetFlags() & TEXTURE_DEALLOCATE_DEFERRED)) {
|
||||
mTextureHost->DeallocateSharedData();
|
||||
}
|
||||
break;
|
||||
|
||||
case NormalShutdown:
|
||||
case AbnormalShutdown:
|
||||
mTextureHost->OnShutdown();
|
||||
break;
|
||||
|
||||
case FailedConstructor:
|
||||
NS_RUNTIMEABORT("FailedConstructor isn't possible in PTexture");
|
||||
}
|
||||
mTextureHost->ForgetSharedData();
|
||||
mTextureHost = nullptr;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsRegion.h" // for nsIntRegion
|
||||
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "nscore.h" // for nsACString
|
||||
#include "mozilla/layers/AtomicRefCountedWithFinalize.h"
|
||||
|
||||
class gfxImageSurface;
|
||||
class gfxReusableSurfaceWrapper;
|
||||
@ -46,8 +47,9 @@ class TextureSourceOGL;
|
||||
class TextureSourceD3D9;
|
||||
class TextureSourceD3D11;
|
||||
class TextureSourceBasic;
|
||||
class TextureParent;
|
||||
class DataTextureSource;
|
||||
class PTextureParent;
|
||||
class TextureParent;
|
||||
|
||||
/**
|
||||
* A view on a TextureHost where the texture is internally represented as tiles
|
||||
@ -257,19 +259,28 @@ private:
|
||||
* The Lock/Unlock mecanism here mirrors Lock/Unlock in TextureClient.
|
||||
*
|
||||
*/
|
||||
class TextureHost : public RefCounted<TextureHost>
|
||||
class TextureHost
|
||||
: public AtomicRefCountedWithFinalize<TextureHost>
|
||||
{
|
||||
/**
|
||||
* Called once, just before the destructor.
|
||||
*
|
||||
* Here goes the shut-down code that uses virtual methods.
|
||||
* Must only be called by Release().
|
||||
*/
|
||||
void Finalize();
|
||||
|
||||
friend class AtomicRefCountedWithFinalize<TextureHost>;
|
||||
|
||||
public:
|
||||
TextureHost(uint64_t aID,
|
||||
TextureFlags aFlags);
|
||||
TextureHost(TextureFlags aFlags);
|
||||
|
||||
virtual ~TextureHost();
|
||||
|
||||
/**
|
||||
* Factory method.
|
||||
*/
|
||||
static TemporaryRef<TextureHost> Create(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
static TemporaryRef<TextureHost> Create(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
@ -332,27 +343,15 @@ public:
|
||||
virtual void DeallocateSharedData() {}
|
||||
|
||||
/**
|
||||
* An ID to differentiate TextureHosts of a given CompositableHost.
|
||||
* Should be overridden in order to force the TextureHost to drop all references
|
||||
* to it's shared data.
|
||||
*
|
||||
* A TextureHost and its corresponding TextureClient always have the same ID.
|
||||
* TextureHosts of a given CompositableHost always have different IDs.
|
||||
* TextureHosts of different CompositableHosts, may have the same ID.
|
||||
* Zero is always an invalid ID.
|
||||
* This is important to ensure the correctness of the deallocation protocol.
|
||||
*/
|
||||
uint64_t GetID() const { return mID; }
|
||||
virtual void ForgetSharedData() {}
|
||||
|
||||
virtual gfx::IntSize GetSize() const = 0;
|
||||
|
||||
/**
|
||||
* TextureHosts are kept as a linked list in their compositable
|
||||
* XXX - This is just a poor man's PTexture. The purpose of this list is
|
||||
* to keep TextureHost alive which should be independent from compositables.
|
||||
* It will be removed when we add the PTetxure protocol (which will more
|
||||
* gracefully handle the lifetime of textures). See bug 897452
|
||||
*/
|
||||
TextureHost* GetNextSibling() const { return mNextTexture; }
|
||||
void SetNextSibling(TextureHost* aNext) { mNextTexture = aNext; }
|
||||
|
||||
/**
|
||||
* Debug facility.
|
||||
* XXX - cool kids use Moz2D. See bug 882113.
|
||||
@ -371,6 +370,27 @@ public:
|
||||
|
||||
TextureFlags GetFlags() { return mFlags; }
|
||||
|
||||
/**
|
||||
* Allocate and deallocate a TextureParent actor.
|
||||
*
|
||||
* TextureParent< is an implementation detail of TextureHost that is not
|
||||
* exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
|
||||
* are for use with the managing IPDL protocols only (so that they can
|
||||
* implement AllocPTextureParent and DeallocPTextureParent).
|
||||
*/
|
||||
static PTextureParent* CreateIPDLActor(ISurfaceAllocator* aAllocator);
|
||||
static bool DestroyIPDLActor(PTextureParent* actor);
|
||||
|
||||
/**
|
||||
* Destroy the TextureChild/Parent pair.
|
||||
*/
|
||||
static bool SendDeleteIPDLActor(PTextureParent* actor);
|
||||
|
||||
/**
|
||||
* Get the TextureHost corresponding to the actor passed in parameter.
|
||||
*/
|
||||
static TextureHost* AsTextureHost(PTextureParent* actor);
|
||||
|
||||
/**
|
||||
* Specific to B2G's Composer2D
|
||||
* XXX - more doc here
|
||||
@ -386,14 +406,12 @@ public:
|
||||
|
||||
// If a texture host holds a reference to shmem, it should override this method
|
||||
// to forget about the shmem _without_ releasing it.
|
||||
virtual void OnActorDestroy() {}
|
||||
virtual void OnShutdown() {}
|
||||
|
||||
virtual const char *Name() { return "TextureHost"; }
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
protected:
|
||||
uint64_t mID;
|
||||
RefPtr<TextureHost> mNextTexture;
|
||||
TextureFlags mFlags;
|
||||
RefPtr<CompositableBackendSpecificData> mCompositableBackendData;
|
||||
};
|
||||
@ -414,8 +432,7 @@ protected:
|
||||
class BufferTextureHost : public TextureHost
|
||||
{
|
||||
public:
|
||||
BufferTextureHost(uint64_t aID,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
BufferTextureHost(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags);
|
||||
|
||||
~BufferTextureHost();
|
||||
@ -470,8 +487,7 @@ protected:
|
||||
class ShmemTextureHost : public BufferTextureHost
|
||||
{
|
||||
public:
|
||||
ShmemTextureHost(uint64_t aID,
|
||||
const mozilla::ipc::Shmem& aShmem,
|
||||
ShmemTextureHost(const mozilla::ipc::Shmem& aShmem,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
@ -480,11 +496,13 @@ public:
|
||||
|
||||
virtual void DeallocateSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual void ForgetSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual const char *Name() MOZ_OVERRIDE { return "ShmemTextureHost"; }
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE;
|
||||
virtual void OnShutdown() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
mozilla::ipc::Shmem* mShmem;
|
||||
@ -500,8 +518,7 @@ protected:
|
||||
class MemoryTextureHost : public BufferTextureHost
|
||||
{
|
||||
public:
|
||||
MemoryTextureHost(uint64_t aID,
|
||||
uint8_t* aBuffer,
|
||||
MemoryTextureHost(uint8_t* aBuffer,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags);
|
||||
|
||||
@ -509,6 +526,8 @@ public:
|
||||
|
||||
virtual void DeallocateSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual void ForgetSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
|
||||
|
||||
virtual const char *Name() MOZ_OVERRIDE { return "MemoryTextureHost"; }
|
||||
@ -711,7 +730,7 @@ public:
|
||||
// see bug 865908 about fixing this.
|
||||
virtual void ForgetBuffer() {}
|
||||
|
||||
void OnActorDestroy();
|
||||
void OnShutdown();
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -814,8 +833,7 @@ private:
|
||||
* Not all SurfaceDescriptor types are supported
|
||||
*/
|
||||
TemporaryRef<TextureHost>
|
||||
CreateBackendIndependentTextureHost(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags);
|
||||
|
||||
|
@ -119,16 +119,6 @@ public:
|
||||
mCompositor = aCompositor;
|
||||
}
|
||||
|
||||
void OnActorDestroy()
|
||||
{
|
||||
Iterator end = TilesEnd();
|
||||
for (Iterator it = TilesBegin(); it != end; ++it) {
|
||||
if (it->mDeprecatedTextureHost) {
|
||||
it->mDeprecatedTextureHost->OnActorDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
TiledTexture ValidateTile(TiledTexture aTile,
|
||||
const nsIntPoint& aTileRect,
|
||||
@ -249,12 +239,6 @@ public:
|
||||
Compositor* aCompositor,
|
||||
AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnActorDestroy() MOZ_OVERRIDE
|
||||
{
|
||||
mVideoMemoryTiledBuffer.OnActorDestroy();
|
||||
mLowPrecisionVideoMemoryTiledBuffer.OnActorDestroy();
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
|
@ -29,6 +29,8 @@ class ThebesBufferData;
|
||||
class DeprecatedTextureClient;
|
||||
class TextureClient;
|
||||
class BasicTiledLayerBuffer;
|
||||
class PTextureChild;
|
||||
class TextureClientData;
|
||||
|
||||
/**
|
||||
* A transaction is a set of changes that happenned on the content side, that
|
||||
@ -93,6 +95,14 @@ public:
|
||||
virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptorTiles& aTiledDescriptor) = 0;
|
||||
|
||||
/**
|
||||
* Create an unitialized TextureChild.
|
||||
*
|
||||
* This does not trigger the the creation of a TextureHost on the compositor
|
||||
* side (see PTexture::Init).
|
||||
*/
|
||||
virtual PTextureChild* CreateEmptyTextureChild() = 0;
|
||||
|
||||
/**
|
||||
* Communicate to the compositor that the texture identified by aCompositable
|
||||
* and aTextureId has been updated to aImage.
|
||||
@ -150,25 +160,10 @@ public:
|
||||
virtual void DestroyedThebesBuffer(const SurfaceDescriptor& aBackBufferToDestroy) = 0;
|
||||
|
||||
/**
|
||||
* Tell the compositor side to create a TextureHost that corresponds to
|
||||
* aClient.
|
||||
* Tell the compositor side to delete the TextureHost corresponding to the
|
||||
* TextureClient passed in parameter.
|
||||
*/
|
||||
virtual bool AddTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aClient) = 0;
|
||||
|
||||
/**
|
||||
* Tell the compositor side to delete the TextureHost corresponding to
|
||||
* aTextureID.
|
||||
* By default the shared Data is deallocated along with the TextureHost, but
|
||||
* this behaviour can be overriden by the TextureFlags passed here.
|
||||
* XXX - This is kind of bad, but for now we have to do this, because of some
|
||||
* edge cases caused by the lifetime of the TextureHost being limited by the
|
||||
* lifetime of the CompositableHost. We should be able to remove this flags
|
||||
* parameter when we remove the lifetime constraint.
|
||||
*/
|
||||
virtual void RemoveTexture(CompositableClient* aCompositable,
|
||||
uint64_t aTextureID,
|
||||
TextureFlags aFlags) = 0;
|
||||
virtual void RemoveTexture(TextureClient* aTexture) = 0;
|
||||
|
||||
/**
|
||||
* Tell the CompositableHost on the compositor side what texture to use for
|
||||
|
@ -222,12 +222,8 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
}
|
||||
case CompositableOperation::TOpUseTexture: {
|
||||
const OpUseTexture& op = aEdit.get_OpUseTexture();
|
||||
if (op.textureID() == 0) {
|
||||
NS_WARNING("Invalid texture ID");
|
||||
break;
|
||||
}
|
||||
CompositableHost* compositable = AsCompositable(op);
|
||||
RefPtr<TextureHost> tex = compositable->GetTextureHost(op.textureID());
|
||||
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(op.textureParent());
|
||||
|
||||
MOZ_ASSERT(tex.get());
|
||||
compositable->UseTextureHost(tex);
|
||||
@ -237,75 +233,17 @@ CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpAddTexture: {
|
||||
const OpAddTexture& op = aEdit.get_OpAddTexture();
|
||||
if (op.textureID() == 0) {
|
||||
NS_WARNING("Invalid texture ID");
|
||||
break;
|
||||
}
|
||||
CompositableHost* compositable = AsCompositable(op);
|
||||
RefPtr<TextureHost> tex = TextureHost::Create(op.textureID(),
|
||||
op.data(),
|
||||
this,
|
||||
op.textureFlags());
|
||||
MOZ_ASSERT(tex.get());
|
||||
tex->SetCompositor(compositable->GetCompositor());
|
||||
// set CompositableBackendSpecificData
|
||||
// on gonk, create EGLImage if possible.
|
||||
// create EGLImage during buffer swap could reduce the graphic driver's task
|
||||
// during rendering.
|
||||
compositable->AddTextureHost(tex);
|
||||
MOZ_ASSERT(compositable->GetTextureHost(op.textureID()) == tex.get());
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpRemoveTexture: {
|
||||
const OpRemoveTexture& op = aEdit.get_OpRemoveTexture();
|
||||
if (op.textureID() == 0) {
|
||||
NS_WARNING("Invalid texture ID");
|
||||
break;
|
||||
}
|
||||
CompositableHost* compositable = AsCompositable(op);
|
||||
|
||||
RefPtr<TextureHost> texture = compositable->GetTextureHost(op.textureID());
|
||||
MOZ_ASSERT(texture);
|
||||
|
||||
TextureFlags flags = texture->GetFlags();
|
||||
|
||||
if (!(flags & TEXTURE_DEALLOCATE_CLIENT) &&
|
||||
!(flags & TEXTURE_DEALLOCATE_DEFERRED)) {
|
||||
texture->DeallocateSharedData();
|
||||
}
|
||||
|
||||
compositable->RemoveTextureHost(texture);
|
||||
|
||||
// if it is not the host that deallocates the shared data, then we need
|
||||
// to notfy the client side to tell when it is safe to deallocate or
|
||||
// reuse it.
|
||||
if (flags & TEXTURE_DEALLOCATE_CLIENT) {
|
||||
replyv.push_back(ReplyTextureRemoved(op.compositableParent(), nullptr,
|
||||
op.textureID()));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CompositableOperation::TOpUpdateTexture: {
|
||||
const OpUpdateTexture& op = aEdit.get_OpUpdateTexture();
|
||||
if (op.textureID() == 0) {
|
||||
NS_WARNING("Invalid texture ID");
|
||||
break;
|
||||
}
|
||||
CompositableHost* compositable = AsCompositable(op);
|
||||
MOZ_ASSERT(compositable);
|
||||
RefPtr<TextureHost> texture = compositable->GetTextureHost(op.textureID());
|
||||
RefPtr<TextureHost> texture = TextureHost::AsTextureHost(op.textureParent());
|
||||
MOZ_ASSERT(texture);
|
||||
|
||||
texture->Updated(op.region().type() == MaybeRegion::TnsIntRegion
|
||||
? &op.region().get_nsIntRegion()
|
||||
: nullptr); // no region means invalidate the entire surface
|
||||
|
||||
|
||||
compositable->UseTextureHost(texture);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "nsThreadUtils.h" // for NS_IsMainThread
|
||||
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
||||
#include "mozilla/StaticPtr.h" // for StaticRefPtr
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
|
||||
struct nsIntRect;
|
||||
|
||||
@ -103,46 +104,12 @@ struct AutoEndTransaction {
|
||||
CompositableTransaction* mTxn;
|
||||
};
|
||||
|
||||
bool
|
||||
ImageBridgeChild::AddTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture)
|
||||
{
|
||||
SurfaceDescriptor descriptor;
|
||||
if (!aTexture->ToSurfaceDescriptor(descriptor)) {
|
||||
NS_WARNING("ImageBridge: Failed to serialize a TextureClient");
|
||||
return false;
|
||||
}
|
||||
mTxn->AddEdit(OpAddTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID(),
|
||||
descriptor,
|
||||
aTexture->GetFlags()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::RemoveTexture(CompositableClient* aCompositable,
|
||||
uint64_t aTexture,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
|
||||
// if deallocation happens on the host side, we need the transaction
|
||||
// to be synchronous.
|
||||
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture,
|
||||
aFlags));
|
||||
} else {
|
||||
mTxn->AddNoSwapEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture,
|
||||
aFlags));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageBridgeChild::UseTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture)
|
||||
{
|
||||
mTxn->AddNoSwapEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID()));
|
||||
nullptr, aTexture->GetIPDLActor()));
|
||||
}
|
||||
|
||||
void
|
||||
@ -153,7 +120,7 @@ ImageBridgeChild::UpdatedTexture(CompositableClient* aCompositable,
|
||||
MaybeRegion region = aRegion ? MaybeRegion(*aRegion)
|
||||
: MaybeRegion(null_t());
|
||||
mTxn->AddNoSwapEdit(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID(),
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
region));
|
||||
}
|
||||
|
||||
@ -465,7 +432,6 @@ void ImageBridgeChild::FlushAllImagesNow(ImageClient* aClient, ImageContainer* a
|
||||
aClient->FlushAllImages(aExceptFront);
|
||||
aClient->OnTransaction();
|
||||
sImageBridgeChildSingleton->EndTransaction();
|
||||
aClient->FlushTexturesToRemoveCallbacks();
|
||||
}
|
||||
|
||||
void
|
||||
@ -523,18 +489,6 @@ ImageBridgeChild::EndTransaction()
|
||||
->SetDescriptorFromReply(ots.textureId(), ots.image());
|
||||
break;
|
||||
}
|
||||
case EditReply::TReplyTextureRemoved: {
|
||||
// We receive this reply when a Texture is removed and when it is not
|
||||
// the responsibility of the compositor side to deallocate memory.
|
||||
// This would be, for instance, the place to implement a mechanism to
|
||||
// notify the B2G camera that the gralloc buffer is not used by the
|
||||
// compositor anymore and that it can be recycled.
|
||||
const ReplyTextureRemoved& rep = reply.get_ReplyTextureRemoved();
|
||||
CompositableClient* compositable
|
||||
= static_cast<CompositableChild*>(rep.compositableChild())->GetCompositableClient();
|
||||
compositable->OnReplyTextureRemoved(rep.textureId());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NS_RUNTIMEABORT("not reached");
|
||||
}
|
||||
@ -940,5 +894,54 @@ ImageBridgeChild::AllocGrallocBuffer(const gfxIntSize& aSize,
|
||||
#endif
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
ImageBridgeChild::AllocPTextureChild()
|
||||
{
|
||||
return TextureClient::CreateIPDLActor();
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeChild::DeallocPTextureChild(PTextureChild* actor)
|
||||
{
|
||||
return TextureClient::DestroyIPDLActor(actor);
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
ImageBridgeChild::CreateEmptyTextureChild()
|
||||
{
|
||||
return SendPTextureConstructor();
|
||||
}
|
||||
|
||||
static void RemoveTextureSync(TextureClient* aTexture, ReentrantMonitor* aBarrier, bool* aDone)
|
||||
{
|
||||
aTexture->ForceRemove();
|
||||
|
||||
ReentrantMonitorAutoEnter autoMon(*aBarrier);
|
||||
*aDone = true;
|
||||
aBarrier->NotifyAll();
|
||||
}
|
||||
|
||||
void ImageBridgeChild::RemoveTexture(TextureClient* aTexture)
|
||||
{
|
||||
if (InImageBridgeChildThread()) {
|
||||
aTexture->ForceRemove();
|
||||
return;
|
||||
}
|
||||
|
||||
ReentrantMonitor barrier("RemoveTexture Lock");
|
||||
ReentrantMonitorAutoEnter autoMon(barrier);
|
||||
bool done = false;
|
||||
|
||||
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&RemoveTextureSync, aTexture, &barrier, &done));
|
||||
|
||||
// should stop the thread until the ImageClient has been created on
|
||||
// the other thread
|
||||
while (!done) {
|
||||
barrier.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
||||
|
@ -195,6 +195,12 @@ public:
|
||||
virtual bool
|
||||
DeallocPGrallocBufferChild(PGrallocBufferChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTextureChild*
|
||||
AllocPTextureChild() MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
DeallocPTextureChild(PTextureChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Allocate a gralloc SurfaceDescriptor remotely.
|
||||
*/
|
||||
@ -254,19 +260,6 @@ public:
|
||||
|
||||
virtual void Connect(CompositableClient* aCompositable) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::AddTexture
|
||||
*/
|
||||
virtual bool AddTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aClient) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::RemoveTexture
|
||||
*/
|
||||
virtual void RemoveTexture(CompositableClient* aCompositable,
|
||||
uint64_t aTextureID,
|
||||
TextureFlags aFlags) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::UpdatedTexture
|
||||
*/
|
||||
@ -280,6 +273,8 @@ public:
|
||||
virtual void UseTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aClient) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTexture(TextureClient* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
virtual void PaintedTiledLayerBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptorTiles& aTileLayerDescriptor) MOZ_OVERRIDE
|
||||
{
|
||||
@ -378,6 +373,8 @@ public:
|
||||
*/
|
||||
virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem);
|
||||
|
||||
virtual PTextureChild* CreateEmptyTextureChild() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
ImageBridgeChild();
|
||||
bool DispatchAllocShmemInternal(size_t aSize,
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl
|
||||
#include "nsTArrayForwardDeclare.h" // for InfallibleTArray
|
||||
#include "nsXULAppAPI.h" // for XRE_GetIOMessageLoop
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
|
||||
using namespace base;
|
||||
using namespace mozilla::ipc;
|
||||
@ -127,6 +128,16 @@ ImageBridgeParent::Create(Transport* aTransport, ProcessId aOtherProcess)
|
||||
|
||||
bool ImageBridgeParent::RecvStop()
|
||||
{
|
||||
// If there is any texture still alive we have to force it to deallocate the
|
||||
// device data (GL textures, etc.) now because shortly after SenStop() returns
|
||||
// on the child side the widget will be destroyed along with it's associated
|
||||
// GL context.
|
||||
InfallibleTArray<PTextureParent*> textures;
|
||||
ManagedPTextureParent(textures);
|
||||
for (unsigned int i = 0; i < textures.Length(); ++i) {
|
||||
RefPtr<TextureHost> tex = TextureHost::AsTextureHost(textures[i]);
|
||||
tex->DeallocateDeviceData();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -178,6 +189,18 @@ bool ImageBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
|
||||
return true;
|
||||
}
|
||||
|
||||
PTextureParent*
|
||||
ImageBridgeParent::AllocPTextureParent()
|
||||
{
|
||||
return TextureHost::CreateIPDLActor(this);
|
||||
}
|
||||
|
||||
bool
|
||||
ImageBridgeParent::DeallocPTextureParent(PTextureParent* actor)
|
||||
{
|
||||
return TextureHost::DestroyIPDLActor(actor);
|
||||
}
|
||||
|
||||
MessageLoop * ImageBridgeParent::GetMessageLoop() {
|
||||
return mMessageLoop;
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ public:
|
||||
uint64_t*) MOZ_OVERRIDE;
|
||||
bool DeallocPCompositableParent(PCompositableParent* aActor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTextureParent* AllocPTextureParent() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
bool RecvStop() MOZ_OVERRIDE;
|
||||
|
||||
MessageLoop * GetMessageLoop();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/mozalloc.h" // for operator delete, etc
|
||||
#include "nsDebug.h" // for NS_RUNTIMEABORT, etc
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "mozilla/layers/TextureClient.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -96,5 +97,17 @@ LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
|
||||
#endif
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
LayerTransactionChild::AllocPTextureChild()
|
||||
{
|
||||
return TextureClient::CreateIPDLActor();
|
||||
}
|
||||
|
||||
bool
|
||||
LayerTransactionChild::DeallocPTextureChild(PTextureChild* actor)
|
||||
{
|
||||
return TextureClient::DestroyIPDLActor(actor);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -58,6 +58,10 @@ protected:
|
||||
|
||||
virtual PCompositableChild* AllocPCompositableChild(const TextureInfo& aInfo) MOZ_OVERRIDE;
|
||||
virtual bool DeallocPCompositableChild(PCompositableChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTextureChild* AllocPTextureChild() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPTextureChild(PTextureChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
|
||||
|
||||
void AddIPDLReference() {
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc
|
||||
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
|
||||
typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
|
||||
|
||||
@ -600,5 +601,17 @@ LayerTransactionParent::DeallocPCompositableParent(PCompositableParent* actor)
|
||||
return true;
|
||||
}
|
||||
|
||||
PTextureParent*
|
||||
LayerTransactionParent::AllocPTextureParent()
|
||||
{
|
||||
return TextureHost::CreateIPDLActor(this);
|
||||
}
|
||||
|
||||
bool
|
||||
LayerTransactionParent::DeallocPTextureParent(PTextureParent* actor)
|
||||
{
|
||||
return TextureHost::DestroyIPDLActor(actor);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
@ -106,6 +106,9 @@ protected:
|
||||
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) MOZ_OVERRIDE;
|
||||
virtual bool DeallocPCompositableParent(PCompositableParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PTextureParent* AllocPTextureParent() MOZ_OVERRIDE;
|
||||
virtual bool DeallocPTextureParent(PTextureParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
void Attach(ShadowLayerParent* aLayerParent,
|
||||
CompositableParent* aCompositable,
|
||||
bool aIsAsyncVideo);
|
||||
|
@ -11,6 +11,7 @@ include protocol PCompositor;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PLayer;
|
||||
include protocol PRenderFrame;
|
||||
include protocol PTexture;
|
||||
|
||||
include "gfxipc/ShadowLayerUtils.h";
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
@ -300,34 +301,13 @@ struct OpUpdatePictureRect {
|
||||
nsIntRect picture;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides the compositor side with enough information to create a
|
||||
* TextureHost.
|
||||
*/
|
||||
struct OpAddTexture {
|
||||
PCompositable compositable;
|
||||
uint64_t textureID;
|
||||
SurfaceDescriptor data;
|
||||
uint32_t textureFlags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tells the compositor-side to remove the corresponding TextureHost and
|
||||
* deallocate its data.
|
||||
*/
|
||||
struct OpRemoveTexture {
|
||||
PCompositable compositable;
|
||||
uint64_t textureID;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* Tells the compositor-side which texture to use (for example, as front buffer
|
||||
* if there is several textures for double buffering)
|
||||
*/
|
||||
struct OpUseTexture {
|
||||
PCompositable compositable;
|
||||
uint64_t textureID;
|
||||
PTexture texture;
|
||||
};
|
||||
|
||||
union MaybeRegion {
|
||||
@ -337,7 +317,7 @@ union MaybeRegion {
|
||||
|
||||
struct OpUpdateTexture {
|
||||
PCompositable compositable;
|
||||
uint64_t textureID;
|
||||
PTexture texture;
|
||||
MaybeRegion region;
|
||||
};
|
||||
|
||||
@ -354,8 +334,6 @@ union CompositableOperation {
|
||||
|
||||
OpPaintTiledLayerBuffer;
|
||||
|
||||
OpAddTexture;
|
||||
OpRemoveTexture;
|
||||
OpUpdateTexture;
|
||||
OpUseTexture;
|
||||
};
|
||||
@ -399,18 +377,11 @@ struct OpTextureSwap {
|
||||
SurfaceDescriptor image;
|
||||
};
|
||||
|
||||
struct ReplyTextureRemoved {
|
||||
PCompositable compositable;
|
||||
uint64_t textureId;
|
||||
};
|
||||
|
||||
// Unit of a "changeset reply". This is a weird abstraction, probably
|
||||
// only to be used for buffer swapping.
|
||||
union EditReply {
|
||||
OpContentBufferSwap;
|
||||
OpTextureSwap;
|
||||
|
||||
ReplyTextureRemoved;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@ -7,6 +7,7 @@ include LayersSurfaces;
|
||||
include LayersMessages;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PCompositable;
|
||||
include protocol PTexture;
|
||||
include ProtocolTypes;
|
||||
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
@ -25,6 +26,7 @@ intr protocol PImageBridge
|
||||
{
|
||||
manages PCompositable;
|
||||
manages PGrallocBuffer;
|
||||
manages PTexture;
|
||||
|
||||
parent:
|
||||
|
||||
@ -49,6 +51,7 @@ parent:
|
||||
sync Stop();
|
||||
|
||||
sync PCompositable(TextureInfo aInfo) returns (uint64_t id);
|
||||
async PTexture();
|
||||
};
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ include protocol PCompositor;
|
||||
include protocol PGrallocBuffer;
|
||||
include protocol PLayer;
|
||||
include protocol PRenderFrame;
|
||||
include protocol PTexture;
|
||||
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
@ -33,6 +34,7 @@ sync protocol PLayerTransaction {
|
||||
manages PLayer;
|
||||
manages PCompositable;
|
||||
manages PGrallocBuffer;
|
||||
manages PTexture;
|
||||
|
||||
parent:
|
||||
/**
|
||||
@ -66,6 +68,7 @@ parent:
|
||||
returns (MaybeMagicGrallocBufferHandle handle);
|
||||
async PLayer();
|
||||
async PCompositable(TextureInfo aTextureInfo);
|
||||
async PTexture();
|
||||
|
||||
// The isFirstPaint flag can be used to indicate that this is the first update
|
||||
// for a particular document.
|
||||
|
46
gfx/layers/ipc/PTexture.ipdl
Normal file
46
gfx/layers/ipc/PTexture.ipdl
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=8 et :
|
||||
*/
|
||||
/* 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/. */
|
||||
|
||||
include LayersSurfaces;
|
||||
include protocol PLayerTransaction;
|
||||
include protocol PImageBridge;
|
||||
include protocol PGrallocBuffer;
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* PTexture is the IPDL glue between a TextureClient and a TextureHost.
|
||||
*/
|
||||
sync protocol PTexture {
|
||||
manager PImageBridge or PLayerTransaction;
|
||||
|
||||
child:
|
||||
async __delete__();
|
||||
|
||||
parent:
|
||||
/**
|
||||
* Set the shared data and create the TextureHost on the parent side.
|
||||
*/
|
||||
async Init(SurfaceDescriptor aSharedData, uint32_t aTextureFlags);
|
||||
|
||||
/**
|
||||
* Asynchronously tell the Compositor side to remove the texture.
|
||||
*/
|
||||
async RemoveTexture();
|
||||
|
||||
/**
|
||||
* Synchronously tell the compositor side to remove the texture.
|
||||
*/
|
||||
sync RemoveTextureSync();
|
||||
};
|
||||
|
||||
} // layers
|
||||
} // mozilla
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/CompositorTypes.h"
|
||||
#include "mozilla/layers/TextureHost.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
|
@ -15,10 +15,6 @@
|
||||
#include "mozilla/layers/PGrallocBufferChild.h"
|
||||
#include "mozilla/layers/PGrallocBufferParent.h"
|
||||
|
||||
// used only for hacky fix in gecko 23 for bug 862324
|
||||
// see bug 865908 about fixing this.
|
||||
#include "TextureHost.h"
|
||||
|
||||
#define MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
||||
#define MOZ_HAVE_PLATFORM_SPECIFIC_LAYER_BUFFERS
|
||||
|
||||
@ -29,6 +25,8 @@ namespace layers {
|
||||
|
||||
class MaybeMagicGrallocBufferHandle;
|
||||
class SurfaceDescriptorGralloc;
|
||||
class TextureHost;
|
||||
class DeprecatedTextureHost;
|
||||
|
||||
/**
|
||||
* This class exists to share the underlying GraphicBuffer resources
|
||||
|
@ -407,39 +407,6 @@ ShadowLayerForwarder::UpdatePictureRect(CompositableClient* aCompositable,
|
||||
mTxn->AddNoSwapPaint(OpUpdatePictureRect(nullptr, aCompositable->GetIPDLActor(), aRect));
|
||||
}
|
||||
|
||||
bool
|
||||
ShadowLayerForwarder::AddTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture)
|
||||
{
|
||||
SurfaceDescriptor descriptor;
|
||||
if (!aTexture->ToSurfaceDescriptor(descriptor)) {
|
||||
NS_WARNING("Failed to serialize a TextureClient");
|
||||
return false;
|
||||
}
|
||||
CheckSurfaceDescriptor(&descriptor);
|
||||
MOZ_ASSERT(aCompositable);
|
||||
MOZ_ASSERT(aCompositable->GetIPDLActor());
|
||||
MOZ_ASSERT(aTexture->GetFlags() != 0);
|
||||
mTxn->AddEdit(OpAddTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID(),
|
||||
descriptor,
|
||||
aTexture->GetFlags()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::RemoveTexture(CompositableClient* aCompositable,
|
||||
uint64_t aTexture,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture,
|
||||
aFlags));
|
||||
if (aFlags & TEXTURE_DEALLOCATE_CLIENT) {
|
||||
mTxn->MarkSyncTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture,
|
||||
@ -449,11 +416,11 @@ ShadowLayerForwarder::UpdatedTexture(CompositableClient* aCompositable,
|
||||
: MaybeRegion(null_t());
|
||||
if (aTexture->GetFlags() & TEXTURE_IMMEDIATE_UPLOAD) {
|
||||
mTxn->AddPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID(),
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
region));
|
||||
} else {
|
||||
mTxn->AddNoSwapPaint(OpUpdateTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID(),
|
||||
nullptr, aTexture->GetIPDLActor(),
|
||||
region));
|
||||
}
|
||||
}
|
||||
@ -463,7 +430,13 @@ ShadowLayerForwarder::UseTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aTexture)
|
||||
{
|
||||
mTxn->AddEdit(OpUseTexture(nullptr, aCompositable->GetIPDLActor(),
|
||||
aTexture->GetID()));
|
||||
nullptr, aTexture->GetIPDLActor()));
|
||||
}
|
||||
|
||||
void
|
||||
ShadowLayerForwarder::RemoveTexture(TextureClient* aTexture)
|
||||
{
|
||||
aTexture->ForceRemove();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -989,6 +962,13 @@ void ShadowLayerForwarder::AttachAsyncCompositable(uint64_t aCompositableID,
|
||||
aCompositableID));
|
||||
}
|
||||
|
||||
PTextureChild*
|
||||
ShadowLayerForwarder::CreateEmptyTextureChild()
|
||||
{
|
||||
return mShadowManager->SendPTextureConstructor();
|
||||
}
|
||||
|
||||
|
||||
void ShadowLayerForwarder::SetShadowManager(PLayerTransactionChild* aShadowManager)
|
||||
{
|
||||
mShadowManager = static_cast<LayerTransactionChild*>(aShadowManager);
|
||||
|
@ -149,6 +149,8 @@ public:
|
||||
*/
|
||||
void Connect(CompositableClient* aCompositable);
|
||||
|
||||
virtual PTextureChild* CreateEmptyTextureChild() MOZ_OVERRIDE;
|
||||
|
||||
virtual void CreatedSingleBuffer(CompositableClient* aCompositable,
|
||||
const SurfaceDescriptor& aDescriptor,
|
||||
const TextureInfo& aTextureInfo,
|
||||
@ -277,6 +279,8 @@ public:
|
||||
TextureIdentifier aTextureId,
|
||||
SurfaceDescriptor* aDescriptor) MOZ_OVERRIDE;
|
||||
|
||||
virtual void RemoveTexture(TextureClient* aTexture) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Same as above, but performs an asynchronous layer transaction
|
||||
*/
|
||||
@ -305,19 +309,6 @@ public:
|
||||
void UpdatePictureRect(CompositableClient* aCompositable,
|
||||
const nsIntRect& aRect);
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::AddTexture
|
||||
*/
|
||||
virtual bool AddTexture(CompositableClient* aCompositable,
|
||||
TextureClient* aClient) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::RemoveTexture
|
||||
*/
|
||||
virtual void RemoveTexture(CompositableClient* aCompositable,
|
||||
uint64_t aTextureID,
|
||||
TextureFlags aFlags) MOZ_OVERRIDE;
|
||||
|
||||
/**
|
||||
* See CompositableForwarder::UpdatedTexture
|
||||
*/
|
||||
|
@ -98,6 +98,7 @@ EXPORTS.gfxipc += [
|
||||
]
|
||||
|
||||
EXPORTS.mozilla.layers += [
|
||||
'AtomicRefCountedWithFinalize.h',
|
||||
'basic/BasicCompositor.h',
|
||||
'basic/MacIOSurfaceTextureHostBasic.h',
|
||||
'basic/TextureHostBasic.h',
|
||||
@ -186,6 +187,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'GrallocImages.cpp',
|
||||
'opengl/EGLImageHelpers.cpp',
|
||||
'opengl/GrallocTextureClient.cpp',
|
||||
'opengl/GrallocTextureHost.cpp',
|
||||
]
|
||||
@ -290,6 +292,7 @@ IPDL_SOURCES = [
|
||||
'ipc/PImageBridge.ipdl',
|
||||
'ipc/PLayer.ipdl',
|
||||
'ipc/PLayerTransaction.ipdl',
|
||||
'ipc/PTexture.ipdl',
|
||||
]
|
||||
|
||||
MSVC_ENABLE_PGO = True
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsServiceManagerUtils.h" // for do_GetService
|
||||
#include "nsString.h" // for nsString, nsAutoCString, etc
|
||||
#include "DecomposeIntoNoRepeatTriangles.h"
|
||||
#include "ScopedGLHelpers.h"
|
||||
|
||||
#if MOZ_ANDROID_OMTC
|
||||
#include "TexturePoolOGL.h"
|
||||
@ -65,6 +66,16 @@ static inline IntSize ns2gfxSize(const nsIntSize& s) {
|
||||
return IntSize(s.width, s.height);
|
||||
}
|
||||
|
||||
static void
|
||||
BindMaskForProgram(ShaderProgramOGL* aProgram, TextureSourceOGL* aSourceMask,
|
||||
GLenum aTexUnit, const gfx::Matrix4x4& aTransform)
|
||||
{
|
||||
MOZ_ASSERT(LOCAL_GL_TEXTURE0 <= aTexUnit && aTexUnit <= LOCAL_GL_TEXTURE31);
|
||||
aSourceMask->BindTexture(aTexUnit);
|
||||
aProgram->SetMaskTextureUnit(aTexUnit - LOCAL_GL_TEXTURE0);
|
||||
aProgram->SetMaskLayerTransform(aTransform);
|
||||
}
|
||||
|
||||
// Draw the given quads with the already selected shader. Texture coordinates
|
||||
// are supplied if the shader requires them.
|
||||
static void
|
||||
@ -978,28 +989,76 @@ CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
|
||||
}
|
||||
|
||||
struct MOZ_STACK_CLASS AutoBindTexture
|
||||
: public ScopedGLWrapper<AutoBindTexture>
|
||||
{
|
||||
AutoBindTexture() : mTexture(nullptr) {}
|
||||
AutoBindTexture(TextureSourceOGL* aTexture, GLenum aTextureUnit)
|
||||
: mTexture(nullptr) { Bind(aTexture, aTextureUnit); }
|
||||
~AutoBindTexture()
|
||||
friend struct ScopedGLWrapper<AutoBindTexture>;
|
||||
|
||||
protected:
|
||||
GLenum mTexUnit;
|
||||
GLuint mOldTexId;
|
||||
|
||||
public:
|
||||
explicit AutoBindTexture(GLContext* aGL)
|
||||
: ScopedGLWrapper<AutoBindTexture>(aGL)
|
||||
, mTexUnit(0)
|
||||
, mOldTexId(GLuint(-1))
|
||||
{ }
|
||||
|
||||
AutoBindTexture(GLContext* aGL, TextureSourceOGL* aTexture,
|
||||
GLenum aTexUnit = LOCAL_GL_TEXTURE0)
|
||||
: ScopedGLWrapper<AutoBindTexture>(aGL)
|
||||
, mTexUnit(0)
|
||||
, mOldTexId(GLuint(-1))
|
||||
{
|
||||
if (mTexture) {
|
||||
mTexture->UnbindTexture();
|
||||
}
|
||||
MOZ_ASSERT(aTexture);
|
||||
MOZ_ASSERT(mOldTexId == GLuint(-1));
|
||||
mTexUnit = aTexUnit;
|
||||
|
||||
ScopedBindTextureUnit autoBindTexUnit(mGL, aTexUnit);
|
||||
|
||||
mGL->GetUIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, &mOldTexId);
|
||||
aTexture->BindTexture(mTexUnit);
|
||||
}
|
||||
|
||||
void Bind(TextureSourceOGL* aTexture, GLenum aTextureUnit)
|
||||
protected:
|
||||
void UnwrapImpl()
|
||||
{
|
||||
MOZ_ASSERT(!mTexture);
|
||||
mTexture = aTexture;
|
||||
mTexture->BindTexture(aTextureUnit);
|
||||
}
|
||||
if (mOldTexId == GLuint(-1))
|
||||
return;
|
||||
|
||||
private:
|
||||
TextureSourceOGL* mTexture;
|
||||
ScopedBindTextureUnit autoBindTexUnit(mGL, mTexUnit);
|
||||
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mOldTexId);
|
||||
}
|
||||
};
|
||||
|
||||
struct MOZ_STACK_CLASS AutoSaveTexture
|
||||
: public ScopedGLWrapper<AutoSaveTexture>
|
||||
{
|
||||
friend struct ScopedGLWrapper<AutoSaveTexture>;
|
||||
|
||||
protected:
|
||||
GLenum mTexUnit;
|
||||
GLuint mOldTexId;
|
||||
|
||||
public:
|
||||
AutoSaveTexture(GLContext* aGL, GLenum aTexUnit = LOCAL_GL_TEXTURE0)
|
||||
: ScopedGLWrapper<AutoSaveTexture>(aGL)
|
||||
, mTexUnit(aTexUnit)
|
||||
, mOldTexId(GLuint(-1))
|
||||
{
|
||||
ScopedBindTextureUnit savedTexUnit(mGL, mTexUnit);
|
||||
mGL->GetUIntegerv(LOCAL_GL_TEXTURE_BINDING_2D, &mOldTexId);
|
||||
}
|
||||
|
||||
protected:
|
||||
void UnwrapImpl()
|
||||
{
|
||||
ScopedBindTextureUnit savedTexUnit(mGL, mTexUnit);
|
||||
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mOldTexId);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
CompositorOGL::DrawLines(const std::vector<gfx::Point>& aLines, const gfx::Rect& aClipRect,
|
||||
const gfx::Color& aColor,
|
||||
@ -1019,6 +1078,20 @@ CompositorOGL::DrawLines(const std::vector<gfx::Point>& aLines, const gfx::Rect&
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies aFilter to the texture currently bound to aTarget.
|
||||
*/
|
||||
void ApplyFilterToBoundTexture(GLContext* aGL,
|
||||
GraphicsFilter aFilter,
|
||||
GLuint aTarget = LOCAL_GL_TEXTURE_2D)
|
||||
{
|
||||
GLenum filter =
|
||||
(aFilter == GraphicsFilter::FILTER_NEAREST ? LOCAL_GL_NEAREST : LOCAL_GL_LINEAR);
|
||||
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, filter);
|
||||
aGL->fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
|
||||
void
|
||||
CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
const Rect& aClipRect,
|
||||
@ -1112,11 +1185,9 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
|
||||
program->SetRenderColor(color);
|
||||
|
||||
AutoBindTexture bindMask;
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE0);
|
||||
if (maskType != MaskNone) {
|
||||
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE0);
|
||||
program->SetMaskTextureUnit(0);
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE0, maskQuadTransform);
|
||||
}
|
||||
|
||||
BindAndDrawQuad(program, false, aDrawMode);
|
||||
@ -1137,7 +1208,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
}
|
||||
|
||||
AutoBindTexture bindSource(source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
|
||||
AutoBindTexture bindSource(mGLContext, source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
|
||||
|
||||
gfx3DMatrix textureTransform = source->AsSourceOGL()->GetTextureTransform();
|
||||
program->SetTextureTransform(textureTransform);
|
||||
@ -1155,18 +1226,15 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
filter = GraphicsFilter::FILTER_NEAREST;
|
||||
}
|
||||
#endif
|
||||
mGLContext->ApplyFilterToBoundTexture(source->AsSourceOGL()->GetTextureTarget(),
|
||||
filter);
|
||||
ApplyFilterToBoundTexture(mGLContext, filter,
|
||||
source->AsSourceOGL()->GetTextureTarget());
|
||||
|
||||
program->SetTextureUnit(0);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
|
||||
AutoBindTexture bindMask;
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1);
|
||||
if (maskType != MaskNone) {
|
||||
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE1);
|
||||
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE1);
|
||||
program->SetMaskTextureUnit(1);
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE1, maskQuadTransform);
|
||||
}
|
||||
|
||||
BindAndDrawQuadWithTextureRect(program, texturedEffect->mTextureCoords, source);
|
||||
@ -1193,22 +1261,20 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
|
||||
GraphicsFilter filter = ThebesFilter(effectYCbCr->mFilter);
|
||||
|
||||
AutoBindTexture bindY(sourceY, LOCAL_GL_TEXTURE0);
|
||||
mGLContext->ApplyFilterToBoundTexture(filter);
|
||||
AutoBindTexture bindCb(sourceCb, LOCAL_GL_TEXTURE1);
|
||||
mGLContext->ApplyFilterToBoundTexture(filter);
|
||||
AutoBindTexture bindCr(sourceCr, LOCAL_GL_TEXTURE2);
|
||||
mGLContext->ApplyFilterToBoundTexture(filter);
|
||||
AutoBindTexture bindY(mGLContext, sourceY, LOCAL_GL_TEXTURE0);
|
||||
ApplyFilterToBoundTexture(mGLContext, filter);
|
||||
AutoBindTexture bindCb(mGLContext, sourceCb, LOCAL_GL_TEXTURE1);
|
||||
ApplyFilterToBoundTexture(mGLContext, filter);
|
||||
AutoBindTexture bindCr(mGLContext, sourceCr, LOCAL_GL_TEXTURE2);
|
||||
ApplyFilterToBoundTexture(mGLContext, filter);
|
||||
|
||||
program->SetYCbCrTextureUnits(Y, Cb, Cr);
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
program->SetTextureTransform(gfx3DMatrix());
|
||||
|
||||
AutoBindTexture bindMask;
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE3);
|
||||
if (maskType != MaskNone) {
|
||||
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE3);
|
||||
program->SetMaskTextureUnit(3);
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE3, maskQuadTransform);
|
||||
}
|
||||
BindAndDrawQuadWithTextureRect(program, effectYCbCr->mTextureCoords, sourceYCbCr->GetSubSource(Y));
|
||||
}
|
||||
@ -1228,9 +1294,9 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
program->SetLayerOpacity(aOpacity);
|
||||
program->SetTextureTransform(gfx3DMatrix());
|
||||
|
||||
AutoBindTexture bindMask;
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE1);
|
||||
if (maskType != MaskNone) {
|
||||
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE1);
|
||||
sourceMask->BindTexture(LOCAL_GL_TEXTURE1);
|
||||
program->SetMaskTextureUnit(1);
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
}
|
||||
@ -1277,8 +1343,8 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
LOCAL_GL_ONE, LOCAL_GL_ONE);
|
||||
}
|
||||
|
||||
AutoBindTexture bindSourceOnBlack(sourceOnBlack, LOCAL_GL_TEXTURE0);
|
||||
AutoBindTexture bindSourceOnWhite(sourceOnWhite, LOCAL_GL_TEXTURE1);
|
||||
AutoBindTexture bindSourceOnBlack(mGLContext, sourceOnBlack, LOCAL_GL_TEXTURE0);
|
||||
AutoBindTexture bindSourceOnWhite(mGLContext, sourceOnWhite, LOCAL_GL_TEXTURE1);
|
||||
|
||||
program->Activate();
|
||||
program->SetBlackTextureUnit(0);
|
||||
@ -1288,11 +1354,9 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect,
|
||||
program->SetTextureTransform(gfx3DMatrix());
|
||||
program->SetRenderOffset(offset.x, offset.y);
|
||||
program->SetLayerQuadRect(aRect);
|
||||
AutoBindTexture bindMask;
|
||||
AutoSaveTexture bindMask(mGLContext, LOCAL_GL_TEXTURE2);
|
||||
if (maskType != MaskNone) {
|
||||
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE2);
|
||||
program->SetMaskTextureUnit(2);
|
||||
program->SetMaskLayerTransform(maskQuadTransform);
|
||||
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE2, maskQuadTransform);
|
||||
}
|
||||
|
||||
BindAndDrawQuadWithTextureRect(program, effectComponentAlpha->mTextureCoords, effectComponentAlpha->mOnBlack);
|
||||
|
50
gfx/layers/opengl/EGLImageHelpers.cpp
Normal file
50
gfx/layers/opengl/EGLImageHelpers.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#include "EGLImageHelpers.h"
|
||||
#include "GLContext.h"
|
||||
#include "GLLibraryEGL.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
namespace layers {
|
||||
|
||||
using namespace gl;
|
||||
|
||||
EGLImage
|
||||
EGLImageCreateFromNativeBuffer(GLContext* aGL, void* aBuffer)
|
||||
{
|
||||
EGLint attrs[] = {
|
||||
LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
|
||||
LOCAL_EGL_NONE, LOCAL_EGL_NONE
|
||||
};
|
||||
|
||||
GLLibraryEGL* egl = aGL->GetLibraryEGL();
|
||||
if (!egl) {
|
||||
NS_WARNING("Failed to obtain pointer to EGL. Returning EGL_NO_IMAGE.");
|
||||
return EGL_NO_IMAGE;
|
||||
}
|
||||
|
||||
return egl->fCreateImage(egl->Display(),
|
||||
EGL_NO_CONTEXT,
|
||||
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
|
||||
aBuffer, attrs);
|
||||
}
|
||||
|
||||
void
|
||||
EGLImageDestroy(GLContext* aGL, EGLImage aImage)
|
||||
{
|
||||
GLLibraryEGL* egl = aGL->GetLibraryEGL();
|
||||
if (!egl) {
|
||||
NS_WARNING("Failed to obtain pointer to EGL. Image not destroyed.");
|
||||
return;
|
||||
}
|
||||
|
||||
egl->fDestroyImage(egl->Display(), aImage);
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
25
gfx/layers/opengl/EGLImageHelpers.h
Normal file
25
gfx/layers/opengl/EGLImageHelpers.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef EGLIMAGEHELPERS_H_
|
||||
#define EGLIMAGEHELPERS_H_
|
||||
|
||||
typedef void* EGLImage;
|
||||
|
||||
namespace mozilla {
|
||||
namespace gl {
|
||||
class GLContext;
|
||||
}
|
||||
|
||||
namespace layers {
|
||||
|
||||
EGLImage EGLImageCreateFromNativeBuffer(gl::GLContext* aGL, void* aBuffer);
|
||||
void EGLImageDestroy(gl::GLContext* aGL, EGLImage aImage);
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // EGLIMAGEHELPERS_H_
|
@ -10,6 +10,7 @@
|
||||
#include "GrallocImages.h" // for GrallocImage
|
||||
#include "mozilla/layers/GrallocTextureHost.h"
|
||||
#include "mozilla/layers/CompositorOGL.h"
|
||||
#include "EGLImageHelpers.h"
|
||||
#include "GLContextUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -95,6 +96,7 @@ GrallocTextureSourceOGL::GrallocTextureSourceOGL(CompositorOGL* aCompositor,
|
||||
, mGraphicBuffer(aGraphicBuffer)
|
||||
, mEGLImage(0)
|
||||
, mFormat(aFormat)
|
||||
, mNeedsReset(true)
|
||||
{
|
||||
MOZ_ASSERT(mGraphicBuffer.get());
|
||||
}
|
||||
@ -112,7 +114,7 @@ void GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit)
|
||||
* android::GraphicBuffer, so that texturing will source the GraphicBuffer.
|
||||
*
|
||||
* To this effect we create an EGLImage wrapping this GraphicBuffer,
|
||||
* using CreateEGLImageForNativeBuffer, and then we tie this EGLImage to our
|
||||
* using EGLImageCreateFromNativeBuffer, and then we tie this EGLImage to our
|
||||
* texture using fEGLImageTargetTexture2D.
|
||||
*/
|
||||
MOZ_ASSERT(gl());
|
||||
@ -169,6 +171,14 @@ GrallocTextureSourceOGL::GetFormat() const {
|
||||
void
|
||||
GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData)
|
||||
{
|
||||
if (mCompositableBackendData != aBackendData) {
|
||||
mNeedsReset = true;
|
||||
}
|
||||
|
||||
if (!mNeedsReset) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCompositableBackendData = aBackendData;
|
||||
|
||||
if (!mCompositor) {
|
||||
@ -185,8 +195,9 @@ GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendS
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(textureTarget, tex);
|
||||
// create new EGLImage
|
||||
mEGLImage = gl()->CreateEGLImageForNativeBuffer(mGraphicBuffer->getNativeBuffer());
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage);
|
||||
mNeedsReset = false;
|
||||
}
|
||||
|
||||
gfx::IntSize
|
||||
@ -205,15 +216,14 @@ GrallocTextureSourceOGL::DeallocateDeviceData()
|
||||
if (mEGLImage) {
|
||||
MOZ_ASSERT(gl());
|
||||
gl()->MakeCurrent();
|
||||
gl()->DestroyEGLImage(mEGLImage);
|
||||
mEGLImage = 0;
|
||||
EGLImageDestroy(gl(), mEGLImage);
|
||||
mEGLImage = EGL_NO_IMAGE;
|
||||
}
|
||||
}
|
||||
|
||||
GrallocTextureHostOGL::GrallocTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags,
|
||||
const NewSurfaceDescriptorGralloc& aDescriptor)
|
||||
: TextureHost(aID, aFlags)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
mGrallocActor =
|
||||
static_cast<GrallocBufferActor*>(aDescriptor.bufferParent());
|
||||
@ -273,6 +283,14 @@ GrallocTextureHostOGL::DeallocateSharedData()
|
||||
PGrallocBufferParent::Send__delete__(mGrallocActor);
|
||||
}
|
||||
|
||||
void
|
||||
GrallocTextureHostOGL::ForgetSharedData()
|
||||
{
|
||||
if (mTextureSource) {
|
||||
mTextureSource->ForgetBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GrallocTextureHostOGL::DeallocateDeviceData()
|
||||
{
|
||||
@ -313,7 +331,7 @@ GrallocTextureSourceOGL::GetAsSurface() {
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(GetTextureTarget(), tex);
|
||||
if (!mEGLImage) {
|
||||
mEGLImage = gl()->CreateEGLImageForNativeBuffer(mGraphicBuffer->getNativeBuffer());
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
}
|
||||
gl()->fEGLImageTargetTexture2D(GetTextureTarget(), mEGLImage);
|
||||
|
||||
|
@ -32,8 +32,6 @@ public:
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE;
|
||||
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
||||
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; }
|
||||
@ -69,14 +67,14 @@ protected:
|
||||
android::sp<android::GraphicBuffer> mGraphicBuffer;
|
||||
EGLImage mEGLImage;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
bool mNeedsReset;
|
||||
};
|
||||
|
||||
class GrallocTextureHostOGL : public TextureHost
|
||||
{
|
||||
friend class GrallocBufferActor;
|
||||
public:
|
||||
GrallocTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
GrallocTextureHostOGL(TextureFlags aFlags,
|
||||
const NewSurfaceDescriptorGralloc& aDescriptor);
|
||||
|
||||
virtual ~GrallocTextureHostOGL();
|
||||
@ -91,6 +89,8 @@ public:
|
||||
|
||||
virtual void DeallocateSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual void ForgetSharedData() MOZ_OVERRIDE;
|
||||
|
||||
virtual void DeallocateDeviceData() MOZ_OVERRIDE;
|
||||
|
||||
virtual gfx::SurfaceFormat GetFormat() const;
|
||||
|
@ -34,10 +34,9 @@ MacIOSurfaceTextureSourceOGL::GetFormat() const
|
||||
return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
|
||||
}
|
||||
|
||||
MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor)
|
||||
: TextureHost(aID, aFlags)
|
||||
: TextureHost(aFlags)
|
||||
{
|
||||
mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
|
||||
aDescriptor.scaleFactor(),
|
||||
|
@ -41,8 +41,6 @@ public:
|
||||
|
||||
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
|
||||
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
||||
// MacIOSurfaceTextureSourceOGL doesn't own any gl texture
|
||||
virtual void DeallocateDeviceData() {}
|
||||
|
||||
@ -65,8 +63,7 @@ protected:
|
||||
class MacIOSurfaceTextureHostOGL : public TextureHost
|
||||
{
|
||||
public:
|
||||
MacIOSurfaceTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
|
||||
const SurfaceDescriptorMacIOSurface& aDescriptor);
|
||||
|
||||
// SharedTextureHostOGL doesn't own any GL texture
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/layers/CompositorOGL.h" // for CompositorOGL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
# include "GrallocImages.h" // for GrallocImage
|
||||
# include "EGLImageHelpers.h"
|
||||
#endif
|
||||
#include "mozilla/layers/ISurfaceAllocator.h"
|
||||
#include "mozilla/layers/YCbCrImageDataSerializer.h"
|
||||
@ -87,8 +88,7 @@ CreateDeprecatedTextureHostOGL(SurfaceDescriptorType aDescriptorType,
|
||||
|
||||
|
||||
TemporaryRef<TextureHost>
|
||||
CreateTextureHostOGL(uint64_t aID,
|
||||
const SurfaceDescriptor& aDesc,
|
||||
CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
@ -96,13 +96,13 @@ CreateTextureHostOGL(uint64_t aID,
|
||||
switch (aDesc.type()) {
|
||||
case SurfaceDescriptor::TSurfaceDescriptorShmem:
|
||||
case SurfaceDescriptor::TSurfaceDescriptorMemory: {
|
||||
result = CreateBackendIndependentTextureHost(aID, aDesc,
|
||||
result = CreateBackendIndependentTextureHost(aDesc,
|
||||
aDeallocator, aFlags);
|
||||
break;
|
||||
}
|
||||
case SurfaceDescriptor::TSharedTextureDescriptor: {
|
||||
const SharedTextureDescriptor& desc = aDesc.get_SharedTextureDescriptor();
|
||||
result = new SharedTextureHostOGL(aID, aFlags,
|
||||
result = new SharedTextureHostOGL(aFlags,
|
||||
desc.shareType(),
|
||||
desc.handle(),
|
||||
gfx::ToIntSize(desc.size()),
|
||||
@ -113,7 +113,7 @@ CreateTextureHostOGL(uint64_t aID,
|
||||
case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
|
||||
const SurfaceDescriptorMacIOSurface& desc =
|
||||
aDesc.get_SurfaceDescriptorMacIOSurface();
|
||||
result = new MacIOSurfaceTextureHostOGL(aID, aFlags, desc);
|
||||
result = new MacIOSurfaceTextureHostOGL(aFlags, desc);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -121,7 +121,7 @@ CreateTextureHostOGL(uint64_t aID,
|
||||
case SurfaceDescriptor::TNewSurfaceDescriptorGralloc: {
|
||||
const NewSurfaceDescriptorGralloc& desc =
|
||||
aDesc.get_NewSurfaceDescriptorGralloc();
|
||||
result = new GrallocTextureHostOGL(aID, aFlags, desc);
|
||||
result = new GrallocTextureHostOGL(aFlags, desc);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -376,13 +376,12 @@ SharedTextureSourceOGL::GetTextureTransform()
|
||||
return handleDetails.mTextureTransform;
|
||||
}
|
||||
|
||||
SharedTextureHostOGL::SharedTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
SharedTextureHostOGL::SharedTextureHostOGL(TextureFlags aFlags,
|
||||
gl::SharedTextureShareType aShareType,
|
||||
gl::SharedTextureHandle aSharedHandle,
|
||||
gfx::IntSize aSize,
|
||||
bool inverted)
|
||||
: TextureHost(aID, aFlags)
|
||||
: TextureHost(aFlags)
|
||||
, mSize(aSize)
|
||||
, mCompositor(nullptr)
|
||||
, mSharedHandle(aSharedHandle)
|
||||
@ -1156,9 +1155,9 @@ GrallocDeprecatedTextureHostOGL::DeleteTextures()
|
||||
{
|
||||
if (mEGLImage) {
|
||||
if (gl()->MakeCurrent()) {
|
||||
gl()->DestroyEGLImage(mEGLImage);
|
||||
EGLImageDestroy(gl(), mEGLImage);
|
||||
}
|
||||
mEGLImage = 0;
|
||||
mEGLImage = EGL_NO_IMAGE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1214,7 +1213,7 @@ GrallocDeprecatedTextureHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImag
|
||||
// create new EGLImage
|
||||
// create EGLImage during buffer swap could reduce the graphic driver's task
|
||||
// during rendering.
|
||||
mEGLImage = gl()->CreateEGLImageForNativeBuffer(mGraphicBuffer->getNativeBuffer());
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
gl()->fEGLImageTargetTexture2D(mTextureTarget, mEGLImage);
|
||||
|
||||
}
|
||||
@ -1387,7 +1386,7 @@ GrallocDeprecatedTextureHostOGL::GetAsSurface() {
|
||||
gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
|
||||
gl()->fBindTexture(mTextureTarget, tex);
|
||||
if (!mEGLImage) {
|
||||
mEGLImage = gl()->CreateEGLImageForNativeBuffer(mGraphicBuffer->getNativeBuffer());
|
||||
mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer());
|
||||
}
|
||||
gl()->fEGLImageTargetTexture2D(mTextureTarget, mEGLImage);
|
||||
|
||||
|
@ -127,8 +127,6 @@ public:
|
||||
|
||||
virtual void BindTexture(GLenum aTextureUnit) = 0;
|
||||
|
||||
virtual void UnbindTexture() = 0;
|
||||
|
||||
virtual gfx::IntSize GetSize() const = 0;
|
||||
|
||||
virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_2D; }
|
||||
@ -187,11 +185,6 @@ public:
|
||||
|
||||
virtual bool IsValid() const MOZ_OVERRIDE { return !!mTexImage; }
|
||||
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE
|
||||
{
|
||||
mTexImage->ReleaseTexture();
|
||||
}
|
||||
|
||||
virtual GLenum GetWrapMode() const MOZ_OVERRIDE
|
||||
{
|
||||
return mTexImage->GetWrapMode();
|
||||
@ -269,8 +262,6 @@ public:
|
||||
|
||||
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return mWrapMode; }
|
||||
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
||||
// SharedTextureSource doesn't own any gl texture
|
||||
virtual void DeallocateDeviceData() {}
|
||||
|
||||
@ -298,8 +289,7 @@ protected:
|
||||
class SharedTextureHostOGL : public TextureHost
|
||||
{
|
||||
public:
|
||||
SharedTextureHostOGL(uint64_t aID,
|
||||
TextureFlags aFlags,
|
||||
SharedTextureHostOGL(TextureFlags aFlags,
|
||||
gl::SharedTextureShareType aShareType,
|
||||
gl::SharedTextureHandle aSharedhandle,
|
||||
gfx::IntSize aSize,
|
||||
@ -407,11 +397,6 @@ public:
|
||||
mTexture->BindTexture(aTextureUnit);
|
||||
}
|
||||
|
||||
void UnbindTexture() MOZ_OVERRIDE
|
||||
{
|
||||
mTexture->ReleaseTexture();
|
||||
}
|
||||
|
||||
gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
||||
|
||||
GLenum GetWrapMode() const MOZ_OVERRIDE
|
||||
@ -529,10 +514,6 @@ public:
|
||||
{
|
||||
mTexImage->BindTexture(aUnit);
|
||||
}
|
||||
void UnbindTexture() MOZ_OVERRIDE
|
||||
{
|
||||
mTexImage->ReleaseTexture();
|
||||
}
|
||||
virtual bool IsValid() const MOZ_OVERRIDE
|
||||
{
|
||||
return !!mTexImage;
|
||||
@ -651,7 +632,6 @@ public:
|
||||
// Lock already bound us!
|
||||
MOZ_ASSERT(activetex == LOCAL_GL_TEXTURE0);
|
||||
}
|
||||
void UnbindTexture() MOZ_OVERRIDE {}
|
||||
GLuint GetTextureID() { return mTextureHandle; }
|
||||
ContentType GetContentType()
|
||||
{
|
||||
@ -732,8 +712,6 @@ public:
|
||||
|
||||
void BindTexture(GLenum activetex) MOZ_OVERRIDE;
|
||||
|
||||
void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
||||
GLuint GetTextureID() { return mTextureHandle; }
|
||||
ContentType GetContentType() {
|
||||
return (mFormat == gfx::FORMAT_B8G8R8A8) ?
|
||||
@ -793,7 +771,6 @@ public:
|
||||
virtual bool IsValid() const MOZ_OVERRIDE { return true; }
|
||||
virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; }
|
||||
virtual void BindTexture(GLenum aTextureUnit);
|
||||
virtual void UnbindTexture() MOZ_OVERRIDE {}
|
||||
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE
|
||||
{
|
||||
return mSize;
|
||||
@ -876,7 +853,6 @@ public:
|
||||
virtual const char* Name() { return "GrallocDeprecatedTextureHostOGL"; }
|
||||
|
||||
void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE;
|
||||
void UnbindTexture() MOZ_OVERRIDE {}
|
||||
|
||||
virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE
|
||||
{
|
||||
|
@ -119,20 +119,17 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface)
|
||||
texture->Unlock();
|
||||
|
||||
// client serialization
|
||||
texture->SetID(1);
|
||||
SurfaceDescriptor descriptor;
|
||||
ASSERT_TRUE(texture->ToSurfaceDescriptor(descriptor));
|
||||
|
||||
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
|
||||
|
||||
// host deserialization
|
||||
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(texture->GetID(),
|
||||
descriptor, nullptr,
|
||||
RefPtr<TextureHost> host = CreateBackendIndependentTextureHost(descriptor, nullptr,
|
||||
texture->GetFlags());
|
||||
|
||||
ASSERT_TRUE(host.get() != nullptr);
|
||||
ASSERT_EQ(host->GetFlags(), texture->GetFlags());
|
||||
ASSERT_EQ(host->GetID(), texture->GetID());
|
||||
|
||||
// host read
|
||||
ASSERT_TRUE(host->Lock());
|
||||
@ -145,9 +142,6 @@ void TestTextureClientSurface(TextureClient* texture, gfxImageSurface* surface)
|
||||
hostDataSurface->Stride(),
|
||||
SurfaceFormatToImageFormat(hostDataSurface->GetFormat()));
|
||||
AssertSurfacesEqual(surface, hostSurface.get());
|
||||
|
||||
// host deallocation
|
||||
host->DeallocateSharedData();
|
||||
}
|
||||
|
||||
// Same as above, for YCbCr surfaces
|
||||
@ -168,22 +162,19 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
|
||||
client->Unlock();
|
||||
|
||||
// client serialization
|
||||
client->SetID(1);
|
||||
SurfaceDescriptor descriptor;
|
||||
ASSERT_TRUE(client->ToSurfaceDescriptor(descriptor));
|
||||
|
||||
ASSERT_NE(descriptor.type(), SurfaceDescriptor::Tnull_t);
|
||||
|
||||
// host deserialization
|
||||
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(client->GetID(),
|
||||
descriptor, nullptr,
|
||||
RefPtr<TextureHost> textureHost = CreateBackendIndependentTextureHost(descriptor, nullptr,
|
||||
client->GetFlags());
|
||||
|
||||
RefPtr<BufferTextureHost> host = static_cast<BufferTextureHost*>(textureHost.get());
|
||||
|
||||
ASSERT_TRUE(host.get() != nullptr);
|
||||
ASSERT_EQ(host->GetFlags(), client->GetFlags());
|
||||
ASSERT_EQ(host->GetID(), client->GetID());
|
||||
|
||||
// This will work iff the compositor is not BasicCompositor
|
||||
ASSERT_EQ(host->GetFormat(), mozilla::gfx::FORMAT_YUV);
|
||||
@ -213,9 +204,6 @@ void TestTextureClientYCbCr(TextureClient* client, PlanarYCbCrData& ycbcrData) {
|
||||
|
||||
AssertYCbCrSurfacesEqual(&ycbcrData, &data);
|
||||
host->Unlock();
|
||||
|
||||
// host deallocation
|
||||
host->DeallocateSharedData();
|
||||
}
|
||||
|
||||
TEST(Layers, TextureSerialization) {
|
||||
@ -234,7 +222,7 @@ TEST(Layers, TextureSerialization) {
|
||||
RefPtr<TextureClient> client
|
||||
= new MemoryTextureClient(nullptr,
|
||||
mozilla::gfx::ImageFormatToSurfaceFormat(surface->Format()),
|
||||
TEXTURE_FLAGS_DEFAULT);
|
||||
TEXTURE_DEALLOCATE_CLIENT);
|
||||
|
||||
TestTextureClientSurface(client, surface);
|
||||
|
||||
@ -270,7 +258,7 @@ TEST(Layers, TextureYCbCrSerialization) {
|
||||
RefPtr<TextureClient> client
|
||||
= new MemoryTextureClient(nullptr,
|
||||
mozilla::gfx::FORMAT_YUV,
|
||||
TEXTURE_FLAGS_DEFAULT);
|
||||
TEXTURE_DEALLOCATE_CLIENT);
|
||||
|
||||
TestTextureClientYCbCr(client, clientData);
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsAnimationManager.h"
|
||||
#include "nsTransitionManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -215,6 +217,18 @@ ActiveLayerTracker::IsStyleAnimated(nsIFrame* aFrame, nsCSSProperty aProperty)
|
||||
if (aProperty == eCSSProperty_transform && aFrame->Preserves3D()) {
|
||||
return IsStyleAnimated(aFrame->GetParent(), aProperty);
|
||||
}
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
if (content) {
|
||||
if (mozilla::HasAnimationOrTransition<ElementAnimations>(
|
||||
content, nsGkAtoms::animationsProperty, aProperty)) {
|
||||
return true;
|
||||
}
|
||||
if (mozilla::HasAnimationOrTransition<ElementTransitions>(
|
||||
content, nsGkAtoms::transitionsProperty, aProperty)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -230,8 +230,8 @@ nsLayoutUtils::HasAnimationsForCompositor(nsIContent* aContent,
|
||||
}
|
||||
|
||||
template <class AnimationsOrTransitions>
|
||||
static AnimationsOrTransitions*
|
||||
HasAnimationOrTransition(nsIContent* aContent,
|
||||
AnimationsOrTransitions*
|
||||
mozilla::HasAnimationOrTransition(nsIContent* aContent,
|
||||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty)
|
||||
{
|
||||
@ -247,6 +247,17 @@ HasAnimationOrTransition(nsIContent* aContent,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template ElementAnimations*
|
||||
mozilla::HasAnimationOrTransition<ElementAnimations>(nsIContent* aContent,
|
||||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty);
|
||||
|
||||
template ElementTransitions*
|
||||
mozilla::HasAnimationOrTransition<ElementTransitions>(nsIContent* aContent,
|
||||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty);
|
||||
|
||||
|
||||
bool
|
||||
nsLayoutUtils::HasAnimations(nsIContent* aContent,
|
||||
nsCSSProperty aProperty)
|
||||
|
@ -70,6 +70,12 @@ class HTMLVideoElement;
|
||||
namespace layers {
|
||||
class Layer;
|
||||
}
|
||||
|
||||
template <class AnimationsOrTransitions>
|
||||
extern AnimationsOrTransitions* HasAnimationOrTransition(nsIContent* aContent,
|
||||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
|
@ -66,20 +66,29 @@ class BackendConsumeSummary(object):
|
||||
# the read and execute time. It does not cover consume time.
|
||||
self.mozbuild_execution_time = 0.0
|
||||
|
||||
# The total wall time spent emitting objects from sandboxes.
|
||||
self.emitter_execution_time = 0.0
|
||||
|
||||
# The total wall time spent in the backend. This counts the time the
|
||||
# backend writes out files, etc.
|
||||
self.backend_execution_time = 0.0
|
||||
|
||||
# How much wall time the system spent doing other things. This is
|
||||
# wall_time - mozbuild_execution_time - backend_execution_time.
|
||||
# wall_time - mozbuild_execution_time - emitter_execution_time -
|
||||
# backend_execution_time.
|
||||
self.other_time = 0.0
|
||||
|
||||
@property
|
||||
def reader_summary(self):
|
||||
return 'Finished reading {:d} moz.build files into {:d} descriptors in {:.2f}s'.format(
|
||||
self.mozbuild_count, self.object_count,
|
||||
return 'Finished reading {:d} moz.build files in {:.2f}s'.format(
|
||||
self.mozbuild_count,
|
||||
self.mozbuild_execution_time)
|
||||
|
||||
@property
|
||||
def emitter_summary(self):
|
||||
return 'Processed into {:d} build config descriptors in {:.2f}s'.format(
|
||||
self.object_count, self.emitter_execution_time)
|
||||
|
||||
@property
|
||||
def backend_summary(self):
|
||||
return 'Backend executed in {:.2f}s'.format(self.backend_execution_time)
|
||||
@ -91,11 +100,14 @@ class BackendConsumeSummary(object):
|
||||
@property
|
||||
def total_summary(self):
|
||||
efficiency_value = self.cpu_time / self.wall_time if self.wall_time else 100
|
||||
return 'Total wall time: {:.2f}s; CPU time: {:.2f}s; Efficiency: {:.0%}'.format(
|
||||
self.wall_time, self.cpu_time, efficiency_value)
|
||||
return 'Total wall time: {:.2f}s; CPU time: {:.2f}s; Efficiency: ' \
|
||||
'{:.0%}; Untracked: {:.2f}s'.format(
|
||||
self.wall_time, self.cpu_time, efficiency_value,
|
||||
self.other_time)
|
||||
|
||||
def summaries(self):
|
||||
yield self.reader_summary
|
||||
yield self.emitter_summary
|
||||
yield self.backend_summary
|
||||
|
||||
detailed = self.backend_detailed_summary()
|
||||
@ -197,7 +209,8 @@ class BuildBackend(LoggingMixin):
|
||||
|
||||
if isinstance(obj, ReaderSummary):
|
||||
self.summary.mozbuild_count = obj.total_file_count
|
||||
self.summary.mozbuild_execution_time = obj.total_execution_time
|
||||
self.summary.mozbuild_execution_time = obj.total_sandbox_execution_time
|
||||
self.summary.emitter_execution_time = obj.total_emitter_execution_time
|
||||
|
||||
finished_start = time.time()
|
||||
self.consume_finished()
|
||||
@ -232,6 +245,7 @@ class BuildBackend(LoggingMixin):
|
||||
self.summary.backend_execution_time = backend_time
|
||||
self.summary.other_time = self.summary.wall_time - \
|
||||
self.summary.mozbuild_execution_time - \
|
||||
self.summary.emitter_execution_time - \
|
||||
self.summary.backend_execution_time
|
||||
|
||||
return self.summary
|
||||
|
@ -41,10 +41,12 @@ class TreeMetadata(object):
|
||||
class ReaderSummary(TreeMetadata):
|
||||
"""A summary of what the reader did."""
|
||||
|
||||
def __init__(self, total_file_count, total_execution_time):
|
||||
def __init__(self, total_file_count, total_sandbox_execution_time,
|
||||
total_emitter_execution_time):
|
||||
TreeMetadata.__init__(self)
|
||||
self.total_file_count = total_file_count
|
||||
self.total_execution_time = total_execution_time
|
||||
self.total_sandbox_execution_time = total_sandbox_execution_time
|
||||
self.total_emitter_execution_time = total_emitter_execution_time
|
||||
|
||||
|
||||
class SandboxDerived(TreeMetadata):
|
||||
|
@ -9,6 +9,7 @@ import logging
|
||||
import os
|
||||
import traceback
|
||||
import sys
|
||||
import time
|
||||
|
||||
from mach.mixin.logging import LoggingMixin
|
||||
|
||||
@ -79,26 +80,44 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
typically fed into this function.
|
||||
"""
|
||||
file_count = 0
|
||||
execution_time = 0.0
|
||||
sandbox_execution_time = 0.0
|
||||
emitter_time = 0.0
|
||||
sandboxes = {}
|
||||
|
||||
def emit_objs(objs):
|
||||
for o in objs:
|
||||
yield o
|
||||
if not o._ack:
|
||||
raise Exception('Unhandled object of type %s' % type(o))
|
||||
|
||||
for out in output:
|
||||
if isinstance(out, MozbuildSandbox):
|
||||
# Keep all sandboxes around, we will need them later.
|
||||
sandboxes[out['OBJDIR']] = out
|
||||
|
||||
for o in self.emit_from_sandbox(out):
|
||||
yield o
|
||||
if not o._ack:
|
||||
raise Exception('Unhandled object of type %s' % type(o))
|
||||
start = time.time()
|
||||
# We need to expand the generator for the timings to work.
|
||||
objs = list(self.emit_from_sandbox(out))
|
||||
emitter_time += time.time() - start
|
||||
|
||||
for o in emit_objs(objs): yield o
|
||||
|
||||
# Update the stats.
|
||||
file_count += len(out.all_paths)
|
||||
execution_time += out.execution_time
|
||||
sandbox_execution_time += out.execution_time
|
||||
|
||||
else:
|
||||
raise Exception('Unhandled output type: %s' % out)
|
||||
|
||||
start = time.time()
|
||||
objs = list(self._emit_libs_derived(sandboxes))
|
||||
emitter_time += time.time() - start
|
||||
|
||||
for o in emit_objs(objs): yield o
|
||||
|
||||
yield ReaderSummary(file_count, sandbox_execution_time, emitter_time)
|
||||
|
||||
def _emit_libs_derived(self, sandboxes):
|
||||
for objdir, libname, final_lib in self._final_libs:
|
||||
if final_lib not in self._libs:
|
||||
raise Exception('FINAL_LIBRARY in %s (%s) does not match any '
|
||||
@ -134,8 +153,6 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
yield passthru
|
||||
yield libdef
|
||||
|
||||
yield ReaderSummary(file_count, execution_time)
|
||||
|
||||
def emit_from_sandbox(self, sandbox):
|
||||
"""Convert a MozbuildSandbox to tree metadata objects.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user