Backed out changeset f534fcb785c9 (bug 1167235)

This commit is contained in:
Sebastian Hengst 2016-06-28 20:28:22 +02:00
parent 955599781a
commit 7f0473d085
6 changed files with 12 additions and 107 deletions

View File

@ -745,36 +745,6 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(CanvasPattern, Release)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CanvasPattern, mContext)
class CanvasShutdownObserver final : public nsIObserver
{
public:
explicit CanvasShutdownObserver(CanvasRenderingContext2D* aCanvas)
: mCanvas(aCanvas)
{}
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
private:
~CanvasShutdownObserver() {}
CanvasRenderingContext2D* mCanvas;
};
NS_IMPL_ISUPPORTS(CanvasShutdownObserver, nsIObserver)
NS_IMETHODIMP
CanvasShutdownObserver::Observe(nsISupports *aSubject,
const char *aTopic,
const char16_t *aData)
{
if (mCanvas && strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
mCanvas->OnShutdown();
nsContentUtils::UnregisterShutdownObserver(this);
}
return NS_OK;
}
class CanvasDrawObserver
{
public:
@ -1074,9 +1044,6 @@ CanvasRenderingContext2D::CanvasRenderingContext2D()
{
sNumLivingContexts++;
mShutdownObserver = new CanvasShutdownObserver(this);
nsContentUtils::RegisterShutdownObserver(mShutdownObserver);
// The default is to use OpenGL mode
if (gfxPlatform::GetPlatform()->UseAcceleratedCanvas()) {
mDrawObserver = new CanvasDrawObserver(this);
@ -1089,7 +1056,6 @@ CanvasRenderingContext2D::~CanvasRenderingContext2D()
{
RemoveDrawObserver();
RemovePostRefreshObserver();
RemoveShutdownObserver();
Reset();
// Drop references from all CanvasRenderingContext2DUserData to this context
for (uint32_t i = 0; i < mUserDatas.Length(); ++i) {
@ -1182,29 +1148,6 @@ CanvasRenderingContext2D::Reset()
return NS_OK;
}
void
CanvasRenderingContext2D::OnShutdown()
{
mShutdownObserver = nullptr;
RefPtr<PersistentBufferProvider> provider = mBufferProvider;
Reset();
if (provider) {
provider->OnShutdown();
}
}
void
CanvasRenderingContext2D::RemoveShutdownObserver()
{
if (mShutdownObserver) {
nsContentUtils::UnregisterShutdownObserver(mShutdownObserver);
mShutdownObserver = nullptr;
}
}
void
CanvasRenderingContext2D::SetStyleFromString(const nsAString& aStr,
Style aWhichStyle)
@ -1513,13 +1456,6 @@ CanvasRenderingContext2D::RenderingMode
CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect,
RenderingMode aRenderingMode)
{
if (AlreadyShutDown()) {
gfxCriticalError() << "Attempt to render into a Canvas2d after shutdown.";
EnsureErrorTarget();
mTarget = sErrorTarget;
return aRenderingMode;
}
// This would make no sense, so make sure we don't get ourselves in a mess
MOZ_ASSERT(mRenderingMode != RenderingMode::DefaultBackendMode);
@ -5755,10 +5691,6 @@ void CanvasRenderingContext2D::RemoveDrawObserver()
PersistentBufferProvider*
CanvasRenderingContext2D::GetBufferProvider(LayerManager* aManager)
{
if (AlreadyShutDown()) {
return nullptr;
}
if (mBufferProvider) {
return mBufferProvider;
}

View File

@ -54,7 +54,6 @@ template<typename T> class Optional;
struct CanvasBidiProcessor;
class CanvasRenderingContext2DUserData;
class CanvasDrawObserver;
class CanvasShutdownObserver;
/**
** CanvasRenderingContext2D
@ -546,7 +545,6 @@ public:
// return true and fills in the bound rect if element has a hit region.
bool GetHitRegionRect(Element* aElement, nsRect& aRect) override;
void OnShutdown();
protected:
nsresult GetImageDataArray(JSContext* aCx, int32_t aX, int32_t aY,
uint32_t aWidth, uint32_t aHeight,
@ -751,10 +749,6 @@ protected:
CanvasDrawObserver* mDrawObserver;
void RemoveDrawObserver();
RefPtr<CanvasShutdownObserver> mShutdownObserver;
void RemoveShutdownObserver();
bool AlreadyShutDown() const { return !mShutdownObserver; }
/**
* Flag to avoid duplicate calls to InvalidateFrame. Set to true whenever
* Redraw is called, reset to false when Render is called.

View File

@ -353,7 +353,8 @@ HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& a
: nsGenericHTMLElement(aNodeInfo),
mResetLayer(true) ,
mWriteOnly(false)
{}
{
}
HTMLCanvasElement::~HTMLCanvasElement()
{

View File

@ -126,7 +126,16 @@ PersistentBufferProviderShared::~PersistentBufferProviderShared()
mFwd->GetActiveResourceTracker().RemoveObject(this);
}
Destroy();
mDrawTarget = nullptr;
if (mBack && mBack->IsLocked()) {
mBack->Unlock();
}
if (mFront && mFront->IsLocked()) {
mFront->Unlock();
}
if (mBuffer && mBuffer->IsLocked()) {
mBuffer->Unlock();
}
}
already_AddRefed<gfx::DrawTarget>
@ -267,28 +276,5 @@ PersistentBufferProviderShared::NotifyInactive()
mBuffer = nullptr;
}
void
PersistentBufferProviderShared::Destroy()
{
mSnapshot = nullptr;
mDrawTarget = nullptr;
if (mFront && mFront->IsLocked()) {
mFront->Unlock();
}
if (mBack && mBack->IsLocked()) {
mBack->Unlock();
}
if (mBuffer && mBuffer->IsLocked()) {
mBuffer->Unlock();
}
mFront = nullptr;
mBack = nullptr;
mBuffer = nullptr;
}
} // namespace layers
} // namespace mozilla

View File

@ -60,8 +60,6 @@ public:
virtual void ReturnSnapshot(already_AddRefed<gfx::SourceSurface> aSnapshot) = 0;
virtual TextureClient* GetTextureClient() { return nullptr; }
virtual void OnShutdown() {}
};
@ -123,8 +121,6 @@ public:
virtual void NotifyInactive() override;
virtual void OnShutdown() override { Destroy(); }
protected:
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
@ -132,8 +128,6 @@ protected:
~PersistentBufferProviderShared();
void Destroy();
gfx::IntSize mSize;
gfx::SurfaceFormat mFormat;
RefPtr<CompositableForwarder> mFwd;

View File

@ -364,8 +364,6 @@ void TextureClient::Destroy(bool aForceSync)
mActor->Lock();
}
mReadLock = nullptr;
CancelWaitFenceHandleOnImageBridge();
RefPtr<TextureChild> actor = mActor;
mActor = nullptr;