Skip to content

Commit 7da8970

Browse files
committed
Bug 944442 - DeCOMify imgIContainer::GetFrame. r=seth
--HG-- extra : rebase_source : 612c1923f3ed8a01fc30f2d306b4682e585e53fe
1 parent 3ec0b0a commit 7da8970

23 files changed

+100
-135
lines changed

browser/components/shell/src/nsWindowsShellService.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,9 @@ WriteBitmap(nsIFile* aFile, imgIContainer* aImage)
752752
{
753753
nsresult rv;
754754

755-
nsRefPtr<gfxASurface> surface;
756-
aImage->GetFrame(imgIContainer::FRAME_FIRST,
757-
imgIContainer::FLAG_SYNC_DECODE,
758-
getter_AddRefs(surface));
755+
nsRefPtr<gfxASurface> surface =
756+
aImage->GetFrame(imgIContainer::FRAME_FIRST,
757+
imgIContainer::FLAG_SYNC_DECODE);
759758
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
760759

761760
nsRefPtr<gfxImageSurface> image(surface->GetAsReadableARGB32ImageSurface());

content/svg/content/src/SVGFEImageElement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
211211

212212
nsRefPtr<gfxASurface> currentFrame;
213213
if (imageContainer) {
214-
imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
215-
imgIContainer::FLAG_SYNC_DECODE,
216-
getter_AddRefs(currentFrame));
214+
currentFrame =
215+
imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
216+
imgIContainer::FLAG_SYNC_DECODE);
217217
}
218218

