Bug 944442 - DeCOMify imgIContainer::GetFrame. r=seth

--HG--
extra : rebase_source : 612c1923f3ed8a01fc30f2d306b4682e585e53fe
This commit is contained in:
Jonathan Watt 2013-12-13 08:34:24 +00:00
parent de607d515b
commit 6c8fbf340c
23 changed files with 100 additions and 135 deletions

View File

@ -752,10 +752,9 @@ WriteBitmap(nsIFile* aFile, imgIContainer* aImage)
{ {
nsresult rv; nsresult rv;
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aImage->GetFrame(imgIContainer::FRAME_FIRST, aImage->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
nsRefPtr<gfxImageSurface> image(surface->GetAsReadableARGB32ImageSurface()); nsRefPtr<gfxImageSurface> image(surface->GetAsReadableARGB32ImageSurface());

View File

@ -211,9 +211,9 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
nsRefPtr<gfxASurface> currentFrame; nsRefPtr<gfxASurface> currentFrame;
if (imageContainer) { if (imageContainer) {
imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, currentFrame =
imgIContainer::FLAG_SYNC_DECODE, imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
getter_AddRefs(currentFrame)); imgIContainer::FLAG_SYNC_DECODE);
} }
if (!currentFrame) { if (!currentFrame) {

View File

@ -55,6 +55,7 @@ native nsSize(nsSize);
native Orientation(mozilla::image::Orientation); native Orientation(mozilla::image::Orientation);
[ref] native TimeStamp(mozilla::TimeStamp); [ref] native TimeStamp(mozilla::TimeStamp);
[ptr] native SVGImageContext(mozilla::SVGImageContext); [ptr] native SVGImageContext(mozilla::SVGImageContext);
native already_AddRefed_gfxASurface(already_AddRefed<gfxASurface>);
/** /**
@ -64,7 +65,7 @@ native Orientation(mozilla::image::Orientation);
* *
* Internally, imgIContainer also manages animation of images. * Internally, imgIContainer also manages animation of images.
*/ */
[scriptable, builtinclass, uuid(73340b79-e3ae-4f02-97d0-822db78017e5)] [scriptable, builtinclass, uuid(8b7db7dd-bfe9-40d3-9114-3a79c0658afd)]
interface imgIContainer : nsISupports interface imgIContainer : nsISupports
{ {
/** /**
@ -172,7 +173,8 @@ interface imgIContainer : nsISupports
* @param aWhichFrame Frame specifier of the FRAME_* variety. * @param aWhichFrame Frame specifier of the FRAME_* variety.
* @param aFlags Flags of the FLAG_* variety * @param aFlags Flags of the FLAG_* variety
*/ */
[noscript] gfxASurface getFrame(in uint32_t aWhichFrame, [noscript, notxpcom] already_AddRefed_gfxASurface
getFrame(in uint32_t aWhichFrame,
in uint32_t aFlags); in uint32_t aFlags);
/** /**

View File

@ -209,23 +209,21 @@ ClippedImage::GetIntrinsicRatio(nsSize* aRatio)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
ClippedImage::GetFrame(uint32_t aWhichFrame, ClippedImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags, _retval); return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags);
} }
nsresult already_AddRefed<gfxASurface>
ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize, ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext, const SVGImageContext* aSVGContext,
uint32_t aWhichFrame, uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
if (!ShouldClip()) { if (!ShouldClip()) {
return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval); return InnerImage()->GetFrame(aWhichFrame, aFlags);
} }
float frameToDraw = InnerImage()->GetFrameIndex(aWhichFrame); float frameToDraw = InnerImage()->GetFrameIndex(aWhichFrame);
@ -273,9 +271,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
} }
MOZ_ASSERT(mCachedSurface, "Should have a cached surface now"); MOZ_ASSERT(mCachedSurface, "Should have a cached surface now");
nsRefPtr<gfxASurface> surf = mCachedSurface->Surface(); return mCachedSurface->Surface();
surf.forget(_retval);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -335,8 +331,8 @@ ClippedImage::Draw(gfxContext* aContext,
if (MustCreateSurface(aContext, aUserSpaceToImageSpace, sourceRect, aSubimage, aFlags)) { if (MustCreateSurface(aContext, aUserSpaceToImageSpace, sourceRect, aSubimage, aFlags)) {
// Create a temporary surface containing a single tile of this image. // Create a temporary surface containing a single tile of this image.
// GetFrame will call DrawSingleTile internally. // GetFrame will call DrawSingleTile internally.
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags, getter_AddRefs(surface)); GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags);
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
// Create a drawable from that surface. // Create a drawable from that surface.

View File

@ -35,9 +35,8 @@ public:
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
NS_IMETHOD GetFrame(uint32_t aWhichFrame, NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags) MOZ_OVERRIDE;
gfxASurface** _retval) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
NS_IMETHOD Draw(gfxContext* aContext, NS_IMETHOD Draw(gfxContext* aContext,
@ -56,11 +55,10 @@ protected:
ClippedImage(Image* aImage, nsIntRect aClip); ClippedImage(Image* aImage, nsIntRect aClip);
private: private:
nsresult GetFrameInternal(const nsIntSize& aViewportSize, already_AddRefed<gfxASurface> GetFrameInternal(const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext, const SVGImageContext* aSVGContext,
uint32_t aWhichFrame, uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags);
gfxASurface** _retval);
bool ShouldClip(); bool ShouldClip();
bool MustCreateSurface(gfxContext* aContext, bool MustCreateSurface(gfxContext* aContext,
const gfxMatrix& aTransform, const gfxMatrix& aTransform,

View File

@ -40,12 +40,11 @@ FrozenImage::GetAnimated(bool* aAnimated)
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
FrozenImage::GetFrame(uint32_t aWhichFrame, FrozenImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
return InnerImage()->GetFrame(FRAME_FIRST, aFlags, _retval); return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
} }
NS_IMETHODIMP_(bool) NS_IMETHODIMP_(bool)

View File

@ -34,9 +34,8 @@ public:
virtual void DecrementAnimationConsumers() MOZ_OVERRIDE; virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE; NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
NS_IMETHOD GetFrame(uint32_t aWhichFrame, NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags) MOZ_OVERRIDE;
gfxASurface** _retval) MOZ_OVERRIDE;
NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) 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;

View File

@ -196,12 +196,11 @@ ImageWrapper::GetAnimated(bool* aAnimated)
return mInnerImage->GetAnimated(aAnimated); return mInnerImage->GetAnimated(aAnimated);
} }
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
ImageWrapper::GetFrame(uint32_t aWhichFrame, ImageWrapper::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
return mInnerImage->GetFrame(aWhichFrame, aFlags, _retval); return mInnerImage->GetFrame(aWhichFrame, aFlags);
} }
NS_IMETHODIMP_(bool) NS_IMETHODIMP_(bool)

View File

@ -75,15 +75,14 @@ OrientedImage::GetIntrinsicRatio(nsSize* aRatio)
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
OrientedImage::GetFrame(uint32_t aWhichFrame, OrientedImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
nsresult rv; nsresult rv;
if (mOrientation.IsIdentity()) { if (mOrientation.IsIdentity()) {
return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval); return InnerImage()->GetFrame(aWhichFrame, aFlags);
} }
// Get the underlying dimensions. // Get the underlying dimensions.
@ -95,7 +94,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
rv = InnerImage()->GetWidth(&width); rv = InnerImage()->GetWidth(&width);
rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height); rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height);
} }
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, nullptr);
// Determine an appropriate format for the surface. // Determine an appropriate format for the surface.
gfx::SurfaceFormat surfaceFormat; gfx::SurfaceFormat surfaceFormat;
@ -116,9 +115,9 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
GetThebesSurfaceForDrawTarget(target); GetThebesSurfaceForDrawTarget(target);
// Create our drawable. // Create our drawable.
nsRefPtr<gfxASurface> innerSurface; nsRefPtr<gfxASurface> innerSurface =
rv = InnerImage()->GetFrame(aWhichFrame, aFlags, getter_AddRefs(innerSurface)); InnerImage()->GetFrame(aWhichFrame, aFlags);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(innerSurface, nullptr);
nsRefPtr<gfxDrawable> drawable = nsRefPtr<gfxDrawable> drawable =
new gfxSurfaceDrawable(innerSurface, gfxIntSize(width, height)); new gfxSurfaceDrawable(innerSurface, gfxIntSize(width, height));
@ -129,8 +128,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
imageRect, imageRect, imageRect, imageRect, imageRect, imageRect, imageRect, imageRect,
imageFormat, GraphicsFilter::FILTER_FAST); imageFormat, GraphicsFilter::FILTER_FAST);
surface.forget(_retval); return surface.forget();
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

View File

@ -32,9 +32,8 @@ public:
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
NS_IMETHOD GetFrame(uint32_t aWhichFrame, NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags) MOZ_OVERRIDE;
gfxASurface** _retval) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
NS_IMETHOD Draw(gfxContext* aContext, NS_IMETHOD Draw(gfxContext* aContext,

View File

@ -879,30 +879,29 @@ RasterImage::CopyFrame(uint32_t aWhichFrame,
//****************************************************************************** //******************************************************************************
/* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, /* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags); */ * in uint32_t aFlags); */
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
RasterImage::GetFrame(uint32_t aWhichFrame, RasterImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface **_retval)
{ {
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
if (aWhichFrame > FRAME_MAX_VALUE) if (aWhichFrame > FRAME_MAX_VALUE)
return NS_ERROR_INVALID_ARG; return nullptr;
if (mError) if (mError)
return NS_ERROR_FAILURE; return nullptr;
// Disallowed in the API // Disallowed in the API
if (mInDecoder && (aFlags & imgIContainer::FLAG_SYNC_DECODE)) if (mInDecoder && (aFlags & imgIContainer::FLAG_SYNC_DECODE))
return NS_ERROR_FAILURE; return nullptr;
nsresult rv = NS_OK;
if (!ApplyDecodeFlags(aFlags)) if (!ApplyDecodeFlags(aFlags))
return NS_ERROR_NOT_AVAILABLE; return nullptr;
// If the caller requested a synchronous decode, do it // If the caller requested a synchronous decode, do it
if (aFlags & FLAG_SYNC_DECODE) { if (aFlags & FLAG_SYNC_DECODE) {
rv = SyncDecode(); nsresult rv = SyncDecode();
CONTAINER_ENSURE_SUCCESS(rv); CONTAINER_ENSURE_TRUE(NS_SUCCEEDED(rv), 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
@ -912,8 +911,7 @@ RasterImage::GetFrame(uint32_t aWhichFrame,
0 : GetCurrentImgFrameIndex(); 0 : GetCurrentImgFrameIndex();
imgFrame *frame = GetDrawableImgFrame(frameIndex); imgFrame *frame = GetDrawableImgFrame(frameIndex);
if (!frame) { if (!frame) {
*_retval = nullptr; return nullptr;
return NS_ERROR_FAILURE;
} }
nsRefPtr<gfxASurface> framesurf; nsRefPtr<gfxASurface> framesurf;
@ -924,19 +922,17 @@ RasterImage::GetFrame(uint32_t aWhichFrame,
if (framerect.x == 0 && framerect.y == 0 && if (framerect.x == 0 && framerect.y == 0 &&
framerect.width == mSize.width && framerect.width == mSize.width &&
framerect.height == mSize.height) framerect.height == mSize.height)
rv = frame->GetSurface(getter_AddRefs(framesurf)); frame->GetSurface(getter_AddRefs(framesurf));
// The image doesn't have a surface because it's been optimized away. Create // The image doesn't have a surface because it's been optimized away. Create
// one. // one.
if (!framesurf) { if (!framesurf) {
nsRefPtr<gfxImageSurface> imgsurf; nsRefPtr<gfxImageSurface> imgsurf;
rv = CopyFrame(aWhichFrame, aFlags, getter_AddRefs(imgsurf)); CopyFrame(aWhichFrame, aFlags, getter_AddRefs(imgsurf));
framesurf = imgsurf; framesurf = imgsurf;
} }
*_retval = framesurf.forget().get(); return framesurf.forget();
return rv;
} }
already_AddRefed<layers::Image> already_AddRefed<layers::Image>
@ -949,13 +945,8 @@ RasterImage::GetCurrentImage()
return nullptr; return nullptr;
} }
nsRefPtr<gfxASurface> imageSurface; nsRefPtr<gfxASurface> imageSurface = GetFrame(FRAME_CURRENT, FLAG_NONE);
nsresult rv = GetFrame(FRAME_CURRENT, FLAG_NONE, getter_AddRefs(imageSurface)); NS_ENSURE_TRUE(imageSurface, nullptr);
NS_ENSURE_SUCCESS(rv, nullptr);
if (!imageSurface) {
return nullptr;
}
if (!mImageContainer) { if (!mImageContainer) {
mImageContainer = LayerManager::CreateImageContainer(); mImageContainer = LayerManager::CreateImageContainer();

View File

@ -647,18 +647,17 @@ VectorImage::FrameIsOpaque(uint32_t aWhichFrame)
//****************************************************************************** //******************************************************************************
/* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, /* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags; */ * in uint32_t aFlags; */
NS_IMETHODIMP NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
VectorImage::GetFrame(uint32_t aWhichFrame, VectorImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags, uint32_t aFlags)
gfxASurface** _retval)
{ {
NS_ENSURE_ARG_POINTER(_retval); MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE);
if (aWhichFrame > FRAME_MAX_VALUE) if (aWhichFrame > FRAME_MAX_VALUE)
return NS_ERROR_INVALID_ARG; return nullptr;
if (mError) if (mError)
return NS_ERROR_FAILURE; return nullptr;
// Look up height & width // Look up height & width
// ---------------------- // ----------------------
@ -668,7 +667,7 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
!mSVGDocumentWrapper->GetWidthOrHeight(SVGDocumentWrapper::eHeight, !mSVGDocumentWrapper->GetWidthOrHeight(SVGDocumentWrapper::eHeight,
imageIntSize.height)) { imageIntSize.height)) {
// We'll get here if our SVG doc has a percent-valued width or height. // We'll get here if our SVG doc has a percent-valued width or height.
return NS_ERROR_FAILURE; return nullptr;
} }
// Create a surface that we'll ultimately return // Create a surface that we'll ultimately return
@ -689,9 +688,8 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
nsIntRect(nsIntPoint(0,0), imageIntSize), nsIntRect(nsIntPoint(0,0), imageIntSize),
imageIntSize, nullptr, aWhichFrame, aFlags); imageIntSize, nullptr, aWhichFrame, aFlags);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, nullptr);
*_retval = surface.forget().get(); return surface.forget();
return rv;
} }
//****************************************************************************** //******************************************************************************

View File

@ -276,10 +276,9 @@ NS_IMETHODIMP imgTools::EncodeImageData(gfxImageSurface *aSurface,
NS_IMETHODIMP imgTools::GetFirstImageFrame(imgIContainer *aContainer, NS_IMETHODIMP imgTools::GetFirstImageFrame(imgIContainer *aContainer,
gfxImageSurface **aSurface) gfxImageSurface **aSurface)
{ {
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aContainer->GetFrame(imgIContainer::FRAME_FIRST, aContainer->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE);
nsRefPtr<gfxImageSurface> frame(surface->CopyToARGB32ImageSurface()); nsRefPtr<gfxImageSurface> frame(surface->CopyToARGB32ImageSurface());

View File

@ -4816,11 +4816,9 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
frameFlags |= imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION; frameFlags |= imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION;
if (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA) if (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA)
frameFlags |= imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA; frameFlags |= imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
nsRefPtr<gfxASurface> framesurf; nsRefPtr<gfxASurface> framesurf =
rv = imgContainer->GetFrame(whichFrame, imgContainer->GetFrame(whichFrame, frameFlags);
frameFlags, if (!framesurf)
getter_AddRefs(framesurf));
if (NS_FAILED(rv))
return result; return result;
int32_t imgWidth, imgHeight; int32_t imgWidth, imgHeight;

View File

@ -431,10 +431,9 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
continue; continue;
} }
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
image->GetFrame(imgIContainer::FRAME_CURRENT, image->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
if (!surface) { if (!surface) {
continue; continue;
} }

View File

@ -372,10 +372,8 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui
} }
else { else {
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aImage->GetFrame(aWhichFrame, aImage->GetFrame(aWhichFrame, imgIContainer::FLAG_SYNC_DECODE);
imgIContainer::FLAG_SYNC_DECODE,
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
frame = surface->GetAsReadableARGB32ImageSurface(); frame = surface->GetAsReadableARGB32ImageSurface();

View File

@ -384,10 +384,9 @@ nsMenuItemIconX::OnStopFrame(imgIRequest* aRequest)
mImageRegionRect.SetRect(0, 0, origWidth, origHeight); mImageRegionRect.SetRect(0, 0, origWidth, origHeight);
} }
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_NONE, imgIContainer::FLAG_NONE);
getter_AddRefs(surface));
if (!surface) { if (!surface) {
[mNativeMenuItem setImage:nil]; [mNativeMenuItem setImage:nil];
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -36,19 +36,17 @@ nsImageToPixbuf::ConvertImageToPixbuf(imgIContainer* aImage)
GdkPixbuf* GdkPixbuf*
nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage) nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage)
{ {
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aImage->GetFrame(imgIContainer::FRAME_CURRENT, aImage->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
// If the last call failed, it was probably because our call stack originates // If the last call failed, it was probably because our call stack originates
// in an imgINotificationObserver event, meaning that we're not allowed request // in an imgINotificationObserver event, meaning that we're not allowed request
// a sync decode. Presumably the originating event is something sensible like // a sync decode. Presumably the originating event is something sensible like
// OnStopFrame(), so we can just retry the call without a sync decode. // OnStopFrame(), so we can just retry the call without a sync decode.
if (!surface) if (!surface)
aImage->GetFrame(imgIContainer::FRAME_CURRENT, surface = aImage->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_NONE, imgIContainer::FLAG_NONE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, nullptr); NS_ENSURE_TRUE(surface, nullptr);

View File

@ -1334,10 +1334,9 @@ NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
return NS_OK; return NS_OK;
} }
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aCursor->GetFrame(imgIContainer::FRAME_CURRENT, aCursor->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE);
nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface()); nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface());

