Bug 1102617 - Replace imgIContainer::FrameIsOpaque with imgIContainer::IsOpaque. r=tn

This commit is contained in:
Seth Fowler 2014-11-24 23:42:43 -08:00
Родитель 6f86073257
Коммит 626d39ccdc
14 изменённых файлов: 29 добавлений и 63 удалений

Просмотреть файл

@ -69,7 +69,7 @@ native nsIntSizeByVal(nsIntSize);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(f8bb7671-5f36-490b-b828-3f4c6ad38665)]
[scriptable, builtinclass, uuid(14ea6fa5-183e-4409-ac88-110bd2e05292)]
interface imgIContainer : nsISupports
{
/**
@ -215,12 +215,9 @@ interface imgIContainer : nsISupports
in uint32_t aFlags);
/**
* Whether the given frame is opaque; that is, needs the background painted
* behind it.
*
* @param aWhichFrame Frame specifier of the FRAME_* variety.
* Whether this image is opaque (i.e., needs a background painted behind it).
*/
[notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame);
[notxpcom] boolean isOpaque();
/**
* Attempts to create an ImageContainer (and Image) containing the current

Просмотреть файл

@ -228,7 +228,7 @@ DynamicImage::GetFrame(uint32_t aWhichFrame,
}
NS_IMETHODIMP_(bool)
DynamicImage::FrameIsOpaque(uint32_t aWhichFrame)
DynamicImage::IsOpaque()
{
// XXX(seth): For performance reasons it'd be better to return true here, but
// I'm not sure how we can guarantee it for an arbitrary gfxDrawable.

Просмотреть файл

@ -50,12 +50,6 @@ FrozenImage::GetFrame(uint32_t aWhichFrame,
return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
}
NS_IMETHODIMP_(bool)
FrozenImage::FrameIsOpaque(uint32_t aWhichFrame)
{
return InnerImage()->FrameIsOpaque(FRAME_FIRST);
}
NS_IMETHODIMP
FrozenImage::GetImageContainer(layers::LayerManager* aManager,
layers::ImageContainer** _retval)

Просмотреть файл

@ -38,7 +38,6 @@ public:
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
NS_IMETHOD_(TemporaryRef<SourceSurface>)
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
layers::ImageContainer** _retval) MOZ_OVERRIDE;
NS_IMETHOD Draw(gfxContext* aContext,

Просмотреть файл

@ -209,9 +209,9 @@ ImageWrapper::GetFrame(uint32_t aWhichFrame,
}
NS_IMETHODIMP_(bool)
ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame)
ImageWrapper::IsOpaque()
{
return mInnerImage->FrameIsOpaque(aWhichFrame);
return mInnerImage->IsOpaque();
}
NS_IMETHODIMP

Просмотреть файл

@ -112,7 +112,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
// Determine an appropriate format for the surface.
gfx::SurfaceFormat surfaceFormat;
if (InnerImage()->FrameIsOpaque(aWhichFrame)) {
if (InnerImage()->IsOpaque()) {
surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
} else {
surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;

Просмотреть файл

@ -101,6 +101,9 @@ public:
// Get the current image status (as in imgIRequest).
uint32_t GetImageStatus() const;
// Get the current Progress.
Progress GetProgress() const { return mProgress; }
// Schedule an asynchronous "replaying" of all the notifications that would
// have to happen to put us in the current state.
// We will also take note of any notifications that happen between the time

Просмотреть файл

@ -654,33 +654,22 @@ RasterImage::GetFirstFrameRect()
return nsIntRect(nsIntPoint(0,0), mSize);
}
//******************************************************************************
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
NS_IMETHODIMP_(bool)
RasterImage::FrameIsOpaque(uint32_t aWhichFrame)
RasterImage::IsOpaque()
{
if (aWhichFrame > FRAME_MAX_VALUE) {
NS_WARNING("aWhichFrame outside valid range!");
if (mError) {
return false;
}
if (mError)
Progress progress = mProgressTracker->GetProgress();
// If we haven't yet finished decoding, the safe answer is "not opaque".
if (!(progress & FLAG_DECODE_COMPLETE)) {
return false;
}
// See if we can get an image frame.
nsRefPtr<imgFrame> frame =
LookupFrameNoDecode(GetRequestedFrameIndex(aWhichFrame));
// If we don't get a frame, the safe answer is "not opaque".
if (!frame)
return false;
// Other, the frame is transparent if either:
// 1. It needs a background.
// 2. Its size doesn't cover our entire area.
nsIntRect framerect = frame->GetRect();
return !frame->GetNeedsBackground() &&
framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height));
// Other, we're opaque if FLAG_HAS_TRANSPARENCY is not set.
return !(progress & FLAG_HAS_TRANSPARENCY);
}
nsIntRect
@ -767,7 +756,7 @@ RasterImage::CopyFrame(uint32_t aWhichFrame,
if (mError)
return nullptr;
if (!ApplyDecodeFlags(aFlags, aWhichFrame))
if (!ApplyDecodeFlags(aFlags))
return nullptr;
// Get the frame. If it's not there, it's probably the caller's fault for
@ -844,7 +833,7 @@ RasterImage::GetFrameInternal(uint32_t aWhichFrame,
if (mError)
return nullptr;
if (!ApplyDecodeFlags(aFlags, aWhichFrame))
if (!ApplyDecodeFlags(aFlags))
return nullptr;
// Get the frame. If it's not there, it's probably the caller's fault for
@ -1120,7 +1109,7 @@ RasterImage::InternalAddFrame(uint32_t framenum,
}
bool
RasterImage::ApplyDecodeFlags(uint32_t aNewFlags, uint32_t aWhichFrame)
RasterImage::ApplyDecodeFlags(uint32_t aNewFlags)
{
if (mFrameDecodeFlags == (aNewFlags & DECODE_FLAGS_MASK))
return true; // Not asking very much of us here.
@ -1133,7 +1122,7 @@ RasterImage::ApplyDecodeFlags(uint32_t aNewFlags, uint32_t aWhichFrame)
(mFrameDecodeFlags & DECODE_FLAGS_MASK) & ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
uint32_t newNonAlphaFlags =
(aNewFlags & DECODE_FLAGS_MASK) & ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
if (currentNonAlphaFlags == newNonAlphaFlags && FrameIsOpaque(aWhichFrame)) {
if (currentNonAlphaFlags == newNonAlphaFlags && IsOpaque()) {
return true;
}
@ -2537,8 +2526,7 @@ RasterImage::Draw(gfxContext* aContext,
// is opaque.
bool haveDefaultFlags = (mFrameDecodeFlags == DECODE_FLAGS_DEFAULT);
bool haveSafeAlphaFlags =
(mFrameDecodeFlags == FLAG_DECODE_NO_PREMULTIPLY_ALPHA) &&
FrameIsOpaque(FRAME_CURRENT);
(mFrameDecodeFlags == FLAG_DECODE_NO_PREMULTIPLY_ALPHA) && IsOpaque();
if (!(haveDefaultFlags || haveSafeAlphaFlags)) {
if (!CanForciblyDiscardAndRedecode())

Просмотреть файл

@ -338,7 +338,7 @@ private:
nsresult DoImageDataComplete();
bool ApplyDecodeFlags(uint32_t aNewFlags, uint32_t aWhichFrame);
bool ApplyDecodeFlags(uint32_t aNewFlags);
already_AddRefed<layers::Image> GetCurrentImage();
void UpdateImageContainer();

Просмотреть файл

@ -687,15 +687,9 @@ VectorImage::GetFirstFrameDelay()
return 0;
}
//******************************************************************************
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
NS_IMETHODIMP_(bool)
VectorImage::FrameIsOpaque(uint32_t aWhichFrame)
VectorImage::IsOpaque()
{
if (aWhichFrame > FRAME_MAX_VALUE)
NS_WARNING("aWhichFrame outside valid range!");
return false; // In general, SVG content is not opaque.
}

Просмотреть файл

@ -584,12 +584,6 @@ SurfaceFormat imgFrame::GetFormat() const
return mFormat;
}
bool imgFrame::GetNeedsBackground() const
{
// We need a background painted if we have alpha or we're incomplete.
return (mFormat == SurfaceFormat::B8G8R8A8 || !ImageComplete());
}
uint32_t imgFrame::GetImageBytesPerRow() const
{
if (mVBuf)

Просмотреть файл

@ -88,7 +88,6 @@ public:
bool NeedsPadding() const { return mOffset != nsIntPoint(0, 0); }
int32_t GetStride() const;
SurfaceFormat GetFormat() const;
bool GetNeedsBackground() const;
uint32_t GetImageBytesPerRow() const;
uint32_t GetImageDataLength() const;
bool GetIsPaletted() const;

Просмотреть файл

@ -1453,9 +1453,7 @@ nsDisplayImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
bool* aSnap)
{
*aSnap = true;
bool animated;
if (mImage && mImage->GetAnimated(&animated) == NS_OK && !animated &&
mImage->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) {
if (mImage && mImage->IsOpaque()) {
// OK, the entire region painted by the image is opaque. But what is that
// region? It's the image's "dest rect" (the rect where a full copy of
// the image is mapped), clipped to the container's content box (which is

Просмотреть файл

@ -2054,8 +2054,8 @@ nsStyleImage::IsOpaque() const
mImage->GetImage(getter_AddRefs(imageContainer));
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
// Check if the crop region of the current image frame is opaque.
if (imageContainer->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) {
// Check if the crop region of the image is opaque.
if (imageContainer->IsOpaque()) {
if (!mCropRect)
return true;