Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1256603. Make aMarkUsed parameters required everywhere. r=aosmond
Browse files Browse the repository at this point in the history
  • Loading branch information
tnikkel committed Oct 13, 2018
1 parent 99ce706 commit ba2367e
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 22 deletions.
6 changes: 3 additions & 3 deletions image/RasterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ LookupResult
RasterImage::LookupFrame(const IntSize& aSize,
uint32_t aFlags,
PlaybackType aPlaybackType,
bool aMarkUsed /* = true */)
bool aMarkUsed)
{
MOZ_ASSERT(NS_IsMainThread());

Expand Down Expand Up @@ -609,7 +609,7 @@ RasterImage::GetFrameInternal(const IntSize& aSize,
// not waiting for the data to be loaded from the network or not passing
// FLAG_SYNC_DECODE.
LookupResult result =
LookupFrame(aSize, aFlags, ToPlaybackType(aWhichFrame));
LookupFrame(aSize, aFlags, ToPlaybackType(aWhichFrame), /* aMarkUsed = */ true);

// The surface cache may have suggested we use a different size than the
// given size in the future. This may or may not be accompanied by an
Expand Down Expand Up @@ -1523,7 +1523,7 @@ RasterImage::Draw(gfxContext* aContext,
: aFlags & ~FLAG_HIGH_QUALITY_SCALING;

LookupResult result =
LookupFrame(aSize, flags, ToPlaybackType(aWhichFrame));
LookupFrame(aSize, flags, ToPlaybackType(aWhichFrame), /* aMarkUsed = */ true);
if (!result) {
// Getting the frame (above) touches the image and kicks off decoding.
if (mDrawStartTime.IsNull()) {
Expand Down
2 changes: 1 addition & 1 deletion image/RasterImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class RasterImage final : public ImageResource
LookupResult LookupFrame(const gfx::IntSize& aSize,
uint32_t aFlags,
PlaybackType aPlaybackType,
bool aMarkUsed = true);
bool aMarkUsed);

/// Helper method for LookupFrame().
LookupResult LookupFrameInternal(const gfx::IntSize& aSize,
Expand Down
8 changes: 4 additions & 4 deletions image/SurfaceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ class SurfaceCacheImpl final : public nsIMemoryReporter
LookupResult Lookup(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
const StaticMutexAutoLock& aAutoLock,
bool aMarkUsed = true)
bool aMarkUsed)
{
RefPtr<ImageSurfaceCache> cache = GetImageCache(aImageKey);
if (!cache) {
Expand Down Expand Up @@ -1000,7 +1000,7 @@ class SurfaceCacheImpl final : public nsIMemoryReporter
LookupResult LookupBestMatch(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
const StaticMutexAutoLock& aAutoLock,
bool aMarkUsed /* = true */)
bool aMarkUsed)
{
RefPtr<ImageSurfaceCache> cache = GetImageCache(aImageKey);
if (!cache) {
Expand Down Expand Up @@ -1519,7 +1519,7 @@ SurfaceCache::Shutdown()
/* static */ LookupResult
SurfaceCache::Lookup(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
bool aMarkUsed /* = true */)
bool aMarkUsed)
{
nsTArray<RefPtr<CachedSurface>> discard;
LookupResult rv(MatchType::NOT_FOUND);
Expand All @@ -1540,7 +1540,7 @@ SurfaceCache::Lookup(const ImageKey aImageKey,
/* static */ LookupResult
SurfaceCache::LookupBestMatch(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
bool aMarkUsed /* = true */)
bool aMarkUsed)
{
nsTArray<RefPtr<CachedSurface>> discard;
LookupResult rv(MatchType::NOT_FOUND);
Expand Down
4 changes: 2 additions & 2 deletions image/SurfaceCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct SurfaceCache
*/
static LookupResult Lookup(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
bool aMarkUsed = true);
bool aMarkUsed);

/**
* Looks up the best matching cache entry and returns a drawable reference to
Expand All @@ -253,7 +253,7 @@ struct SurfaceCache
*/
static LookupResult LookupBestMatch(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
bool aMarkUsed = true);
bool aMarkUsed);

/**
* Insert an ISurfaceProvider into the cache. If an entry with the same
Expand Down
4 changes: 2 additions & 2 deletions image/VectorImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,9 @@ VectorImage::LookupCachedSurface(const IntSize& aSize,
LookupResult result(MatchType::NOT_FOUND);
SurfaceKey surfaceKey = VectorSurfaceKey(aSize, aSVGContext);
if ((aFlags & FLAG_SYNC_DECODE) || !(aFlags & FLAG_HIGH_QUALITY_SCALING)) {
result = SurfaceCache::Lookup(ImageKey(this), surfaceKey);
result = SurfaceCache::Lookup(ImageKey(this), surfaceKey, /* aMarkUsed = */ true);
} else {
result = SurfaceCache::LookupBestMatch(ImageKey(this), surfaceKey);
result = SurfaceCache::LookupBestMatch(ImageKey(this), surfaceKey, /* aMarkUsed = */ true);
}

IntSize rasterSize = result.SuggestedSize().IsEmpty()
Expand Down
27 changes: 18 additions & 9 deletions image/test/gtest/TestDecoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_FIRST)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eStatic));
PlaybackType::eStatic),
/* aMarkUsed = */ false);
ASSERT_EQ(MatchType::EXACT, result.Type());
EXPECT_TRUE(bool(result.Surface()));
}
Expand All @@ -584,7 +585,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_FIRST)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ false);
ASSERT_EQ(MatchType::NOT_FOUND, result.Type());
}

Expand All @@ -600,7 +602,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_FIRST)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());

EXPECT_TRUE(NS_SUCCEEDED(result.Surface().Seek(0)));
Expand All @@ -616,7 +619,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_FIRST)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eStatic));
PlaybackType::eStatic),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());
EXPECT_TRUE(bool(result.Surface()));
}
Expand Down Expand Up @@ -686,7 +690,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_CURRENT)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());

EXPECT_TRUE(NS_SUCCEEDED(result.Surface().Seek(0)));
Expand All @@ -702,7 +707,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_CURRENT)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eStatic));
PlaybackType::eStatic),
/* aMarkUsed = */ false);
ASSERT_EQ(MatchType::NOT_FOUND, result.Type());
}

Expand All @@ -718,7 +724,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_CURRENT)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eStatic));
PlaybackType::eStatic),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());
EXPECT_TRUE(bool(result.Surface()));
}
Expand All @@ -729,7 +736,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRAME_CURRENT)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());

EXPECT_TRUE(NS_SUCCEEDED(result.Surface().Seek(0)));
Expand Down Expand Up @@ -798,7 +806,8 @@ TEST_F(ImageDecoders, AnimatedGIFWithExtraImageSubBlocks)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());

EXPECT_TRUE(NS_SUCCEEDED(result.Surface().Seek(0)));
Expand Down
3 changes: 2 additions & 1 deletion image/test/gtest/TestMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ TEST_F(ImageDecoderMetadata, NoFrameDelayGIFFullDecode)
SurfaceCache::Lookup(ImageKey(image.get()),
RasterSurfaceKey(imageSize,
DefaultSurfaceFlags(),
PlaybackType::eAnimated));
PlaybackType::eAnimated),
/* aMarkUsed = */ true);
ASSERT_EQ(MatchType::EXACT, result.Type());

EXPECT_TRUE(NS_SUCCEEDED(result.Surface().Seek(0)));
Expand Down

0 comments on commit ba2367e

Please sign in to comment.