зеркало из https://github.com/mozilla/gecko-dev.git
Bug 900188 - Correctly treat WebGL as being single buffered when we share it across ipdl. r=nrc
--HG-- extra : rebase_source : 92be3f39d6e07d1e5f5de0a484a0c94eca93a97c
This commit is contained in:
Родитель
25ba0bbd0d
Коммит
7cd7d8afbd
|
@ -22,20 +22,15 @@ namespace mozilla {
|
|||
namespace layers {
|
||||
|
||||
/* static */ TemporaryRef<CanvasClient>
|
||||
CanvasClient::CreateCanvasClient(CompositableType aCompositableHostType,
|
||||
CanvasClient::CreateCanvasClient(CanvasClientType aType,
|
||||
CompositableForwarder* aForwarder,
|
||||
TextureFlags aFlags)
|
||||
{
|
||||
if (aCompositableHostType == BUFFER_IMAGE_SINGLE) {
|
||||
return new CanvasClient2D(aForwarder, aFlags);
|
||||
if (aType == CanvasClientGLContext &&
|
||||
aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
|
||||
return new CanvasClientSurfaceStream(aForwarder, aFlags);
|
||||
}
|
||||
if (aCompositableHostType == BUFFER_IMAGE_BUFFERED) {
|
||||
if (aForwarder->GetCompositorBackendType() == LAYERS_OPENGL) {
|
||||
return new CanvasClientWebGL(aForwarder, aFlags);
|
||||
}
|
||||
return new CanvasClient2D(aForwarder, aFlags);
|
||||
}
|
||||
return nullptr;
|
||||
return new CanvasClient2D(aForwarder, aFlags);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -72,28 +67,32 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|||
}
|
||||
|
||||
void
|
||||
CanvasClientWebGL::Updated()
|
||||
CanvasClientSurfaceStream::Updated()
|
||||
{
|
||||
mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
|
||||
if (mNeedsUpdate) {
|
||||
mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->GetDescriptor());
|
||||
mNeedsUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CanvasClientWebGL::CanvasClientWebGL(CompositableForwarder* aFwd,
|
||||
TextureFlags aFlags)
|
||||
CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aFwd,
|
||||
TextureFlags aFlags)
|
||||
: CanvasClient(aFwd, aFlags)
|
||||
, mNeedsUpdate(false)
|
||||
{
|
||||
mTextureInfo.mCompositableType = BUFFER_IMAGE_BUFFERED;
|
||||
mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
|
||||
}
|
||||
|
||||
void
|
||||
CanvasClientWebGL::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
CanvasClientSurfaceStream::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, "CanvasClientWebGL should only be used with GL canvases");
|
||||
NS_ASSERTION(aLayer->mGLContext, "CanvasClientSurfaceStream should only be used with GL canvases");
|
||||
|
||||
// the content type won't be used
|
||||
mDeprecatedTextureClient->EnsureAllocated(aSize, gfxASurface::CONTENT_COLOR);
|
||||
|
@ -122,15 +121,21 @@ CanvasClientWebGL::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();
|
||||
mDeprecatedTextureClient->SetDescriptor(SurfaceStreamDescriptor(handle, false));
|
||||
SurfaceDescriptor *desc = mDeprecatedTextureClient->GetDescriptor();
|
||||
if (desc->type() != SurfaceDescriptor::TSurfaceStreamDescriptor ||
|
||||
desc->get_SurfaceStreamDescriptor().handle() != handle) {
|
||||
*desc = 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();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
aLayer->Painted();
|
||||
|
|
|
@ -26,7 +26,11 @@ public:
|
|||
* message will be sent to the compositor to create a corresponding image
|
||||
* host.
|
||||
*/
|
||||
static TemporaryRef<CanvasClient> CreateCanvasClient(CompositableType aImageHostType,
|
||||
enum CanvasClientType {
|
||||
CanvasClientSurface,
|
||||
CanvasClientGLContext,
|
||||
};
|
||||
static TemporaryRef<CanvasClient> CreateCanvasClient(CanvasClientType aType,
|
||||
CompositableForwarder* aFwd,
|
||||
TextureFlags aFlags);
|
||||
|
||||
|
@ -69,11 +73,11 @@ public:
|
|||
|
||||
// Used for GL canvases where we don't need to do any readback, i.e., with a
|
||||
// GL backend.
|
||||
class CanvasClientWebGL : public CanvasClient
|
||||
class CanvasClientSurfaceStream : public CanvasClient
|
||||
{
|
||||
public:
|
||||
CanvasClientWebGL(CompositableForwarder* aFwd,
|
||||
TextureFlags aFlags);
|
||||
CanvasClientSurfaceStream(CompositableForwarder* aFwd,
|
||||
TextureFlags aFlags);
|
||||
|
||||
TextureInfo GetTextureInfo() const MOZ_OVERRIDE
|
||||
{
|
||||
|
@ -82,6 +86,9 @@ public:
|
|||
|
||||
virtual void Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer);
|
||||
virtual void Updated() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
bool mNeedsUpdate;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ ClientCanvasLayer::RenderLayer()
|
|||
flags |= TEXTURE_DEALLOCATE_CLIENT;
|
||||
}
|
||||
}
|
||||
mCanvasClient = CanvasClient::CreateCanvasClient(GetCompositableClientType(),
|
||||
mCanvasClient = CanvasClient::CreateCanvasClient(GetCanvasClientType(),
|
||||
ClientManager(), flags);
|
||||
if (!mCanvasClient) {
|
||||
return;
|
||||
|
|
|
@ -25,6 +25,7 @@ class CanvasClientWebGL;
|
|||
class ClientCanvasLayer : public CopyableCanvasLayer,
|
||||
public ClientLayer
|
||||
{
|
||||
typedef CanvasClient::CanvasClientType CanvasClientType;
|
||||
public:
|
||||
ClientCanvasLayer(ClientLayerManager* aLayerManager) :
|
||||
CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
|
||||
|
@ -75,18 +76,18 @@ protected:
|
|||
return static_cast<ClientLayerManager*>(mManager);
|
||||
}
|
||||
|
||||
CompositableType GetCompositableClientType()
|
||||
CanvasClientType GetCanvasClientType()
|
||||
{
|
||||
if (mGLContext) {
|
||||
return BUFFER_IMAGE_BUFFERED;
|
||||
return CanvasClient::CanvasClientGLContext;
|
||||
}
|
||||
return BUFFER_IMAGE_SINGLE;
|
||||
return CanvasClient::CanvasClientSurface;
|
||||
}
|
||||
|
||||
RefPtr<CanvasClient> mCanvasClient;
|
||||
|
||||
friend class CanvasClient2D;
|
||||
friend class CanvasClientWebGL;
|
||||
friend class CanvasClientSurfaceStream;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -592,27 +592,23 @@ SurfaceStreamHostOGL::DeleteTextures()
|
|||
}
|
||||
|
||||
void
|
||||
SurfaceStreamHostOGL::SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion)
|
||||
SurfaceStreamHostOGL::UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset)
|
||||
{
|
||||
MOZ_ASSERT(aImage.type() == SurfaceDescriptor::TSurfaceStreamDescriptor,
|
||||
"Invalid descriptor");
|
||||
|
||||
mStreamGL = nullptr;
|
||||
// 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();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
mStream = SurfaceStream::FromHandle(streamDesc.handle());
|
||||
MOZ_ASSERT(mStream);
|
||||
mStreamGL = dont_AddRef(mStream->GLContext());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -626,15 +622,8 @@ bool
|
|||
SurfaceStreamHostOGL::Lock()
|
||||
{
|
||||
mGL->MakeCurrent();
|
||||
SurfaceStream* surfStream = nullptr;
|
||||
SharedSurface* sharedSurf = nullptr;
|
||||
const SurfaceStreamDescriptor& streamDesc =
|
||||
mBuffer->get_SurfaceStreamDescriptor();
|
||||
|
||||
surfStream = SurfaceStream::FromHandle(streamDesc.handle());
|
||||
MOZ_ASSERT(surfStream);
|
||||
|
||||
sharedSurf = surfStream->SwapConsumer();
|
||||
SharedSurface* sharedSurf = mStream->SwapConsumer();
|
||||
if (!sharedSurf) {
|
||||
// We don't have a valid surf to show yet.
|
||||
return false;
|
||||
|
|
|
@ -652,7 +652,6 @@ public:
|
|||
virtual ~SurfaceStreamHostOGL()
|
||||
{
|
||||
DeleteTextures();
|
||||
*mBuffer = SurfaceDescriptor();
|
||||
}
|
||||
|
||||
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
||||
|
@ -672,8 +671,9 @@ public:
|
|||
bool IsValid() const MOZ_OVERRIDE { return true; }
|
||||
|
||||
// override from DeprecatedTextureHost
|
||||
virtual void SwapTexturesImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
|
||||
virtual void UpdateImpl(const SurfaceDescriptor& aImage,
|
||||
nsIntRegion* aRegion,
|
||||
nsIntPoint* aOffset);
|
||||
virtual bool Lock() MOZ_OVERRIDE;
|
||||
virtual void Unlock() MOZ_OVERRIDE;
|
||||
|
||||
|
@ -720,6 +720,7 @@ public:
|
|||
, mTextureTarget(LOCAL_GL_TEXTURE_2D)
|
||||
, mUploadTexture(0)
|
||||
, mWrapMode(LOCAL_GL_CLAMP_TO_EDGE)
|
||||
, mStream(nullptr)
|
||||
{}
|
||||
|
||||
protected:
|
||||
|
@ -732,6 +733,7 @@ protected:
|
|||
GLuint mUploadTexture;
|
||||
GLenum mWrapMode;
|
||||
nsRefPtr<GLContext> mStreamGL;
|
||||
gfx::SurfaceStream *mStream;
|
||||
};
|
||||
|
||||
class TiledDeprecatedTextureHostOGL : public DeprecatedTextureHost
|
||||
|
|
Загрузка…
Ссылка в новой задаче