Bug 1256603. Make aMarkUsed parameters required everywhere. r=aosmond
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 13 Oct 2018 00:31:03 -0500
changeset 441032 479653ce6d8c31dd5cddc815f9ad19a5b06b7fda
parent 441031 8421b16c011ba49a2e495f81853b282413aa7650
child 441033 d8bb90ade0d68eaf309127cb51840c722e4008b5
push id108895
push usertnikkel@gmail.com
push dateSat, 13 Oct 2018 05:31:39 +0000
treeherdermozilla-inbound@2cc5b3f51ec4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1256603
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1256603. Make aMarkUsed parameters required everywhere. r=aosmond
image/RasterImage.cpp
image/RasterImage.h
image/SurfaceCache.cpp
image/SurfaceCache.h
image/VectorImage.cpp
image/test/gtest/TestDecoders.cpp
image/test/gtest/TestMetadata.cpp
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -328,17 +328,17 @@ RasterImage::LookupFrameInternal(const I
                                                         PlaybackType::eStatic),
                                        aMarkUsed);
 }
 
 LookupResult
 RasterImage::LookupFrame(const IntSize& aSize,
                          uint32_t aFlags,
                          PlaybackType aPlaybackType,
-                         bool aMarkUsed /* = true */)
+                         bool aMarkUsed)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // If we're opaque, we don't need to care about premultiplied alpha, because
   // that can only matter for frames with transparency.
   if (IsOpaque()) {
     aFlags &= ~FLAG_DECODE_NO_PREMULTIPLY_ALPHA;
   }
@@ -604,17 +604,17 @@ RasterImage::GetFrameInternal(const IntS
     return MakeTuple(ImgDrawResult::BAD_IMAGE, aSize,
                      RefPtr<SourceSurface>());
   }
 
   // Get the frame. If it's not there, it's probably the caller's fault for
   // 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
   // actual surface, depending on what it has in its cache.
   IntSize suggestedSize = result.SuggestedSize().IsEmpty()
                           ? aSize : result.SuggestedSize();
   MOZ_ASSERT_IF(result.Type() == MatchType::SUBSTITUTE_BECAUSE_BEST,
                 suggestedSize != aSize);