View File

@ -176,10 +176,9 @@ nsClipboard::SetNativeClipboardData( nsITransferable *aTransferable,
if (!image) // Not getting an image for an image mime type!? if (!image) // Not getting an image for an image mime type!?
continue; continue;
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
image->GetFrame(imgIContainer::FRAME_CURRENT, image->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
if (!surface) if (!surface)
continue; continue;

View File

@ -694,8 +694,8 @@ AsyncFaviconDataReady::OnComplete(nsIURI *aFaviconURI,
getter_AddRefs(container)); getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<gfxASurface> imgFrame; nsRefPtr<gfxASurface> imgFrame =
rv = container->GetFrame(imgIContainer::FRAME_FIRST, 0, getter_AddRefs(imgFrame)); container->GetFrame(imgIContainer::FRAME_FIRST, 0);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<gfxImageSurface> imageSurface; nsRefPtr<gfxImageSurface> imageSurface;

View File

@ -116,10 +116,9 @@ nsImageToClipboard::CreateFromImage ( imgIContainer* inImage, HANDLE* outBitmap
nsresult rv; nsresult rv;
*outBitmap = nullptr; *outBitmap = nullptr;
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
inImage->GetFrame(imgIContainer::FRAME_CURRENT, inImage->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface()); nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface());

View File

@ -647,10 +647,9 @@ nsresult nsWindowGfx::CreateIcon(imgIContainer *aContainer,
HICON *aIcon) { HICON *aIcon) {
// Get the image data // Get the image data
nsRefPtr<gfxASurface> surface; nsRefPtr<gfxASurface> surface =
aContainer->GetFrame(imgIContainer::FRAME_CURRENT, aContainer->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE, imgIContainer::FLAG_SYNC_DECODE);
getter_AddRefs(surface));
NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE);
nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface()); nsRefPtr<gfxImageSurface> frame(surface->GetAsReadableARGB32ImageSurface());