Backed out changeset e0d755ab4cbd (bug 1302380) for timeouts reftest with e10s invariable-declaration-XX.html on Linux 32 bit. r=backout

This commit is contained in:
Sebastian Hengst 2016-09-16 18:55:44 +02:00
parent 0a42c7bfec
commit 548f7778a1
7 changed files with 42 additions and 77 deletions

View File

@ -1159,6 +1159,12 @@ CanvasRenderingContext2D::Reset()
mCanvasElement->InvalidateCanvas();
}
// only do this for non-docshell created contexts,
// since those are the ones that we created a surface for
if (mTarget && IsTargetValid() && !mDocShell) {
gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
}
bool forceReset = true;
ReturnTarget(forceReset);
mTarget = nullptr;
@ -1621,6 +1627,8 @@ CanvasRenderingContext2D::EnsureTarget(const gfx::Rect* aCoveredRect,
mTarget = newTarget.forget();
mBufferProvider = newProvider.forget();
RegisterAllocation();
// Skia expects the unused X channel to contains 0 even for opaque operations
// so we can't skip clearing in that case, even if we are going to cover the
// entire canvas in the next drawing operation.
@ -1664,6 +1672,10 @@ CanvasRenderingContext2D::SetErrorState()
{
EnsureErrorTarget();
if (mTarget && mTarget != sErrorTarget) {
gCanvasAzureMemoryUsed -= mWidth * mHeight * 4;
}
mTarget = sErrorTarget;
mBufferProvider = nullptr;
@ -1672,13 +1684,22 @@ CanvasRenderingContext2D::SetErrorState()
}
void
EnsureCanvasMemoryReporter()
CanvasRenderingContext2D::RegisterAllocation()
{
// XXX - It would make more sense to track the allocation in
// PeristentBufferProvider, rather than here.
static bool registered = false;
if (!registered) {
// FIXME: Disable the reporter for now, see bug 1241865
if (!registered && false) {
registered = true;
RegisterStrongMemoryReporter(new Canvas2dPixelsReporter());
}
gCanvasAzureMemoryUsed += mWidth * mHeight * 4;
JSContext* context = nsContentUtils::GetCurrentJSContext();
if (context) {
JS_updateMallocCounter(context, mWidth * mHeight * 4);
}
}
static already_AddRefed<LayerManager>
@ -1762,9 +1783,7 @@ CanvasRenderingContext2D::TrySharedTarget(RefPtr<gfx::DrawTarget>& aOutDT,
return false;
}
EnsureCanvasMemoryReporter();
aOutProvider = layerManager->CreatePersistentBufferProvider(GetSize(), GetSurfaceFormat(),
&gCanvasAzureMemoryUsed);
aOutProvider = layerManager->CreatePersistentBufferProvider(GetSize(), GetSurfaceFormat());
if (!aOutProvider) {
return false;

View File

@ -202,18 +202,15 @@ LayerManager::CreateDrawTarget(const IntSize &aSize,
already_AddRefed<PersistentBufferProvider>
LayerManager::CreatePersistentBufferProvider(const mozilla::gfx::IntSize &aSize,
mozilla::gfx::SurfaceFormat aFormat,
int64_t* aMemoryCounter)
mozilla::gfx::SurfaceFormat aFormat)
{
RefPtr<PersistentBufferProviderBasic> bufferProvider =
PersistentBufferProviderBasic::Create(aSize, aFormat,
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend(),
aMemoryCounter
);
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
if (!bufferProvider) {
bufferProvider = PersistentBufferProviderBasic::Create(aSize, aFormat,
gfxPlatform::GetPlatform()->GetFallbackCanvasBackend(), aMemoryCounter);
gfxPlatform::GetPlatform()->GetFallbackCanvasBackend());
}
return bufferProvider.forget();

View File

@ -485,8 +485,7 @@ public:
*/
virtual already_AddRefed<PersistentBufferProvider>
CreatePersistentBufferProvider(const mozilla::gfx::IntSize &aSize,
mozilla::gfx::SurfaceFormat aFormat,
int64_t* aMemoryCounter);
mozilla::gfx::SurfaceFormat aFormat);
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) { return true; }

View File

@ -16,23 +16,14 @@ using namespace gfx;
namespace layers {
PersistentBufferProviderBasic::PersistentBufferProviderBasic(DrawTarget* aDt, int64_t* aMemoryCounter)
PersistentBufferProviderBasic::PersistentBufferProviderBasic(DrawTarget* aDt)
: mDrawTarget(aDt)
, mMemoryCounter(aMemoryCounter)
{
if (mMemoryCounter) {
IntSize size = mDrawTarget->GetSize();
*mMemoryCounter += size.width * size.height * gfx::BytesPerPixel(mDrawTarget->GetFormat());
}
MOZ_COUNT_CTOR(PersistentBufferProviderBasic);
}
PersistentBufferProviderBasic::~PersistentBufferProviderBasic()
{
if (mMemoryCounter) {
IntSize size = mDrawTarget->GetSize();
*mMemoryCounter -= size.width * size.height * gfx::BytesPerPixel(mDrawTarget->GetFormat());
}
MOZ_COUNT_DTOR(PersistentBufferProviderBasic);
}
@ -76,7 +67,7 @@ PersistentBufferProviderBasic::ReturnSnapshot(already_AddRefed<gfx::SourceSurfac
//static
already_AddRefed<PersistentBufferProviderBasic>
PersistentBufferProviderBasic::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aBackend, int64_t* aMemoryCounter)
gfx::BackendType aBackend)
{
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->CreateDrawTargetForBackend(aBackend, aSize, aFormat);
@ -85,7 +76,7 @@ PersistentBufferProviderBasic::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFo
}
RefPtr<PersistentBufferProviderBasic> provider =
new PersistentBufferProviderBasic(dt, aMemoryCounter);
new PersistentBufferProviderBasic(dt);
return provider.forget();
}
@ -95,8 +86,7 @@ PersistentBufferProviderBasic::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFo
already_AddRefed<PersistentBufferProviderShared>
PersistentBufferProviderShared::Create(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
int64_t* aMemoryCounter)
CompositableForwarder* aFwd)
{
if (!aFwd || !aFwd->IPCOpen()) {
return nullptr;
@ -114,27 +104,23 @@ PersistentBufferProviderShared::Create(gfx::IntSize aSize,
}
RefPtr<PersistentBufferProviderShared> provider =
new PersistentBufferProviderShared(aSize, aFormat, aFwd, texture, aMemoryCounter);
new PersistentBufferProviderShared(aSize, aFormat, aFwd, texture);
return provider.forget();
}
PersistentBufferProviderShared::PersistentBufferProviderShared(gfx::IntSize aSize,
gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
RefPtr<TextureClient>& aTexture,
int64_t* aMemoryCounter)
RefPtr<TextureClient>& aTexture)
: mSize(aSize)
, mFormat(aFormat)
, mFwd(aFwd)
, mFront(Nothing())
, mMemoryCounter(aMemoryCounter)
{
if (mTextures.append(aTexture)) {
mBack = Some<uint32_t>(0);
}
OnAllocation();
MOZ_COUNT_CTOR(PersistentBufferProviderShared);
}
@ -307,7 +293,6 @@ PersistentBufferProviderShared::BorrowDrawTarget(const gfx::IntRect& aPersistedR
MOZ_ASSERT(newTexture);
if (newTexture) {
OnAllocation();
if (mTextures.append(newTexture)) {
tex = newTexture;
mBack = Some<uint32_t>(mTextures.length() - 1);
@ -420,17 +405,12 @@ PersistentBufferProviderShared::NotifyInactive()
RefPtr<TextureClient> front = GetTexture(mFront);
RefPtr<TextureClient> back = GetTexture(mBack);
for (unsigned i = 0; i < mTextures.length(); ++i) {
OnDeallocation();
}
// Clear all textures (except the front and back ones that we just kept).
mTextures.clear();
if (back) {
if (mTextures.append(back)) {
mBack = Some<uint32_t>(0);
OnAllocation();
}
if (front == back) {
mFront = mBack;
@ -440,7 +420,6 @@ PersistentBufferProviderShared::NotifyInactive()
if (front && front != back) {
if (mTextures.append(front)) {
mFront = Some<uint32_t>(mTextures.length() - 1);
OnAllocation();
}
}
}
@ -457,29 +436,10 @@ PersistentBufferProviderShared::Destroy()
MOZ_ASSERT(false);
texture->Unlock();
}
if (texture) {
OnDeallocation();
}
}
mTextures.clear();
}
void
PersistentBufferProviderShared::OnAllocation()
{
if (mMemoryCounter) {
*mMemoryCounter += mSize.width * mSize.height * gfx::BytesPerPixel(mFormat);
}
}
void
PersistentBufferProviderShared::OnDeallocation()
{
if (mMemoryCounter) {
*mMemoryCounter -= mSize.width * mSize.height * gfx::BytesPerPixel(mFormat);
}
}
} // namespace layers
} // namespace mozilla

