Bug 867656 - Part 1. Implement GetAsSurface for GL TextureHosts. r=bjacob
This commit is contained in:
@@ -59,6 +59,14 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE {
|
||||
if (!mThebesImage) {
|
||||
mThebesImage = mThebesSurface->GetAsImageSurface();
|
||||
}
|
||||
nsRefPtr<gfxImageSurface> result = mThebesImage;
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
BasicCompositor *mCompositor;
|
||||
RefPtr<SourceSurface> mSurface;
|
||||
nsRefPtr<gfxImageSurface> mThebesImage;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "CanvasLayerComposite.h"
|
||||
#include "ImageHost.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@@ -61,6 +62,13 @@ CanvasLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
|
||||
mCompositor->MakeCurrent();
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (gfxUtils::sDumpPainting) {
|
||||
nsRefPtr<gfxImageSurface> surf = mImageHost->GetAsSurface();
|
||||
WriteSnapshotToDumpFile(this, surf);
|
||||
}
|
||||
#endif
|
||||
|
||||
gfxPattern::GraphicsFilter filter = mFilter;
|
||||
#ifdef ANDROID
|
||||
// Bug 691354
|
||||
|
||||
@@ -194,6 +194,10 @@ public:
|
||||
SetCompositor(nullptr);
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() { return nullptr; }
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) { }
|
||||
#endif
|
||||
|
||||
@@ -34,10 +34,6 @@ public:
|
||||
const nsIntRegion& aOldValidRegionBack,
|
||||
nsIntRegion* aUpdatedRegionBack) = 0;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual already_AddRefed<gfxImageSurface> Dump() { return nullptr; }
|
||||
#endif
|
||||
|
||||
virtual void SetPaintWillResample(bool aResample) { }
|
||||
|
||||
protected:
|
||||
@@ -93,9 +89,9 @@ public:
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual already_AddRefed<gfxImageSurface> Dump()
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface()
|
||||
{
|
||||
return mTextureHost->Dump();
|
||||
return mTextureHost->GetAsSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -87,6 +87,13 @@ public:
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE
|
||||
{
|
||||
return mTextureHost->GetAsSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void MakeTextureHost(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aSurface,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ImageHost.h"
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
#include "mozilla/layers/Compositor.h"
|
||||
#include "mozilla/layers/CompositorTypes.h" // for TextureInfo
|
||||
@@ -73,6 +74,13 @@ ImageLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (gfxUtils::sDumpPainting) {
|
||||
nsRefPtr<gfxImageSurface> surf = mImageHost->GetAsSurface();
|
||||
WriteSnapshotToDumpFile(this, surf);
|
||||
}
|
||||
#endif
|
||||
|
||||
mCompositor->MakeCurrent();
|
||||
|
||||
EffectChain effectChain;
|
||||
|
||||
@@ -228,10 +228,6 @@ public:
|
||||
return mDeAllocator;
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
virtual already_AddRefed<gfxImageSurface> Dump() { return nullptr; }
|
||||
#endif
|
||||
|
||||
bool operator== (const TextureHost& o) const
|
||||
{
|
||||
return GetIdentifier() == o.GetIdentifier();
|
||||
@@ -247,6 +243,8 @@ public:
|
||||
mFlags & NeedsYFlip ? LAYER_RENDER_STATE_Y_FLIPPED : 0);
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() = 0;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char *Name() = 0;
|
||||
virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
|
||||
|
||||
@@ -101,7 +101,7 @@ ThebesLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
if (gfxUtils::sDumpPainting) {
|
||||
nsRefPtr<gfxImageSurface> surf = mBuffer->Dump();
|
||||
nsRefPtr<gfxImageSurface> surf = mBuffer->GetAsSurface();
|
||||
WriteSnapshotToDumpFile(this, surf);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -122,6 +122,11 @@ public:
|
||||
|
||||
virtual bool Lock() MOZ_OVERRIDE { return true; }
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE
|
||||
{
|
||||
return nullptr; // TODO: cf bug 872568
|
||||
}
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "TextureHostShmemD3D11"; }
|
||||
#endif
|
||||
@@ -175,6 +180,11 @@ public:
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
virtual void Unlock() MOZ_OVERRIDE;
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE
|
||||
{
|
||||
return nullptr; // TODO: cf bug 872568
|
||||
}
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "TextureHostDXGID3D11"; }
|
||||
#endif
|
||||
@@ -210,6 +220,11 @@ public:
|
||||
|
||||
virtual bool IsYCbCrSource() const MOZ_OVERRIDE { return true; }
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE
|
||||
{
|
||||
return nullptr; // TODO: cf bug 872568
|
||||
}
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() MOZ_OVERRIDE { return "TextureImageTextureHostD3D11"; }
|
||||
#endif
|
||||
|
||||
@@ -141,7 +141,6 @@ TextureImageTextureHostOGL::GetSize() const
|
||||
return gfx::IntSize(0, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextureImageTextureHostOGL::SetCompositor(Compositor* aCompositor)
|
||||
{
|
||||
@@ -234,7 +233,7 @@ bool
|
||||
TextureImageTextureHostOGL::Lock()
|
||||
{
|
||||
if (!mTexture) {
|
||||
NS_WARNING("TextureImageAsTextureHost to be composited without texture");
|
||||
NS_WARNING("TextureImageTextureHost to be composited without texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -877,5 +876,67 @@ GrallocTextureHostOGL::SetBuffer(SurfaceDescriptor* aBuffer, ISurfaceAllocator*
|
||||
|
||||
#endif
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
TextureImageTextureHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() ?
|
||||
mGL->GetTexImage(mTexture->GetTextureID(),
|
||||
false,
|
||||
mTexture->GetShaderProgramType())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
YCbCrTextureHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() ?
|
||||
mGL->GetTexImage(mYTexture->mTexImage->GetTextureID(),
|
||||
false,
|
||||
mYTexture->mTexImage->GetShaderProgramType())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
SharedTextureHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() ?
|
||||
mGL->GetTexImage(GetTextureHandle(),
|
||||
false,
|
||||
GetShaderProgram())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
SurfaceStreamHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() ?
|
||||
mGL->GetTexImage(mTextureHandle,
|
||||
false,
|
||||
GetShaderProgram())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
TiledTextureHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() ?
|
||||
mGL->GetTexImage(mTextureHandle,
|
||||
false,
|
||||
GetShaderProgram())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
already_AddRefed<gfxImageSurface>
|
||||
GrallocTextureHostOGL::GetAsSurface() {
|
||||
nsRefPtr<gfxImageSurface> surf = IsValid() && mGLTexture ?
|
||||
mGL->GetTexImage(mGLTexture,
|
||||
false,
|
||||
GetShaderProgram())
|
||||
: nullptr;
|
||||
return surf.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -131,6 +131,8 @@ public:
|
||||
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
// textureSource
|
||||
void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE
|
||||
{
|
||||
@@ -272,7 +274,6 @@ public:
|
||||
{
|
||||
return mTexImage->GetWrapMode();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// TextureSource implementation
|
||||
@@ -296,6 +297,8 @@ public:
|
||||
return mYTexture->GetSize();
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "YCbCrTextureHostOGL"; }
|
||||
#endif
|
||||
@@ -380,6 +383,8 @@ public:
|
||||
|
||||
virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE;
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "SharedTextureHostOGL"; }
|
||||
#endif
|
||||
@@ -463,6 +468,8 @@ public:
|
||||
gfxASurface::CONTENT_COLOR;
|
||||
}
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "SurfaceStreamHostOGL"; }
|
||||
#endif
|
||||
@@ -524,6 +531,8 @@ public:
|
||||
nsIntRegion* aRegion = nullptr)
|
||||
{ MOZ_ASSERT(false, "Tiles should not use this path"); }
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "TiledTextureHostOGL"; }
|
||||
#endif
|
||||
@@ -607,6 +616,8 @@ public:
|
||||
|
||||
bool IsValid() const MOZ_OVERRIDE;
|
||||
|
||||
virtual already_AddRefed<gfxImageSurface> GetAsSurface() MOZ_OVERRIDE;
|
||||
|
||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||
virtual const char* Name() { return "GrallocTextureHostOGL"; }
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user