@@ -1518,17 +1518,17 @@ RasterImage::Draw(gfxContext* aContext,
 
   // If we're not using SamplingFilter::GOOD, we shouldn't high-quality scale or
   // downscale during decode.
   uint32_t flags = aSamplingFilter == SamplingFilter::GOOD
                  ? aFlags
                  : 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()) {
       mDrawStartTime = TimeStamp::Now();
     }
     return ImgDrawResult::NOT_READY;
   }
 
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -288,17 +288,17 @@ private:
    * the surface cache or not.
    *
    * @return a drawable surface, which may be empty if the requested surface
    *         could not be found.
    */
   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,
                                    uint32_t aFlags,
                                    PlaybackType aPlaybackType,
                                    bool aMarkUsed);
 
   ImgDrawResult DrawInternal(DrawableSurface&& aFrameRef,
--- a/image/SurfaceCache.cpp
+++ b/image/SurfaceCache.cpp
@@ -955,17 +955,17 @@ public:
     mAvailableCost += costEntry.GetCost();
     MOZ_ASSERT(mAvailableCost <= mMaxCost,
                "More available cost than we started with");
   }
 
   LookupResult Lookup(const ImageKey    aImageKey,
                       const SurfaceKey& aSurfaceKey,
                       const StaticMutexAutoLock& aAutoLock,
-                      bool aMarkUsed = true)
+                      bool aMarkUsed)
   {
     RefPtr<ImageSurfaceCache> cache = GetImageCache(aImageKey);
     if (!cache) {
       // No cached surfaces for this image.
       return LookupResult(MatchType::NOT_FOUND);
     }
 
     RefPtr<CachedSurface> surface = cache->Lookup(aSurfaceKey, aMarkUsed);
@@ -995,17 +995,17 @@ public:
     MOZ_ASSERT(surface->GetSurfaceKey() == aSurfaceKey,
                "Lookup() not returning an exact match?");
     return LookupResult(std::move(drawableSurface), MatchType::EXACT);
   }
 
   LookupResult LookupBestMatch(const ImageKey         aImageKey,
                                const SurfaceKey&      aSurfaceKey,
                                const StaticMutexAutoLock& aAutoLock,
-                               bool aMarkUsed /* = true */)
+                               bool aMarkUsed)
   {
     RefPtr<ImageSurfaceCache> cache = GetImageCache(aImageKey);
     if (!cache) {
       // No cached surfaces for this image.
       return LookupResult(MatchType::NOT_FOUND);
     }
 
     // Repeatedly look up the best match, trying again if the resulting surface
@@ -1514,17 +1514,17 @@ SurfaceCache::Shutdown()
     MOZ_ASSERT(sInstance, "No singleton - was Shutdown() called twice?");
     cache = sInstance.forget();
   }
 }
 
 /* static */ LookupResult
 SurfaceCache::Lookup(const ImageKey         aImageKey,
                      const SurfaceKey&      aSurfaceKey,
-                     bool aMarkUsed /* = true */)
+                     bool aMarkUsed)
 {
   nsTArray<RefPtr<CachedSurface>> discard;
   LookupResult rv(MatchType::NOT_FOUND);
 
   {
     StaticMutexAutoLock lock(sInstanceMutex);
     if (!sInstance) {
       return rv;
@@ -1535,17 +1535,17 @@ SurfaceCache::Lookup(const ImageKey     
   }
 
   return rv;
 }
 
 /* static */ LookupResult
 SurfaceCache::LookupBestMatch(const ImageKey         aImageKey,
                               const SurfaceKey&      aSurfaceKey,
-                              bool aMarkUsed /* = true */)
+                              bool aMarkUsed)
 {
   nsTArray<RefPtr<CachedSurface>> discard;
   LookupResult rv(MatchType::NOT_FOUND);
 
   {
     StaticMutexAutoLock lock(sInstanceMutex);
     if (!sInstance) {
       return rv;
--- a/image/SurfaceCache.h
+++ b/image/SurfaceCache.h
@@ -228,17 +228,17 @@ struct SurfaceCache
    *                        belongs to.
    * @param aSurfaceKey     Key data which uniquely identifies the requested
    *                        cache entry.
    * @return                a LookupResult which will contain a DrawableSurface
    *                        if the cache entry was found.
    */
   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
    * its associated surface.
    *
    * The result may vary from the requested cache entry only in terms of size.
    *
    * @param aImageKey       Key data identifying which image the cache entry
@@ -248,17 +248,17 @@ struct SurfaceCache
    * @return                a LookupResult which will contain a DrawableSurface
    *                        if a cache entry similar to the one the caller
    *                        requested could be found. Callers can use
    *                        LookupResult::IsExactMatch() to check whether the
    *                        returned surface exactly matches @aSurfaceKey.
    */
   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
    * ImageKey and SurfaceKey is already in the cache, Insert returns
    * FAILURE_ALREADY_PRESENT. If a matching placeholder is already present, it
    * is replaced.
    *
    * Cache entries will never expire as long as they remain locked, but if they
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1126,19 +1126,19 @@ VectorImage::LookupCachedSurface(const I
   // in this case either.
   if (mHaveAnimations) {
     return MakeTuple(RefPtr<SourceSurface>(), 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()
                        ? aSize : result.SuggestedSize();
   MOZ_ASSERT(result.Type() != MatchType::SUBSTITUTE_BECAUSE_PENDING);
   if (!result || result.Type() == MatchType::SUBSTITUTE_BECAUSE_NOT_FOUND) {
     // No matching surface, or the OS freed the volatile buffer.
     return MakeTuple(RefPtr<SourceSurface>(), rasterSize);
--- a/image/test/gtest/TestDecoders.cpp
+++ b/image/test/gtest/TestDecoders.cpp
@@ -568,60 +568,64 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRA
   EXPECT_TRUE(bool(imageProgress & FLAG_IS_ANIMATED) == true);
 
   // Ensure that we decoded the static version of the image.
   {
     LookupResult result =
       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()));
   }
 
   // Ensure that we didn't decode the animated version of the image.
   {
     LookupResult result =
       SurfaceCache::Lookup(ImageKey(image.get()),
                            RasterSurfaceKey(imageSize,
                                             DefaultSurfaceFlags(),
-                                            PlaybackType::eAnimated));
+                                            PlaybackType::eAnimated),
+                           /* aMarkUsed = */ false);
     ASSERT_EQ(MatchType::NOT_FOUND, result.Type());
   }
 
   // Use GetFrame() to force a sync decode of the image, this time specifying
   // FRAME_CURRENT to ensure that we get an animated decode.
   RefPtr<SourceSurface> animatedSurface =
     image->GetFrame(imgIContainer::FRAME_CURRENT,
                     imgIContainer::FLAG_SYNC_DECODE);
 
   // Ensure that we decoded both frames of the animated version of the image.
   {
     LookupResult result =
       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)));
     EXPECT_TRUE(bool(result.Surface()));
 
     RawAccessFrameRef partialFrame = result.Surface().RawAccessRef(1);
     EXPECT_TRUE(bool(partialFrame));
   }
 
   // Ensure that the static version is still around.
   {
     LookupResult result =
       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()));
   }
 }
 
 TEST_F(ImageDecoders, AnimatedGIFWithFRAME_CURRENT)
 {
   ImageTestCase testCase = GreenFirstFrameAnimatedGIFTestCase();
@@ -681,60 +685,64 @@ TEST_F(ImageDecoders, AnimatedGIFWithFRA
   EXPECT_TRUE(bool(imageProgress & FLAG_IS_ANIMATED) == true);
 
   // Ensure that we decoded both frames of the animated version of the image.
   {
     LookupResult result =
       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)));
     EXPECT_TRUE(bool(result.Surface()));
 
     RawAccessFrameRef partialFrame = result.Surface().RawAccessRef(1);
     EXPECT_TRUE(bool(partialFrame));
   }
 
   // Ensure that we didn't decode the static version of the image.
   {
     LookupResult result =
       SurfaceCache::Lookup(ImageKey(image.get()),
                            RasterSurfaceKey(imageSize,
                                             DefaultSurfaceFlags(),
-                                            PlaybackType::eStatic));
+                                            PlaybackType::eStatic),
+                           /* aMarkUsed = */ false);
     ASSERT_EQ(MatchType::NOT_FOUND, result.Type());
   }
 
   // Use GetFrame() to force a sync decode of the image, this time specifying
   // FRAME_FIRST to ensure that we get a single-frame decode.
   RefPtr<SourceSurface> animatedSurface =
     image->GetFrame(imgIContainer::FRAME_FIRST,
                     imgIContainer::FLAG_SYNC_DECODE);
 
   // Ensure that we decoded the static version of the image.
   {
     LookupResult result =
       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()));
   }
 
   // Ensure that both frames of the animated version are still around.
   {
     LookupResult result =
       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)));
     EXPECT_TRUE(bool(result.Surface()));
 
     RawAccessFrameRef partialFrame = result.Surface().RawAccessRef(1);
     EXPECT_TRUE(bool(partialFrame));
   }
@@ -793,17 +801,18 @@ TEST_F(ImageDecoders, AnimatedGIFWithExt
   EXPECT_TRUE(bool(imageProgress & FLAG_HAS_TRANSPARENCY) == false);
   EXPECT_TRUE(bool(imageProgress & FLAG_IS_ANIMATED) == true);
 
   // Ensure that we decoded both frames of the image.
   LookupResult result =
     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)));
   EXPECT_TRUE(bool(result.Surface()));
 
   RawAccessFrameRef partialFrame = result.Surface().RawAccessRef(1);
   EXPECT_TRUE(bool(partialFrame));
 }
--- a/image/test/gtest/TestMetadata.cpp
+++ b/image/test/gtest/TestMetadata.cpp
@@ -245,17 +245,18 @@ TEST_F(ImageDecoderMetadata, NoFrameDela
   EXPECT_TRUE(bool(imageProgress & FLAG_HAS_TRANSPARENCY) == false);
   EXPECT_TRUE(bool(imageProgress & FLAG_IS_ANIMATED) == true);
 
   // Ensure that we decoded both frames of the image.
   LookupResult result =
     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)));
   EXPECT_TRUE(bool(result.Surface()));
 
   RawAccessFrameRef partialFrame = result.Surface().RawAccessRef(1);
   EXPECT_TRUE(bool(partialFrame));
 }