Backed out changeset 9a5f4bbd4fcb (bug 900188) to see if it fixes the OSX crashtest and reftest asserts.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2013-08-02 00:45:09 -04:00
parent 1300362aab
commit ae30fbde10
6 changed files with 59 additions and 63 deletions

View File

@ -22,15 +22,20 @@ namespace mozilla {
namespace layers {
/* static */ TemporaryRef<CanvasClient>
CanvasClient::CreateCanvasClient(CanvasClientType aType,
CanvasClient::CreateCanvasClient(CompositableType aCompositableHostType,
CompositableForwarder* aForwarder,
TextureFlags aFlags)
{
if (aType == CanvasClientGLContext &&
aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
return new CanvasClientSurfaceStream(aForwarder, aFlags);
if (aCompositableHostType == BUFFER_IMAGE_SINGLE) {
return new CanvasClient2D(aForwarder, aFlags);
}
return new CanvasClient2D(aForwarder, aFlags);
if (aCompositableHostType == BUFFER_IMAGE_BUFFERED) {
if (aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
return new CanvasClientWebGL(aForwarder, aFlags);
}
return new CanvasClient2D(aForwarder, aFlags);
}
return nullptr;
}
void
@ -67,32 +72,28 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
}
void
CanvasClientSurfaceStream::Updated()
CanvasClientWebGL::Updated()
{
if (mNeedsUpdate) {
mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
mNeedsUpdate = false;
}
mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
}
CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aFwd,
TextureFlags aFlags)
CanvasClientWebGL::CanvasClientWebGL(CompositableForwarder* aFwd,
TextureFlags aFlags)
: CanvasClient(aFwd, aFlags)
, mNeedsUpdate(false)
{
mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
mTextureInfo.mCompositableType = BUFFER_IMAGE_BUFFERED;
}
void
CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
CanvasClientWebGL::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
{
if (!mDeprecatedTextureClient) {
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL);
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
}
NS_ASSERTION(aLayer->mGLContext, "CanvasClientSurfaceStream should only be used with GL canvases");
NS_ASSERTION(aLayer->mGLContext, "CanvasClientWebGL should only be used with GL canvases");
// the content type won't be used
mDeprecatedTextureClient->EnsureAllocated(aSize, gfxASurface::CONTENT_COLOR);
@ -121,21 +122,15 @@ CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
MOZ_ASSERT(false);
#endif
mNeedsUpdate = true;
} else {
SurfaceStreamHandle handle = stream->GetShareHandle();
SurfaceDescriptor *desc = mDeprecatedTextureClient->GetDescriptor();
if (desc->type() != SurfaceDescriptor::TSurfaceStreamDescriptor ||
desc->get_SurfaceStreamDescriptor().handle() != handle) {
*desc = SurfaceStreamDescriptor(handle, false);
mDeprecatedTextureClient->SetDescriptor(SurfaceStreamDescriptor(handle, false));
// Bug 894405
//
// Ref this so the SurfaceStream doesn't disappear unexpectedly. The
// Compositor will need to unref it when finished.
aLayer->mGLContext->AddRef();
mNeedsUpdate = true;
}
// Bug 894405
//
// Ref this so the SurfaceStream doesn't disappear unexpectedly. The
// Compositor will need to unref it when finished.
aLayer->mGLContext->AddRef();
}
aLayer->Painted();

View File

@ -26,11 +26,7 @@ public:
* message will be sent to the compositor to create a corresponding image
* host.
*/
enum CanvasClientType {
CanvasClientSurface,
CanvasClientGLContext,
};
static TemporaryRef<CanvasClient> CreateCanvasClient(CanvasClientType aType,
static TemporaryRef<CanvasClient> CreateCanvasClient(CompositableType aImageHostType,
CompositableForwarder* aFwd,
TextureFlags aFlags);
@ -73,11 +69,11 @@ public:
// Used for GL canvases where we don't need to do any readback, i.e., with a
// GL backend.
class CanvasClientSurfaceStream : public CanvasClient
class CanvasClientWebGL : public CanvasClient
{
public:
CanvasClientSurfaceStream(CompositableForwarder* aFwd,
TextureFlags aFlags);
CanvasClientWebGL(CompositableForwarder* aFwd,
TextureFlags aFlags);
TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
@ -86,9 +82,6 @@ public:
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
virtual void Updated() MOZ_OVERRIDE;
private:
bool mNeedsUpdate;
};
}

View File

@ -94,7 +94,7 @@ ClientCanvasLayer::RenderLayer()
flags |= TEXTURE_DEALLOCATE_CLIENT;
}
}
mCanvasClient = CanvasClient::CreateCanvasClient(GetCanvasClientType(),
mCanvasClient = CanvasClient::CreateCanvasClient(GetCompositableClientType(),
ClientManager(), flags);
if (!mCanvasClient) {
return;

View File

@ -25,7 +25,6 @@ class CanvasClientWebGL;
class ClientCanvasLayer : public CopyableCanvasLayer,
public ClientLayer
{
typedef CanvasClient::CanvasClientType CanvasClientType;
public:
ClientCanvasLayer(ClientLayerManager* aLayerManager) :
CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
@ -76,18 +75,18 @@ protected:
return static_cast<ClientLayerManager*>(mManager);
}
CanvasClientType GetCanvasClientType()
CompositableType GetCompositableClientType()
{
if (mGLContext) {
return CanvasClient::CanvasClientGLContext;
return BUFFER_IMAGE_BUFFERED;
}
return CanvasClient::CanvasClientSurface;
return BUFFER_IMAGE_SINGLE;
}
RefPtr<CanvasClient> mCanvasClient;
friend class CanvasClient2D;
friend class CanvasClientSurfaceStream;
friend class CanvasClientWebGL;
};
}
}

