Skip to content

Commit

Permalink
Bug 1332005 - Remove opaque BGRA8 image surface optimization. r=tnikkel
Browse files Browse the repository at this point in the history
  • Loading branch information
aosmond committed Jan 18, 2017
1 parent 8ee0e84 commit 4866c62
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
31 changes: 0 additions & 31 deletions image/imgFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "mozilla/gfx/Tools.h"
#include "mozilla/Likely.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Telemetry.h"
#include "nsMargin.h"
#include "nsThreadUtils.h"

Expand Down Expand Up @@ -165,7 +164,6 @@ imgFrame::imgFrame()
, mTimeout(FrameTimeout::FromRawMilliseconds(100))
, mDisposalMethod(DisposalMethod::NOT_SPECIFIED)
, mBlendMethod(BlendMethod::OVER)
, mHasNoAlpha(false)
, mAborted(false)
, mFinished(false)
, mOptimizable(false)
Expand Down Expand Up @@ -383,23 +381,6 @@ imgFrame::InitWithDrawable(gfxDrawable* aDrawable,
return NS_OK;
}

bool
imgFrame::CanOptimizeOpaqueImage()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!ShutdownTracker::ShutdownHasStarted());
mMonitor.AssertCurrentThreadOwns();

// If we're using a surface format with alpha but the image has no alpha,
// change the format. This doesn't change the underlying data at all, but
// allows DrawTargets to avoid blending when drawing known opaque images.
// This optimization is free and safe, so we always do it when we can except
// if we have a Skia backend. Skia doesn't support RGBX so ensure we don't
// optimize to a RGBX surface.
return mHasNoAlpha && mFormat == SurfaceFormat::B8G8R8A8 && mImageSurface &&
(gfxPlatform::GetPlatform()->GetDefaultContentBackend() != BackendType::SKIA);
}

nsresult
imgFrame::Optimize(DrawTarget* aTarget)
{
Expand All @@ -426,12 +407,6 @@ imgFrame::Optimize(DrawTarget* aTarget)
return NS_OK;
}

// This optimization is basically free, so we perform it even if optimization is disabled.
if (CanOptimizeOpaqueImage()) {
mFormat = SurfaceFormat::B8G8R8X8;
mImageSurface = CreateLockedSurface(mVBuf, mFrameRect.Size(), mFormat);
}

if (gDisableOptimize) {
return NS_OK;
}
Expand Down Expand Up @@ -619,12 +594,6 @@ imgFrame::Finish(Opacity aFrameOpacity /* = Opacity::SOME_TRANSPARENCY */,
MonitorAutoLock lock(mMonitor);
MOZ_ASSERT(mLockCount > 0, "Image data should be locked");

if (aFrameOpacity == Opacity::FULLY_OPAQUE) {
mHasNoAlpha = true;
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_OPAQUE_BGRA,
mFormat == SurfaceFormat::B8G8R8A8);
}

mDisposalMethod = aDisposalMethod;
mTimeout = aTimeout;
mBlendMethod = aBlendMethod;
Expand Down
2 changes: 0 additions & 2 deletions image/imgFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ class imgFrame

nsresult LockImageData();
nsresult UnlockImageData();
bool CanOptimizeOpaqueImage();
nsresult Optimize(gfx::DrawTarget* aTarget);

void AssertImageDataLocked() const;
Expand Down Expand Up @@ -415,7 +414,6 @@ class imgFrame
Maybe<IntRect> mBlendRect;
SurfaceFormat mFormat;

bool mHasNoAlpha;
bool mAborted;
bool mFinished;
bool mOptimizable;
Expand Down
7 changes: 0 additions & 7 deletions toolkit/components/telemetry/Histograms.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,6 @@
"n_buckets": 50,
"description": "Decode count"
},
"IMAGE_DECODE_OPAQUE_BGRA": {
"alert_emails": ["aosmond@mozilla.com"],
"expires_in_version": "53",
"kind": "boolean",
"description": "Opaque images are BGRA",
"bug_numbers": [1311779]
},
"IMAGE_DECODE_SPEED_JPEG": {
"expires_in_version": "never",
"kind": "exponential",
Expand Down

0 comments on commit 4866c62

Please sign in to comment.