diff --git a/image/SurfaceCacheUtils.cpp b/image/SurfaceCacheUtils.cpp new file mode 100644 index 000000000000..f97674c4fb64 --- /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 diff --git a/image/SurfaceCacheUtils.h b/image/SurfaceCacheUtils.h new file mode 100644 index 000000000000..fcce7a334df7 --- /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 diff --git a/image/moz.build b/image/moz.build index f8004df33fd0..707a5278bfb3 100644 --- a/image/moz.build +++ b/image/moz.build @@ -46,8 +46,7 @@ EXPORTS += [ 'imgRequestProxy.h', 'IProgressObserver.h', 'Orientation.h', - 'SurfaceCache.h', - 'SurfaceFlags.h', + 'SurfaceCacheUtils.h', ] UNIFIED_SOURCES += [ @@ -73,6 +72,7 @@ UNIFIED_SOURCES += [ 'ShutdownTracker.cpp', 'SourceBuffer.cpp', 'SurfaceCache.cpp', + 'SurfaceCacheUtils.cpp', 'SurfacePipe.cpp', 'SVGDocumentWrapper.cpp', 'VectorImage.cpp', diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index b9c810fe8a7d..04214395e493 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -37,7 +37,7 @@ #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" @@ -1631,7 +1631,7 @@ nsPresContext::ThemeChangedInternal() // 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