зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1102617 - Replace imgIContainer::FrameIsOpaque with imgIContainer::IsOpaque. r=tn
This commit is contained in:
Родитель
6f86073257
Коммит
626d39ccdc
|
@ -69,7 +69,7 @@ native nsIntSizeByVal(nsIntSize);
|
||||||
*
|
*
|
||||||
* Internally, imgIContainer also manages animation of images.
|
* 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
|
interface imgIContainer : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -215,12 +215,9 @@ interface imgIContainer : nsISupports
|
||||||
in uint32_t aFlags);
|
in uint32_t aFlags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the given frame is opaque; that is, needs the background painted
|
* Whether this image is opaque (i.e., needs a background painted behind it).
|
||||||
* behind it.
|
|
||||||
*
|
|
||||||
* @param aWhichFrame Frame specifier of the FRAME_* variety.
|
|
||||||
*/
|
*/
|
||||||
[notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame);
|
[notxpcom] boolean isOpaque();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to create an ImageContainer (and Image) containing the current
|
* Attempts to create an ImageContainer (and Image) containing the current
|
||||||
|
|
|
@ -228,7 +228,7 @@ DynamicImage::GetFrame(uint32_t aWhichFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
NS_IMETHODIMP_(bool)
|
||||||
DynamicImage::FrameIsOpaque(uint32_t aWhichFrame)
|
DynamicImage::IsOpaque()
|
||||||
{
|
{
|
||||||
// XXX(seth): For performance reasons it'd be better to return true here, but
|
// 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.
|
// 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);
|
return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
|
||||||
FrozenImage::FrameIsOpaque(uint32_t aWhichFrame)
|
|
||||||
{
|
|
||||||
return InnerImage()->FrameIsOpaque(FRAME_FIRST);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FrozenImage::GetImageContainer(layers::LayerManager* aManager,
|
FrozenImage::GetImageContainer(layers::LayerManager* aManager,
|
||||||
layers::ImageContainer** _retval)
|
layers::ImageContainer** _retval)
|
||||||
|
|
|
@ -38,7 +38,6 @@ public:
|
||||||
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
|
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
|
||||||
NS_IMETHOD_(TemporaryRef<SourceSurface>)
|
NS_IMETHOD_(TemporaryRef<SourceSurface>)
|
||||||
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
|
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
|
||||||
NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
|
|
||||||
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
|
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
|
||||||
layers::ImageContainer** _retval) MOZ_OVERRIDE;
|
layers::ImageContainer** _retval) MOZ_OVERRIDE;
|
||||||
NS_IMETHOD Draw(gfxContext* aContext,
|
NS_IMETHOD Draw(gfxContext* aContext,
|
||||||
|
|
|
@ -209,9 +209,9 @@ ImageWrapper::GetFrame(uint32_t aWhichFrame,
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(bool)
|
NS_IMETHODIMP_(bool)
|
||||||
ImageWrapper::FrameIsOpaque(uint32_t aWhichFrame)
|
ImageWrapper::IsOpaque()
|
||||||
{
|
{
|
||||||
return mInnerImage->FrameIsOpaque(aWhichFrame);
|
return mInnerImage->IsOpaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -112,7 +112,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
|
||||||
|
|
||||||
// Determine an appropriate format for the surface.
|
// Determine an appropriate format for the surface.
|
||||||
gfx::SurfaceFormat surfaceFormat;
|
gfx::SurfaceFormat surfaceFormat;
|
||||||
if (InnerImage()->FrameIsOpaque(aWhichFrame)) {
|
if (InnerImage()->IsOpaque()) {
|
||||||
surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
|
surfaceFormat = gfx::SurfaceFormat::B8G8R8X8;
|
||||||
} else {
|
} else {
|
||||||
surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
|
surfaceFormat = gfx::SurfaceFormat::B8G8R8A8;
|
||||||
|
|
|
@ -101,6 +101,9 @@ public:
|
||||||
// Get the current image status (as in imgIRequest).
|
// Get the current image status (as in imgIRequest).
|
||||||
uint32_t GetImageStatus() const;
|
uint32_t GetImageStatus() const;
|
||||||
|
|
||||||
|
// Get the current Progress.
|
||||||
|
Progress GetProgress() const { return mProgress; }
|
||||||
|
|
||||||
// Schedule an asynchronous "replaying" of all the notifications that would
|
// Schedule an asynchronous "replaying" of all the notifications that would
|
||||||
// have to happen to put us in the current state.
|
// have to happen to put us in the current state.
|
||||||
// We will also take note of any notifications that happen between the time
|
// 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);
|
return nsIntRect(nsIntPoint(0,0), mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************
|
|
||||||
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
|
|
||||||
NS_IMETHODIMP_(bool)
|
NS_IMETHODIMP_(bool)
|
||||||
RasterImage::FrameIsOpaque(uint32_t aWhichFrame)
|
RasterImage::IsOpaque()
|
||||||
{
|
{
|
||||||
if (aWhichFrame > FRAME_MAX_VALUE) {
|
if (mError) {
|
||||||
NS_WARNING("aWhichFrame outside valid range!");
|
|
||||||
return false;
|
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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// See if we can get an image frame.
|
// Other, we're opaque if FLAG_HAS_TRANSPARENCY is not set.
|
||||||
nsRefPtr<imgFrame> frame =
|
return !(progress & FLAG_HAS_TRANSPARENCY);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIntRect
|
nsIntRect
|
||||||
|
@ -767,7 +756,7 @@ RasterImage::CopyFrame(uint32_t aWhichFrame,
|
||||||
if (mError)
|
if (mError)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!ApplyDecodeFlags(aFlags, aWhichFrame))
|
if (!ApplyDecodeFlags(aFlags))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Get the frame. If it's not there, it's probably the caller's fault for
|
// 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)
|
if (mError)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!ApplyDecodeFlags(aFlags, aWhichFrame))
|
if (!ApplyDecodeFlags(aFlags))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Get the frame. If it's not there, it's probably the caller's fault for
|
// 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
|
bool
|
||||||
RasterImage::ApplyDecodeFlags(uint32_t aNewFlags, uint32_t aWhichFrame)
|
RasterImage::ApplyDecodeFlags(uint32_t aNewFlags)
|
||||||
{
|
{
|
||||||
if (mFrameDecodeFlags == (aNewFlags & DECODE_FLAGS_MASK))
|
if (mFrameDecodeFlags == (aNewFlags & DECODE_FLAGS_MASK))
|
||||||
return true; // Not asking very much of us here.
|
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;
|
(mFrameDecodeFlags & DECODE_FLAGS_MASK) & ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
|
||||||
uint32_t newNonAlphaFlags =
|
uint32_t newNonAlphaFlags =
|
||||||
(aNewFlags & DECODE_FLAGS_MASK) & ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
|
(aNewFlags & DECODE_FLAGS_MASK) & ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
|
||||||
if (currentNonAlphaFlags == newNonAlphaFlags && FrameIsOpaque(aWhichFrame)) {
|
if (currentNonAlphaFlags == newNonAlphaFlags && IsOpaque()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2537,8 +2526,7 @@ RasterImage::Draw(gfxContext* aContext,
|
||||||
// is opaque.
|
// is opaque.
|
||||||
bool haveDefaultFlags = (mFrameDecodeFlags == DECODE_FLAGS_DEFAULT);
|
bool haveDefaultFlags = (mFrameDecodeFlags == DECODE_FLAGS_DEFAULT);
|
||||||
bool haveSafeAlphaFlags =
|
bool haveSafeAlphaFlags =
|
||||||
(mFrameDecodeFlags == FLAG_DECODE_NO_PREMULTIPLY_ALPHA) &&
|
(mFrameDecodeFlags == FLAG_DECODE_NO_PREMULTIPLY_ALPHA) && IsOpaque();
|
||||||
FrameIsOpaque(FRAME_CURRENT);
|
|
||||||
|
|
||||||
if (!(haveDefaultFlags || haveSafeAlphaFlags)) {
|
if (!(haveDefaultFlags || haveSafeAlphaFlags)) {
|
||||||
if (!CanForciblyDiscardAndRedecode())
|
if (!CanForciblyDiscardAndRedecode())
|
||||||
|
|
|
@ -338,7 +338,7 @@ private:
|
||||||
|
|
||||||
nsresult DoImageDataComplete();
|
nsresult DoImageDataComplete();
|
||||||
|
|
||||||
bool ApplyDecodeFlags(uint32_t aNewFlags, uint32_t aWhichFrame);
|
bool ApplyDecodeFlags(uint32_t aNewFlags);
|
||||||
|
|
||||||
already_AddRefed<layers::Image> GetCurrentImage();
|
already_AddRefed<layers::Image> GetCurrentImage();
|
||||||
void UpdateImageContainer();
|
void UpdateImageContainer();
|
||||||
|
|
|
@ -687,15 +687,9 @@ VectorImage::GetFirstFrameDelay()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//******************************************************************************
|
|
||||||
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
|
|
||||||
NS_IMETHODIMP_(bool)
|
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.
|
return false; // In general, SVG content is not opaque.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,12 +584,6 @@ SurfaceFormat imgFrame::GetFormat() const
|
||||||
return mFormat;
|
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
|
uint32_t imgFrame::GetImageBytesPerRow() const
|
||||||
{
|
{
|
||||||
if (mVBuf)
|
if (mVBuf)
|
||||||
|
|
|
@ -88,7 +88,6 @@ public:
|
||||||
bool NeedsPadding() const { return mOffset != nsIntPoint(0, 0); }
|
bool NeedsPadding() const { return mOffset != nsIntPoint(0, 0); }
|
||||||
int32_t GetStride() const;
|
int32_t GetStride() const;
|
||||||
SurfaceFormat GetFormat() const;
|
SurfaceFormat GetFormat() const;
|
||||||
bool GetNeedsBackground() const;
|
|
||||||
uint32_t GetImageBytesPerRow() const;
|
uint32_t GetImageBytesPerRow() const;
|
||||||
uint32_t GetImageDataLength() const;
|
uint32_t GetImageDataLength() const;
|
||||||
bool GetIsPaletted() const;
|
bool GetIsPaletted() const;
|
||||||
|
|
|
@ -1453,9 +1453,7 @@ nsDisplayImage::GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
||||||
bool* aSnap)
|
bool* aSnap)
|
||||||
{
|
{
|
||||||
*aSnap = true;
|
*aSnap = true;
|
||||||
bool animated;
|
if (mImage && mImage->IsOpaque()) {
|
||||||
if (mImage && mImage->GetAnimated(&animated) == NS_OK && !animated &&
|
|
||||||
mImage->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) {
|
|
||||||
// OK, the entire region painted by the image is opaque. But what is that
|
// 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
|
// 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
|
// 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));
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
||||||
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
|
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
|
||||||
|
|
||||||
// Check if the crop region of the current image frame is opaque.
|
// Check if the crop region of the image is opaque.
|
||||||
if (imageContainer->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) {
|
if (imageContainer->IsOpaque()) {
|
||||||
if (!mCropRect)
|
if (!mCropRect)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче