Bug 1293449 - Stop exposing SurfaceCache implementation code outside of ImageLib. r=dholbert
authorSeth Fowler <mark.seth.fowler@gmail.com>
Mon, 08 Aug 2016 15:54:10 -0700
changeset 309490 94d3d18441af5d64987755ad130a1b084ed53bee
parent 309489 ef4aaae8d79bb6ca37b88d3440db1247fa10e260
child 309491 dbd63e535b5312d47f6de9a8bfd07784cb27f6a5
push id80607
push userseth.bugzilla@blackhail.net
push dateTue, 16 Aug 2016 01:19:59 +0000
treeherdermozilla-inbound@94d3d18441af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1293449
milestone51.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 1293449 - Stop exposing SurfaceCache implementation code outside of ImageLib. r=dholbert
image/SurfaceCacheUtils.cpp
image/SurfaceCacheUtils.h
image/moz.build
layout/base/nsPresContext.cpp
new file mode 100644
--- /dev/null
+++ b/image/SurfaceCacheUtils.cpp
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "SurfaceCacheUtils.h"
+
+#include "SurfaceCache.h"
+
+namespace mozilla {
+namespace image {
+
+/* static */ void
+SurfaceCacheUtils::DiscardAll()
+{
+  SurfaceCache::DiscardAll();
+}
+
+} // namespace image
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/image/SurfaceCacheUtils.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_image_SurfaceCacheUtils_h
+#define mozilla_image_SurfaceCacheUtils_h
+
+/**
+ * SurfaceCacheUtils provides an ImageLib-external API to interact with
+ * ImageLib's SurfaceCache.
+ */
+
+namespace mozilla {
+namespace image {
+
+class SurfaceCacheUtils
+{
+public:
+  /**
+   * Evicts all evictable entries from the surface cache.
+   *
+   * See the documentation for SurfaceCache::DiscardAll() for the details.
+   */
+  static void DiscardAll();
+
+private:
+  virtual ~SurfaceCacheUtils() = 0;  // Forbid instantiation.
+};
+
+} // namespace image
+} // namespace mozilla
+
+#endif // mozilla_image_SurfaceCacheUtils_h
--- a/image/moz.build
+++ b/image/moz.build
@@ -41,18 +41,17 @@ EXPORTS += [
     'ImageLogging.h',
     'ImageOps.h',
     'ImageRegion.h',
     'imgLoader.h',
     'imgRequest.h',
     'imgRequestProxy.h',
     'IProgressObserver.h',
     'Orientation.h',
-    'SurfaceCache.h',
-    'SurfaceFlags.h',
+    'SurfaceCacheUtils.h',
 ]
 
 UNIFIED_SOURCES += [
     'ClippedImage.cpp',
     'DecodedSurfaceProvider.cpp',
     'DecodePool.cpp',
     'Decoder.cpp',
     'DecoderFactory.cpp',
@@ -68,16 +67,17 @@ UNIFIED_SOURCES += [
     'imgFrame.cpp',
     'imgTools.cpp',
     'MultipartImage.cpp',
     'OrientedImage.cpp',
     'ScriptedNotificationObserver.cpp',
     'ShutdownTracker.cpp',
     'SourceBuffer.cpp',
     'SurfaceCache.cpp',
+    'SurfaceCacheUtils.cpp',
     'SurfacePipe.cpp',
     'SVGDocumentWrapper.cpp',
     'VectorImage.cpp',
 ]
 if CONFIG['MOZ_ENABLE_SKIA']:
     UNIFIED_SOURCES += [ 'Downscaler.cpp']
 
 # These files can't be unified because of ImageLogging.h #include order issues.
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -32,17 +32,17 @@
 #include "nsIWeakReferenceUtils.h"
 #include "nsThreadUtils.h"
 #include "nsFrameManager.h"
 #include "nsLayoutUtils.h"
 #include "nsViewManager.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerHandle.h"
 #include "mozilla/RestyleManagerHandleInlines.h"
-#include "SurfaceCache.h"
+#include "SurfaceCacheUtils.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsRuleNode.h"
 #include "gfxPlatform.h"
 #include "nsCSSRules.h"
 #include "nsFontFaceLoader.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EventListenerManager.h"
 #include "prenv.h"
@@ -1626,17 +1626,17 @@ nsPresContext::ThemeChangedInternal()
   if (sLookAndFeelChanged) {
     // Clear all cached LookAndFeel colors.
     LookAndFeel::Refresh();
     sLookAndFeelChanged = false;
 
     // Vector images (SVG) may be using theme colors so we discard all cached
     // surfaces. (We could add a vector image only version of DiscardAll, but
     // in bug 940625 we decided theme changes are rare enough not to bother.)
-    mozilla::image::SurfaceCache::DiscardAll();
+    image::SurfaceCacheUtils::DiscardAll();
   }
 
   // This will force the system metrics to be generated the next time they're used
   nsCSSRuleProcessor::FreeSystemMetrics();
 
   // Changes to system metrics can change media queries on them, or
   // :-moz-system-metric selectors (which requires eRestyle_Subtree).
   // Changes in theme can change system colors (whose changes are