Bug 1077307 - Merge NewTextureSource and TextureSource. r=sotaro

This commit is contained in:
Nicolas Silva 2014-10-07 15:58:59 +02:00
parent 5555ff05e7
commit f094ba38b8
21 changed files with 70 additions and 98 deletions

View File

@ -123,7 +123,7 @@ struct EffectChain;
class Image;
class ISurfaceAllocator;
class Layer;
class NewTextureSource;
class TextureSource;
class DataTextureSource;
class CompositingRenderTarget;
class PCompositorParent;

View File

@ -128,7 +128,7 @@ DIBTextureHost::DIBTextureHost(TextureFlags aFlags,
gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType()));
}
NewTextureSource*
TextureSource*
DIBTextureHost::GetTextureSources()
{
if (!mTextureSource) {

View File

@ -70,7 +70,7 @@ public:
DIBTextureHost(TextureFlags aFlags,
const SurfaceDescriptorDIB& aDescriptor);
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE;

View File

@ -23,7 +23,7 @@ class BasicCompositor;
*/
class MacIOSurfaceTextureSourceBasic
: public TextureSourceBasic,
public NewTextureSource
public TextureSource
{
public:
MacIOSurfaceTextureSourceBasic(BasicCompositor* aCompositor,
@ -63,7 +63,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}

View File

@ -17,7 +17,7 @@ class BasicCompositor;
// TextureSource for Xlib-backed surfaces.
class X11TextureSourceBasic
: public TextureSourceBasic
, public NewTextureSource
, public TextureSource
{
public:
X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface);

View File

@ -49,8 +49,8 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
return;
}
RefPtr<NewTextureSource> source = GetTextureSource();
RefPtr<NewTextureSource> sourceOnWhite = GetTextureSourceOnWhite();
RefPtr<TextureSource> source = GetTextureSource();
RefPtr<TextureSource> sourceOnWhite = GetTextureSourceOnWhite();
if (!source) {
return;
@ -208,8 +208,8 @@ ContentHostBase::Composite(EffectChain& aEffectChain,
TemporaryRef<TexturedEffect>
ContentHostBase::GenEffect(const gfx::Filter& aFilter)
{
RefPtr<NewTextureSource> source = GetTextureSource();
RefPtr<NewTextureSource> sourceOnWhite = GetTextureSourceOnWhite();
RefPtr<TextureSource> source = GetTextureSource();
RefPtr<TextureSource> sourceOnWhite = GetTextureSourceOnWhite();
if (!source) {
return nullptr;
}
@ -439,14 +439,14 @@ ContentHostIncremental::ProcessTextureUpdates()
mUpdateList.Clear();
}
NewTextureSource*
TextureSource*
ContentHostIncremental::GetTextureSource()
{
MOZ_ASSERT(mLocked);
return mSource;
}
NewTextureSource*
TextureSource*
ContentHostIncremental::GetTextureSourceOnWhite()
{
MOZ_ASSERT(mLocked);

View File

@ -103,8 +103,8 @@ public:
const gfx::Rect& aClipRect,
const nsIntRegion* aVisibleRegion = nullptr);
virtual NewTextureSource* GetTextureSource() = 0;
virtual NewTextureSource* GetTextureSourceOnWhite() = 0;
virtual TextureSource* GetTextureSource() = 0;
virtual TextureSource* GetTextureSourceOnWhite() = 0;
virtual TemporaryRef<TexturedEffect> GenEffect(const gfx::Filter& aFilter) MOZ_OVERRIDE;
@ -173,11 +173,11 @@ public:
mLocked = false;
}
virtual NewTextureSource* GetTextureSource() MOZ_OVERRIDE {
virtual TextureSource* GetTextureSource() MOZ_OVERRIDE {
MOZ_ASSERT(mLocked);
return mTextureHost->GetTextureSources();
}
virtual NewTextureSource* GetTextureSourceOnWhite() MOZ_OVERRIDE {
virtual TextureSource* GetTextureSourceOnWhite() MOZ_OVERRIDE {
MOZ_ASSERT(mLocked);
if (mTextureHostOnWhite) {
return mTextureHostOnWhite->GetTextureSources();
@ -291,8 +291,8 @@ public:
mLocked = false;
}
virtual NewTextureSource* GetTextureSource() MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSourceOnWhite() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSource() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSourceOnWhite() MOZ_OVERRIDE;
private:

View File

@ -104,7 +104,7 @@ ImageHost::Composite(EffectChain& aEffectChain,
NS_WARNING("failed to lock front buffer");
return;
}
RefPtr<NewTextureSource> source = GetTextureSource();
RefPtr<TextureSource> source = GetTextureSource();
if (!source) {
return;
}
@ -273,7 +273,7 @@ ImageHost::Unlock()
mLocked = false;
}
TemporaryRef<NewTextureSource>
TemporaryRef<TextureSource>
ImageHost::GetTextureSource()
{
MOZ_ASSERT(mLocked);
@ -283,7 +283,7 @@ ImageHost::GetTextureSource()
TemporaryRef<TexturedEffect>
ImageHost::GenEffect(const gfx::Filter& aFilter)
{
RefPtr<NewTextureSource> source = GetTextureSource();
RefPtr<TextureSource> source = GetTextureSource();
if (!source) {
return nullptr;
}

View File

@ -84,7 +84,7 @@ public:
virtual void Unlock() MOZ_OVERRIDE;
virtual TemporaryRef<NewTextureSource> GetTextureSource();
virtual TemporaryRef<TextureSource> GetTextureSource();
virtual TemporaryRef<TexturedEffect> GenEffect(const gfx::Filter& aFilter) MOZ_OVERRIDE;

View File

@ -367,7 +367,7 @@ BufferTextureHost::SetCompositor(Compositor* aCompositor)
if (mCompositor == aCompositor) {
return;
}
RefPtr<NewTextureSource> it = mFirstSource;
RefPtr<TextureSource> it = mFirstSource;
while (it) {
it->SetCompositor(aCompositor);
it = it->GetNextSibling();
@ -378,7 +378,7 @@ BufferTextureHost::SetCompositor(Compositor* aCompositor)
void
BufferTextureHost::DeallocateDeviceData()
{
RefPtr<NewTextureSource> it = mFirstSource;
RefPtr<TextureSource> it = mFirstSource;
while (it) {
it->DeallocateDeviceData();
it = it->GetNextSibling();
@ -403,7 +403,7 @@ BufferTextureHost::Unlock()
mLocked = false;
}
NewTextureSource*
TextureSource*
BufferTextureHost::GetTextureSources()
{
MOZ_ASSERT(mLocked);
@ -865,7 +865,7 @@ StreamTextureHost::Lock()
break;
}
RefPtr<NewTextureSource> newTexSource;
RefPtr<TextureSource> newTexSource;
if (compositorSupportsShSurfType) {
gfx::SurfaceFormat format = abstractSurf->mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
: gfx::SurfaceFormat::R8G8B8X8;

View File

@ -88,14 +88,18 @@ public:
*/
class TextureSource
{
protected:
virtual ~TextureSource();
public:
NS_INLINE_DECL_REFCOUNTING(TextureSource)
TextureSource();
/**
* Should be overridden in order to deallocate the data that is associated
* with the rendering backend, such as GL textures.
*/
virtual void DeallocateDeviceData() {}
/**
* Return the size of the texture in texels.
* If this is a tile iterator, GetSize must return the size of the current tile.
@ -114,63 +118,28 @@ public:
virtual TextureSourceD3D9* AsSourceD3D9() { return nullptr; }
virtual TextureSourceD3D11* AsSourceD3D11() { return nullptr; }
virtual TextureSourceBasic* AsSourceBasic() { return nullptr; }
/**
* Cast to a DataTextureSurce.
*/
virtual DataTextureSource* AsDataTextureSource() { return nullptr; }
/**
* In some rare cases we currently need to consider a group of textures as one
* TextureSource, that can be split in sub-TextureSources.
*/
virtual TextureSource* GetSubSource(int index) { return nullptr; }
/**
* Overload this if the TextureSource supports big textures that don't fit in
* one device texture and must be tiled internally.
*/
virtual BigImageIterator* AsBigImageIterator() { return nullptr; }
};
/**
* XXX - merge this class with TextureSource when deprecated texture classes
* are completely removed.
*/
class NewTextureSource : public TextureSource
{
public:
NewTextureSource()
{
MOZ_COUNT_CTOR(NewTextureSource);
}
protected:
virtual ~NewTextureSource()
{
MOZ_COUNT_DTOR(NewTextureSource);
}
public:
/**
* Should be overridden in order to deallocate the data that is associated
* with the rendering backend, such as GL textures.
*/
virtual void DeallocateDeviceData() = 0;
virtual void SetCompositor(Compositor* aCompositor) {}
void SetNextSibling(NewTextureSource* aTexture)
{
mNextSibling = aTexture;
}
void SetNextSibling(TextureSource* aTexture) { mNextSibling = aTexture; }
NewTextureSource* GetNextSibling() const
{
return mNextSibling;
}
TextureSource* GetNextSibling() const { return mNextSibling; }
// temporary adapter to use the same SubSource API as the old TextureSource
virtual TextureSource* GetSubSource(int index) MOZ_OVERRIDE
/**
* In some rare cases we currently need to consider a group of textures as one
* TextureSource, that can be split in sub-TextureSources.
*/
TextureSource* GetSubSource(int index)
{
switch (index) {
case 0: return this;
@ -181,7 +150,9 @@ public:
}
protected:
RefPtr<NewTextureSource> mNextSibling;
virtual ~TextureSource();
RefPtr<TextureSource> mNextSibling;
};
/**
@ -189,7 +160,7 @@ protected:
*
* All backend should implement at least one DataTextureSource.
*/
class DataTextureSource : public NewTextureSource
class DataTextureSource : public TextureSource
{
public:
DataTextureSource()
@ -328,7 +299,7 @@ public:
* so as to not upload textures while the main thread is blocked.
* Must not be called while this TextureHost is not sucessfully Locked.
*/
virtual NewTextureSource* GetTextureSources() = 0;
virtual TextureSource* GetTextureSources() = 0;
/**
* Is called before compositing if the shared data has changed since last
@ -499,7 +470,7 @@ public:
virtual void Unlock() MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE;
@ -621,7 +592,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}
@ -640,7 +611,7 @@ public:
protected:
Compositor* mCompositor;
gl::SurfaceStream* mStream;
RefPtr<NewTextureSource> mTextureSource;
RefPtr<TextureSource> mTextureSource;
RefPtr<DataTextureSource> mDataTextureSource;
};
@ -671,9 +642,10 @@ private:
* This can be used as an offscreen rendering target by the compositor, and
* subsequently can be used as a source by the compositor.
*/
class CompositingRenderTarget : public TextureSource
class CompositingRenderTarget: public TextureSource
{
public:
explicit CompositingRenderTarget(const gfx::IntPoint& aOrigin)
: mOrigin(aOrigin)
{}

View File

@ -486,8 +486,8 @@ TiledContentHost::RenderTile(const TileHost& aTile,
NS_WARNING("Failed to lock tile");
return;
}
RefPtr<NewTextureSource> source = aTile.mTextureHost->GetTextureSources();
RefPtr<NewTextureSource> sourceOnWhite =
RefPtr<TextureSource> source = aTile.mTextureHost->GetTextureSources();
RefPtr<TextureSource> sourceOnWhite =
aTile.mTextureHostOnWhite ? aTile.mTextureHostOnWhite->GetTextureSources() : nullptr;
if (!source || (aTile.mTextureHostOnWhite && !sourceOnWhite)) {
return;

View File

@ -30,7 +30,7 @@ public:
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}
@ -46,7 +46,7 @@ public:
protected:
Compositor* mCompositor;
RefPtr<NewTextureSource> mTextureSource;
RefPtr<TextureSource> mTextureSource;
RefPtr<gfxXlibSurface> mSurface;
};

View File

@ -485,7 +485,7 @@ DXGITextureHostD3D11::Unlock()
mIsLocked = false;
}
NewTextureSource*
TextureSource*
DXGITextureHostD3D11::GetTextureSources()
{
MOZ_ASSERT(mIsLocked);

View File

@ -176,7 +176,7 @@ public:
DXGITextureHostD3D11(TextureFlags aFlags,
const SurfaceDescriptorD3D10& aDescriptor);
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE {}

View File

@ -889,7 +889,7 @@ TextureHostD3D9::SetCompositor(Compositor* aCompositor)
}
}
NewTextureSource*
TextureSource*
TextureHostD3D9::GetTextureSources()
{
MOZ_ASSERT(mIsLocked);
@ -965,7 +965,7 @@ DXGITextureHostD3D9::OpenSharedHandle()
return;
}
NewTextureSource*
TextureSource*
DXGITextureHostD3D9::GetTextureSources()
{
MOZ_ASSERT(mIsLocked);

View File

@ -292,7 +292,7 @@ public:
TextureHostD3D9(TextureFlags aFlags,
const SurfaceDescriptorD3D9& aDescriptor);
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE;
@ -333,7 +333,7 @@ public:
DXGITextureHostD3D9(TextureFlags aFlags,
const SurfaceDescriptorD3D10& aDescriptor);
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;
virtual void DeallocateDeviceData() MOZ_OVERRIDE;

View File

@ -16,7 +16,7 @@ namespace layers {
class GrallocTextureHostOGL;
class GrallocTextureSourceOGL : public NewTextureSource
class GrallocTextureSourceOGL : public TextureSource
, public TextureSourceOGL
{
public:
@ -116,7 +116,7 @@ public:
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}

View File

@ -19,7 +19,7 @@ namespace layers {
* It does not own any GL texture, and attaches its shared handle to one of
* the compositor's temporary textures when binding.
*/
class MacIOSurfaceTextureSourceOGL : public NewTextureSource
class MacIOSurfaceTextureSourceOGL : public TextureSource
, public TextureSourceOGL
{
public:
@ -73,7 +73,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}

View File

@ -368,7 +368,7 @@ protected:
*
* The shared texture handle is owned by the TextureHost.
*/
class GLTextureSource : public NewTextureSource
class GLTextureSource : public TextureSource
, public TextureSourceOGL
{
public:
@ -411,7 +411,7 @@ protected:
#ifdef MOZ_WIDGET_ANDROID
class SurfaceTextureSource : public NewTextureSource
class SurfaceTextureSource : public TextureSource
, public TextureSourceOGL
{
public:
@ -474,7 +474,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}
@ -502,7 +502,7 @@ protected:
////////////////////////////////////////////////////////////////////////
// EGLImage
class EGLImageTextureSource : public NewTextureSource
class EGLImageTextureSource : public TextureSource
, public TextureSourceOGL
{
public:
@ -565,7 +565,7 @@ public:
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
virtual TextureSource* GetTextureSources() MOZ_OVERRIDE
{
return mTextureSource;
}

View File

@ -17,7 +17,7 @@ namespace layers {
// TextureSource for Xlib-backed surfaces.
class X11TextureSourceOGL
: public TextureSourceOGL
, public NewTextureSource
, public TextureSource
{
public:
X11TextureSourceOGL(CompositorOGL* aCompositor, gfxXlibSurface* aSurface);