Bug 1293449 - Stop exposing SurfaceCache implementation code outside of ImageLib. r=dholbert

This commit is contained in:
Seth Fowler 2016-08-08 15:54:10 -07:00
parent ca40b738e4
commit 21f89abe61
4 changed files with 58 additions and 4 deletions

View File

@ -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

34
image/SurfaceCacheUtils.h Normal file
View File

@ -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

View File

@ -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',

View File

@ -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