mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 874721. Ensure a compositable is valid before use. r=Bas
This commit is contained in:
parent
386aa78597
commit
afcda0726b
@ -33,7 +33,8 @@ CanvasLayerComposite::~CanvasLayerComposite()
|
||||
CleanupResources();
|
||||
}
|
||||
|
||||
void CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost) {
|
||||
void
|
||||
CanvasLayerComposite::SetCompositableHost(CompositableHost* aHost) {
|
||||
mImageHost = aHost;
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ CanvasLayerComposite::GetLayer()
|
||||
LayerRenderState
|
||||
CanvasLayerComposite::GetRenderState()
|
||||
{
|
||||
if (mDestroyed || !mImageHost) {
|
||||
if (mDestroyed || !mImageHost || !mImageHost->IsAttached()) {
|
||||
return LayerRenderState();
|
||||
}
|
||||
return mImageHost->GetRenderState();
|
||||
@ -56,7 +57,7 @@ void
|
||||
CanvasLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
const nsIntRect& aClipRect)
|
||||
{
|
||||
if (!mImageHost) {
|
||||
if (!mImageHost || !mImageHost->IsAttached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -96,8 +97,12 @@ CanvasLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
}
|
||||
|
||||
CompositableHost*
|
||||
CanvasLayerComposite::GetCompositableHost() {
|
||||
return mImageHost.get();
|
||||
CanvasLayerComposite::GetCompositableHost()
|
||||
{
|
||||
if (mImageHost->IsAttached())
|
||||
return mImageHost.get();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -115,7 +120,7 @@ CanvasLayerComposite::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
CanvasLayer::PrintInfo(aTo, aPrefix);
|
||||
aTo += "\n";
|
||||
if (mImageHost) {
|
||||
if (mImageHost && mImageHost->IsAttached()) {
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
mImageHost->PrintInfo(aTo, pfx.get());
|
||||
|
@ -18,6 +18,7 @@ CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
|
||||
: mTextureInfo(aTextureInfo)
|
||||
, mCompositor(nullptr)
|
||||
, mLayer(nullptr)
|
||||
, mAttached(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CompositableHost);
|
||||
}
|
||||
|
@ -185,13 +185,18 @@ public:
|
||||
virtual void Attach(Layer* aLayer, Compositor* aCompositor)
|
||||
{
|
||||
MOZ_ASSERT(aCompositor, "Compositor is required");
|
||||
MOZ_ASSERT(!IsAttached());
|
||||
SetCompositor(aCompositor);
|
||||
SetLayer(aLayer);
|
||||
mAttached = true;
|
||||
}
|
||||
void Detach() {
|
||||
void Detach()
|
||||
{
|
||||
SetLayer(nullptr);
|
||||
SetCompositor(nullptr);
|
||||
mAttached = false;
|
||||
}
|
||||
bool IsAttached() { return mAttached; }
|
||||
|
||||
virtual void Dump(FILE* aFile=nullptr,
|
||||
const char* aPrefix="",
|
||||
@ -217,6 +222,7 @@ protected:
|
||||
Compositor* mCompositor;
|
||||
Layer* mLayer;
|
||||
RefPtr<TextureHost> mFirstTexture;
|
||||
bool mAttached;
|
||||
};
|
||||
|
||||
class CompositableParentManager;
|
||||
|
@ -54,7 +54,7 @@ ImageLayerComposite::Disconnect()
|
||||
LayerRenderState
|
||||
ImageLayerComposite::GetRenderState()
|
||||
{
|
||||
if (mImageHost) {
|
||||
if (mImageHost && mImageHost->IsAttached()) {
|
||||
return mImageHost->GetRenderState();
|
||||
}
|
||||
return LayerRenderState();
|
||||
@ -70,7 +70,7 @@ void
|
||||
ImageLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
const nsIntRect& aClipRect)
|
||||
{
|
||||
if (!mImageHost) {
|
||||
if (!mImageHost || !mImageHost->IsAttached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,7 +106,8 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToS
|
||||
// Snap image edges to pixel boundaries
|
||||
gfxRect sourceRect(0, 0, 0, 0);
|
||||
if (mImageHost &&
|
||||
(mImageHost->GetDeprecatedTextureHost() || mImageHost->GetTextureHost())) {
|
||||
mImageHost->IsAttached() &&
|
||||
(mImageHost->GetDeprecatedTextureHost() || mImageHost->GetTextureHost())) {
|
||||
IntSize size =
|
||||
mImageHost->GetTextureHost() ? mImageHost->GetTextureHost()->GetSize()
|
||||
: mImageHost->GetDeprecatedTextureHost()->GetSize();
|
||||
@ -130,8 +131,12 @@ ImageLayerComposite::ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToS
|
||||
}
|
||||
|
||||
CompositableHost*
|
||||
ImageLayerComposite::GetCompositableHost() {
|
||||
return mImageHost.get();
|
||||
ImageLayerComposite::GetCompositableHost()
|
||||
{
|
||||
if (mImageHost->IsAttached())
|
||||
return mImageHost.get();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -149,7 +154,7 @@ ImageLayerComposite::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
ImageLayer::PrintInfo(aTo, aPrefix);
|
||||
aTo += "\n";
|
||||
if (mImageHost) {
|
||||
if (mImageHost && mImageHost->IsAttached()) {
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
mImageHost->PrintInfo(aTo, pfx.get());
|
||||
|
@ -37,15 +37,13 @@ ThebesLayerComposite::ThebesLayerComposite(LayerManagerComposite *aManager)
|
||||
ThebesLayerComposite::~ThebesLayerComposite()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ThebesLayerComposite);
|
||||
if (mBuffer) {
|
||||
mBuffer->Detach();
|
||||
}
|
||||
CleanupResources();
|
||||
}
|
||||
|
||||
void
|
||||
ThebesLayerComposite::SetCompositableHost(CompositableHost* aHost)
|
||||
{
|
||||
mBuffer= static_cast<ContentHost*>(aHost);
|
||||
mBuffer = static_cast<ContentHost*>(aHost);
|
||||
}
|
||||
|
||||
void
|
||||
@ -58,10 +56,7 @@ void
|
||||
ThebesLayerComposite::Destroy()
|
||||
{
|
||||
if (!mDestroyed) {
|
||||
if (mBuffer) {
|
||||
mBuffer->Detach();
|
||||
}
|
||||
mBuffer = nullptr;
|
||||
CleanupResources();
|
||||
mDestroyed = true;
|
||||
}
|
||||
}
|
||||
@ -75,13 +70,14 @@ ThebesLayerComposite::GetLayer()
|
||||
TiledLayerComposer*
|
||||
ThebesLayerComposite::GetTiledLayerComposer()
|
||||
{
|
||||
MOZ_ASSERT(mBuffer && mBuffer->IsAttached());
|
||||
return mBuffer->AsTiledLayerComposer();
|
||||
}
|
||||
|
||||
LayerRenderState
|
||||
ThebesLayerComposite::GetRenderState()
|
||||
{
|
||||
if (!mBuffer || mDestroyed) {
|
||||
if (!mBuffer || !mBuffer->IsAttached() || mDestroyed) {
|
||||
return LayerRenderState();
|
||||
}
|
||||
return mBuffer->GetRenderState();
|
||||
@ -91,10 +87,14 @@ void
|
||||
ThebesLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
const nsIntRect& aClipRect)
|
||||
{
|
||||
if (!mBuffer) {
|
||||
if (!mBuffer || !mBuffer->IsAttached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mBuffer->GetCompositor() == mCompositeManager->GetCompositor() &&
|
||||
mBuffer->GetLayer() == this,
|
||||
"buffer is corrupted");
|
||||
|
||||
gfx::Matrix4x4 transform;
|
||||
ToMatrix4x4(GetEffectiveTransform(), transform);
|
||||
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
@ -144,14 +144,19 @@ ThebesLayerComposite::RenderLayer(const nsIntPoint& aOffset,
|
||||
}
|
||||
|
||||
CompositableHost*
|
||||
ThebesLayerComposite::GetCompositableHost() {
|
||||
return mBuffer.get();
|
||||
ThebesLayerComposite::GetCompositableHost()
|
||||
{
|
||||
if (mBuffer->IsAttached()) {
|
||||
return mBuffer.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
ThebesLayerComposite::CleanupResources()
|
||||
{
|
||||
if (mBuffer) {
|
||||
if (mBuffer) {
|
||||
mBuffer->Detach();
|
||||
}
|
||||
mBuffer = nullptr;
|
||||
@ -282,7 +287,7 @@ ThebesLayerComposite::PrintInfo(nsACString& aTo, const char* aPrefix)
|
||||
{
|
||||
ThebesLayer::PrintInfo(aTo, aPrefix);
|
||||
aTo += "\n";
|
||||
if (mBuffer) {
|
||||
if (mBuffer && mBuffer->IsAttached()) {
|
||||
nsAutoCString pfx(aPrefix);
|
||||
pfx += " ";
|
||||
mBuffer->PrintInfo(aTo, pfx.get());
|
||||
|
Loading…
Reference in New Issue
Block a user