Bug 1010966 - Reduce gl()->fEGLImageTargetTexture2D() call from tiled layer on gonk r=nical

This commit is contained in:
Sotaro Ikeda 2014-12-15 19:41:21 -08:00
Родитель e1f2ef0e3c
Коммит 2631cf1673
3 изменённых файлов: 73 добавлений и 17 удалений

Просмотреть файл

@ -175,6 +175,16 @@ class CompositableTextureRef {
public:
CompositableTextureRef() {}
explicit CompositableTextureRef(const CompositableTextureRef& aOther)
{
*this = aOther;
}
explicit CompositableTextureRef(T* aOther)
{
*this = aOther;
}
~CompositableTextureRef()
{
if (mRef) {
@ -182,6 +192,18 @@ public:
}
}
CompositableTextureRef& operator=(const CompositableTextureRef& aOther)
{
if (aOther.get()) {
aOther->AddCompositableRef();
}
if (mRef) {
mRef->ReleaseCompositableRef();
}
mRef = aOther.get();
return *this;
}
CompositableTextureRef& operator=(const TemporaryRef<T>& aOther)
{
RefPtr<T> temp = aOther;

Просмотреть файл

@ -41,7 +41,8 @@ TiledLayerBufferComposite::RecycleCallback(TextureHost* textureHost, void* aClos
TiledLayerBufferComposite::TiledLayerBufferComposite(ISurfaceAllocator* aAllocator,
const SurfaceDescriptorTiles& aDescriptor,
const nsIntRegion& aOldPaintedRegion)
const nsIntRegion& aOldPaintedRegion,
Compositor* aCompositor)
{
mIsValid = true;
mHasDoubleBufferedTiles = false;
@ -61,8 +62,8 @@ TiledLayerBufferComposite::TiledLayerBufferComposite(ISurfaceAllocator* aAllocat
const InfallibleTArray<TileDescriptor>& tiles = aDescriptor.tiles();
for(size_t i = 0; i < tiles.Length(); i++) {
RefPtr<TextureHost> texture;
RefPtr<TextureHost> textureOnWhite;
CompositableTextureHostRef texture;
CompositableTextureHostRef textureOnWhite;
const TileDescriptor& tileDesc = tiles[i];
switch (tileDesc.type()) {
case TileDescriptor::TTexturedTileDescriptor : {
@ -94,7 +95,21 @@ TiledLayerBufferComposite::TiledLayerBufferComposite(ISurfaceAllocator* aAllocat
}
}
mRetainedTiles.AppendElement(TileHost(sharedLock, texture, textureOnWhite));
CompositableTextureSourceRef textureSource;
CompositableTextureSourceRef textureSourceOnWhite;
if (texture) {
texture->SetCompositor(aCompositor);
texture->PrepareTextureSource(textureSource);
}
if (textureOnWhite) {
textureOnWhite->SetCompositor(aCompositor);
textureOnWhite->PrepareTextureSource(textureSourceOnWhite);
}
mRetainedTiles.AppendElement(TileHost(sharedLock,
texture.get(),
textureOnWhite.get(),
textureSource.get(),
textureSourceOnWhite.get()));
break;
}
default:
@ -130,6 +145,8 @@ TiledLayerBufferComposite::ReleaseTextureHosts()
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
mRetainedTiles[i].mTextureHost = nullptr;
mRetainedTiles[i].mTextureHostOnWhite = nullptr;
mRetainedTiles[i].mTextureSource = nullptr;
mRetainedTiles[i].mTextureSourceOnWhite = nullptr;
}
}
@ -321,8 +338,10 @@ TiledContentHost::UseTiledLayerBuffer(ISurfaceAllocator* aAllocator,
}
}
mLowPrecisionTiledBuffer =
TiledLayerBufferComposite(aAllocator, aTiledDescriptor,
mLowPrecisionTiledBuffer.GetPaintedRegion());
TiledLayerBufferComposite(aAllocator,
aTiledDescriptor,
mLowPrecisionTiledBuffer.GetPaintedRegion(),
mCompositor);
if (!mLowPrecisionTiledBuffer.IsValid()) {
// Something bad happened. Stop here, return false (kills the child process),
// and do as little work as possible on the received data as it appears
@ -341,8 +360,10 @@ TiledContentHost::UseTiledLayerBuffer(ISurfaceAllocator* aAllocator,
mOldTiledBuffer.ReleaseTextureHosts();
}
}
mTiledBuffer = TiledLayerBufferComposite(aAllocator, aTiledDescriptor,
mTiledBuffer.GetPaintedRegion());
mTiledBuffer = TiledLayerBufferComposite(aAllocator,
aTiledDescriptor,
mTiledBuffer.GetPaintedRegion(),
mCompositor);
if (!mTiledBuffer.IsValid()) {
// Something bad happened. Stop here, return false (kills the child process),
// and do as little work as possible on the received data as it appears
@ -477,14 +498,16 @@ TiledContentHost::RenderTile(const TileHost& aTile,
NS_WARNING("Failed to lock tile");
return;
}
RefPtr<TextureSource> source = aTile.mTextureHost->GetTextureSources();
RefPtr<TextureSource> sourceOnWhite =
aTile.mTextureHostOnWhite ? aTile.mTextureHostOnWhite->GetTextureSources() : nullptr;
if (!source || (aTile.mTextureHostOnWhite && !sourceOnWhite)) {
if (!aTile.mTextureHost->BindTextureSource(aTile.mTextureSource)) {
return;
}
RefPtr<TexturedEffect> effect = CreateTexturedEffect(source, sourceOnWhite, aFilter, true);
if (aTile.mTextureHostOnWhite && !aTile.mTextureHostOnWhite->BindTextureSource(aTile.mTextureSourceOnWhite)) {
return;
}
RefPtr<TexturedEffect> effect = CreateTexturedEffect(aTile.mTextureSource, aTile.mTextureSourceOnWhite, aFilter, true);
if (!effect) {
return;
}

Просмотреть файл

@ -62,15 +62,21 @@ public:
// Constructs a TileHost from a gfxSharedReadLock and TextureHost.
TileHost(gfxSharedReadLock* aSharedLock,
TextureHost* aTextureHost,
TextureHost* aTextureHostOnWhite)
TextureHost* aTextureHostOnWhite,
TextureSource* aSource,
TextureSource* aSourceOnWhite)
: mSharedLock(aSharedLock)
, mTextureHost(aTextureHost)
, mTextureHostOnWhite(aTextureHostOnWhite)
, mTextureSource(aSource)
, mTextureSourceOnWhite(aSourceOnWhite)
{}
TileHost(const TileHost& o) {
mTextureHost = o.mTextureHost;
mTextureHostOnWhite = o.mTextureHostOnWhite;
mTextureSource = o.mTextureSource;
mTextureSourceOnWhite = o.mTextureSourceOnWhite;
mSharedLock = o.mSharedLock;
}
TileHost& operator=(const TileHost& o) {
@ -79,6 +85,8 @@ public:
}
mTextureHost = o.mTextureHost;
mTextureHostOnWhite = o.mTextureHostOnWhite;
mTextureSource = o.mTextureSource;
mTextureSourceOnWhite = o.mTextureSourceOnWhite;
mSharedLock = o.mSharedLock;
return *this;
}
@ -99,8 +107,10 @@ public:
}
RefPtr<gfxSharedReadLock> mSharedLock;
RefPtr<TextureHost> mTextureHost;
RefPtr<TextureHost> mTextureHostOnWhite;
CompositableTextureHostRef mTextureHost;
CompositableTextureHostRef mTextureHostOnWhite;
mutable CompositableTextureSourceRef mTextureSource;
mutable CompositableTextureSourceRef mTextureSourceOnWhite;
};
class TiledLayerBufferComposite
@ -114,7 +124,8 @@ public:
TiledLayerBufferComposite();
TiledLayerBufferComposite(ISurfaceAllocator* aAllocator,
const SurfaceDescriptorTiles& aDescriptor,
const nsIntRegion& aOldPaintedRegion);
const nsIntRegion& aOldPaintedRegion,
Compositor* aCompositor);
TileHost GetPlaceholderTile() const { return TileHost(); }