View File

@ -592,23 +592,27 @@ SurfaceStreamHostOGL::DeleteTextures()
}
void
SurfaceStreamHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion,
nsIntPoint* aOffset)
SurfaceStreamHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion)
{
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor,
"Invalid descriptor");
// Bug 894405
//
// The SurfaceStream's GLContext was refed before being passed up to us, so
// we need to ensure it gets unrefed when we are finished.
const SurfaceStreamDescriptor& streamDesc =
aImage.get_SurfaceStreamDescriptor();
mStreamGL = nullptr;
mStream = SurfaceStream::FromHandle(streamDesc.handle());
MOZ_ASSERT(mStream);
mStreamGL = dont_AddRef(mStream->GLContext());
if (aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor) {
// Bug 894405
//
// The SurfaceStream's GLContext was refed before being passed up to us, so
// we need to ensure it gets unrefed when we are finished.
const SurfaceStreamDescriptor& streamDesc =
aImage.get_SurfaceStreamDescriptor();
SurfaceStream* surfStream = SurfaceStream::FromHandle(streamDesc.handle());
if (surfStream) {
mStreamGL = dont_AddRef(surfStream->GLContext());
}
}
}
void
@ -622,8 +626,15 @@ bool
SurfaceStreamHostOGL::Lock()
{
mGL->MakeCurrent();
SurfaceStream* surfStream = nullptr;
SharedSurface* sharedSurf = nullptr;
const SurfaceStreamDescriptor& streamDesc =
mBuffer->get_SurfaceStreamDescriptor();
SharedSurface* sharedSurf = mStream->SwapConsumer();
surfStream = SurfaceStream::FromHandle(streamDesc.handle());
MOZ_ASSERT(surfStream);
sharedSurf = surfStream->SwapConsumer();
if (!sharedSurf) {
// We don't have a valid surf to show yet.
return false;

View File

@ -652,6 +652,7 @@ public:
virtual ~SurfaceStreamHostOGL()
{
DeleteTextures();
*mBuffer = SurfaceDescriptor();
}
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
@ -671,9 +672,8 @@ public:
bool IsValid() const MOZ_OVERRIDE { return true; }
// override from DeprecatedTextureHost
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion,
nsIntPoint* aOffset);
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
virtual bool Lock() MOZ_OVERRIDE;
virtual void Unlock() MOZ_OVERRIDE;
@ -720,7 +720,6 @@ public:
, mTextureTarget(LOCAL_GL_TEXTURE_2D)
, mUploadTexture(0)
, mWrapMode(LOCAL_GL_CLAMP_TO_EDGE)
, mStream(nullptr)
{}
protected:
@ -733,7 +732,6 @@ protected:
GLuint mUploadTexture;
GLenum mWrapMode;
nsRefPtr<GLContext> mStreamGL;
gfx::SurfaceStream *mStream;
};
class TiledDeprecatedTextureHostOGL : public DeprecatedTextureHost