View File

@ -82,10 +82,9 @@ public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PersistentBufferProviderBasic, override)
static already_AddRefed<PersistentBufferProviderBasic>
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, gfx::BackendType aBackend,
int64_t* aMemoryCounter);
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, gfx::BackendType aBackend);
explicit PersistentBufferProviderBasic(gfx::DrawTarget* aTarget, int64_t* aMemoryCounter = nullptr);
explicit PersistentBufferProviderBasic(gfx::DrawTarget* aTarget);
virtual LayersBackend GetType() override { return LayersBackend::LAYERS_BASIC; }
@ -103,7 +102,6 @@ private:
RefPtr<gfx::DrawTarget> mDrawTarget;
RefPtr<gfx::SourceSurface> mSnapshot;
int64_t* mMemoryCounter;
};
@ -119,8 +117,7 @@ public:
static already_AddRefed<PersistentBufferProviderShared>
Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
int64_t* aMemoryCounter);
CompositableForwarder* aFwd);
virtual LayersBackend GetType() override { return LayersBackend::LAYERS_CLIENT; }
@ -144,14 +141,10 @@ public:
protected:
PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
CompositableForwarder* aFwd,
RefPtr<TextureClient>& aTexture,
int64_t* aMemoryCounter);
RefPtr<TextureClient>& aTexture);
~PersistentBufferProviderShared();
void OnAllocation();
void OnDeallocation();
TextureClient* GetTexture(Maybe<uint32_t> aIndex);
bool CheckIndex(uint32_t aIndex) { return aIndex < mTextures.length(); }
@ -168,7 +161,6 @@ protected:
RefPtr<gfx::DrawTarget> mDrawTarget;
RefPtr<gfx::SourceSurface > mSnapshot;
int64_t* mMemoryCounter;
};
struct AutoReturnSnapshot