219219
if (!currentFrame) {

image/public/imgIContainer.idl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ native nsSize(nsSize);
5555
native Orientation(mozilla::image::Orientation);
5656
[ref] native TimeStamp(mozilla::TimeStamp);
5757
[ptr] native SVGImageContext(mozilla::SVGImageContext);
58+
native already_AddRefed_gfxASurface(already_AddRefed<gfxASurface>);
5859

5960

6061
/**
@@ -64,7 +65,7 @@ native Orientation(mozilla::image::Orientation);
6465
*
6566
* Internally, imgIContainer also manages animation of images.
6667
*/
67-
[scriptable, builtinclass, uuid(73340b79-e3ae-4f02-97d0-822db78017e5)]
68+
[scriptable, builtinclass, uuid(8b7db7dd-bfe9-40d3-9114-3a79c0658afd)]
6869
interface imgIContainer : nsISupports
6970
{
7071
/**
@@ -172,7 +173,8 @@ interface imgIContainer : nsISupports
172173
* @param aWhichFrame Frame specifier of the FRAME_* variety.
173174
* @param aFlags Flags of the FLAG_* variety
174175
*/
175-
[noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
176+
[noscript, notxpcom] already_AddRefed_gfxASurface
177+
getFrame(in uint32_t aWhichFrame,
176178
in uint32_t aFlags);
177179

178180
/**

image/src/ClippedImage.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,21 @@ ClippedImage::GetIntrinsicRatio(nsSize* aRatio)
209209
return NS_OK;
210210
}
211211

212-
NS_IMETHODIMP
212+
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
213213
ClippedImage::GetFrame(uint32_t aWhichFrame,
214-
uint32_t aFlags,
215-
gfxASurface** _retval)
214+
uint32_t aFlags)
216215
{
217-
return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags, _retval);
216+
return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags);
218217
}
219218

220-
nsresult
219+
already_AddRefed<gfxASurface>
221220
ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
222221
const SVGImageContext* aSVGContext,
223222
uint32_t aWhichFrame,
224-
uint32_t aFlags,
225-
gfxASurface** _retval)
223+
uint32_t aFlags)
226224
{
227225
if (!ShouldClip()) {
228-
return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval);
226+
return InnerImage()->GetFrame(aWhichFrame, aFlags);
229227
}
230228

231229
float frameToDraw = InnerImage()->GetFrameIndex(aWhichFrame);
@@ -273,9 +271,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
273271
}
274272

275273
MOZ_ASSERT(mCachedSurface, "Should have a cached surface now");
276-
nsRefPtr<gfxASurface> surf = mCachedSurface->Surface();
277-
surf.forget(_retval);
278-
return NS_OK;
274+
return mCachedSurface->Surface();
279275
}
280276

281277
NS_IMETHODIMP
@@ -335,8 +331,8 @@ ClippedImage::Draw(gfxContext* aContext,
335331
if (MustCreateSurface(aContext, aUserSpaceToImageSpace, sourceRect, aSubimage, aFlags)) {
336332
// Create a temporary surface containing a single tile of this image.
337333
// GetFrame will call DrawSingleTile internally.
338-
nsRefPtr<gfxASurface> surface;
339-
GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags, getter_AddRefs(surface));
334+
nsRefPtr<gfxASurface> surface =
335+
GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags);
340336
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
341337

342338
// Create a drawable from that surface.

image/src/ClippedImage.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ class ClippedImage : public ImageWrapper
3535
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
3636
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
3737
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
38-
NS_IMETHOD GetFrame(uint32_t aWhichFrame,
39-
uint32_t aFlags,
40-
gfxASurface** _retval) MOZ_OVERRIDE;
38+
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
39+
uint32_t aFlags) MOZ_OVERRIDE;
4140
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
4241
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
4342
NS_IMETHOD Draw(gfxContext* aContext,
@@ -56,11 +55,10 @@ class ClippedImage : public ImageWrapper
5655
ClippedImage(Image* aImage, nsIntRect aClip);
5756

5857
private:
59-
nsresult GetFrameInternal(const nsIntSize& aViewportSize,
60-
const SVGImageContext* aSVGContext,
61-
uint32_t aWhichFrame,
62-
uint32_t aFlags,
63-
gfxASurface** _retval);
58+
already_AddRefed<gfxASurface> GetFrameInternal(const nsIntSize& aViewportSize,
59+
const SVGImageContext* aSVGContext,
60+
uint32_t aWhichFrame,
61+
uint32_t aFlags);
6462
bool ShouldClip();
6563
bool MustCreateSurface(gfxContext* aContext,
6664
const gfxMatrix& aTransform,

image/src/FrozenImage.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ FrozenImage::GetAnimated(bool* aAnimated)
4040
return rv;
4141
}
4242

43-
NS_IMETHODIMP
43+
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
4444
FrozenImage::GetFrame(uint32_t aWhichFrame,
45-
uint32_t aFlags,
46-
gfxASurface** _retval)
45+
uint32_t aFlags)
4746
{
48-
return InnerImage()->GetFrame(FRAME_FIRST, aFlags, _retval);
47+
return InnerImage()->GetFrame(FRAME_FIRST, aFlags);
4948
}
5049

5150
NS_IMETHODIMP_(bool)

image/src/FrozenImage.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ class FrozenImage : public ImageWrapper
3434
virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
3535

3636
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
37-
NS_IMETHOD GetFrame(uint32_t aWhichFrame,
38-
uint32_t aFlags,
39-
gfxASurface** _retval) MOZ_OVERRIDE;
37+
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
38+
uint32_t aFlags) MOZ_OVERRIDE;
4039
NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
4140
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
4241
layers::ImageContainer** _retval) MOZ_OVERRIDE;

image/src/ImageWrapper.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,11 @@ ImageWrapper::GetAnimated(bool* aAnimated)
196196
return mInnerImage->GetAnimated(aAnimated);
197197
}
198198

199-
NS_IMETHODIMP
199+
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
200200
ImageWrapper::GetFrame(uint32_t aWhichFrame,
201-
uint32_t aFlags,
202-
gfxASurface** _retval)
201+
uint32_t aFlags)
203202
{
204-
return mInnerImage->GetFrame(aWhichFrame, aFlags, _retval);
203+
return mInnerImage->GetFrame(aWhichFrame, aFlags);
205204
}
206205

207206
NS_IMETHODIMP_(bool)

image/src/OrientedImage.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,14 @@ OrientedImage::GetIntrinsicRatio(nsSize* aRatio)
7575
return rv;
7676
}
7777

78-
NS_IMETHODIMP
78+
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
7979
OrientedImage::GetFrame(uint32_t aWhichFrame,
80-
uint32_t aFlags,
81-
gfxASurface** _retval)
80+
uint32_t aFlags)
8281
{
8382
nsresult rv;
8483

8584
if (mOrientation.IsIdentity()) {
86-
return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval);
85+
return InnerImage()->GetFrame(aWhichFrame, aFlags);
8786
}
8887

8988
// Get the underlying dimensions.
@@ -95,7 +94,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
9594
rv = InnerImage()->GetWidth(&width);
9695
rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height);
9796
}
98-
NS_ENSURE_SUCCESS(rv, rv);
97+
NS_ENSURE_SUCCESS(rv, nullptr);
9998

10099
// Determine an appropriate format for the surface.
101100
gfx::SurfaceFormat surfaceFormat;
@@ -116,9 +115,9 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
116115
GetThebesSurfaceForDrawTarget(target);
117116

118117
// Create our drawable.
119-
nsRefPtr<gfxASurface> innerSurface;
120-
rv = InnerImage()->GetFrame(aWhichFrame, aFlags, getter_AddRefs(innerSurface));
121-
NS_ENSURE_SUCCESS(rv, rv);
118+
nsRefPtr<gfxASurface> innerSurface =
119+
InnerImage()->GetFrame(aWhichFrame, aFlags);
120+
NS_ENSURE_TRUE(innerSurface, nullptr);
122121
nsRefPtr<gfxDrawable> drawable =
123122
new gfxSurfaceDrawable(innerSurface, gfxIntSize(width, height));
124123

@@ -129,8 +128,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
129128
imageRect, imageRect, imageRect, imageRect,
130129
imageFormat, GraphicsFilter::FILTER_FAST);
131130

132-
surface.forget(_retval);
133-
return NS_OK;
131+
return surface.forget();
134132
}
135133

136134
NS_IMETHODIMP

image/src/OrientedImage.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class OrientedImage : public ImageWrapper
3232
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
3333
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
3434
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
35-
NS_IMETHOD GetFrame(uint32_t aWhichFrame,
36-
uint32_t aFlags,
37-
gfxASurface** _retval) MOZ_OVERRIDE;
35+
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
36+
uint32_t aFlags) MOZ_OVERRIDE;
3837
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
3938
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
4039
NS_IMETHOD Draw(gfxContext* aContext,

0 commit comments

Comments
 (0)