View File

@ -840,8 +840,7 @@ ClientLayerManager::DependsOnStaleDevice() const
already_AddRefed<PersistentBufferProvider>
ClientLayerManager::CreatePersistentBufferProvider(const gfx::IntSize& aSize,
gfx::SurfaceFormat aFormat,
int64_t* aMemoryCounter)
gfx::SurfaceFormat aFormat)
{
// Don't use a shared buffer provider if compositing is considered "not cheap"
// because the canvas will most likely be flattened into a thebes layer instead
@ -850,13 +849,13 @@ ClientLayerManager::CreatePersistentBufferProvider(const gfx::IntSize& aSize,
if (IsCompositingCheap() &&
gfxPrefs::PersistentBufferProviderSharedEnabled()) {
RefPtr<PersistentBufferProvider> provider
= PersistentBufferProviderShared::Create(aSize, aFormat, AsShadowForwarder(), aMemoryCounter);
= PersistentBufferProviderShared::Create(aSize, aFormat, AsShadowForwarder());
if (provider) {
return provider.forget();
}
}
return LayerManager::CreatePersistentBufferProvider(aSize, aFormat, aMemoryCounter);
return LayerManager::CreatePersistentBufferProvider(aSize, aFormat);
}

View File

@ -231,8 +231,7 @@ public:
void RemoveDidCompositeObserver(DidCompositeObserver* aObserver);
virtual already_AddRefed<PersistentBufferProvider>
CreatePersistentBufferProvider(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat,
int64_t* aMemoryCounter) override;
CreatePersistentBufferProvider(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) override;
protected:
enum TransactionPhase {