Bug 1523969 part 10 - Move method definition inline comments to new line in 'image/'. r=aosmond

Differential Revision: https://phabricator.services.mozilla.com/D21110
This commit is contained in:
Ryan Hunt
2019-02-25 16:07:58 -06:00
parent 50b1514555
commit f703c76ee2
13 changed files with 152 additions and 102 deletions

View File

@@ -36,8 +36,10 @@ namespace image {
// DecodePool implementation. // DecodePool implementation.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/* static */ StaticRefPtr<DecodePool> DecodePool::sSingleton; /* static */
/* static */ uint32_t DecodePool::sNumCores = 0; StaticRefPtr<DecodePool> DecodePool::sSingleton;
/* static */
uint32_t DecodePool::sNumCores = 0;
NS_IMPL_ISUPPORTS(DecodePool, nsIObserver) NS_IMPL_ISUPPORTS(DecodePool, nsIObserver)
@@ -309,13 +311,15 @@ bool DecodePoolImpl::CreateThread() {
return true; return true;
} }
/* static */ void DecodePool::Initialize() { /* static */
void DecodePool::Initialize() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
sNumCores = max<int32_t>(PR_GetNumberOfProcessors(), 1); sNumCores = max<int32_t>(PR_GetNumberOfProcessors(), 1);
DecodePool::Singleton(); DecodePool::Singleton();
} }
/* static */ DecodePool* DecodePool::Singleton() { /* static */
DecodePool* DecodePool::Singleton() {
if (!sSingleton) { if (!sSingleton) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
sSingleton = new DecodePool(); sSingleton = new DecodePool();
@@ -325,7 +329,8 @@ bool DecodePoolImpl::CreateThread() {
return sSingleton; return sSingleton;
} }
/* static */ uint32_t DecodePool::NumberOfCores() { return sNumCores; } /* static */
uint32_t DecodePool::NumberOfCores() { return sNumCores; }
DecodePool::DecodePool() : mMutex("image::DecodePool") { DecodePool::DecodePool() : mMutex("image::DecodePool") {
// Determine the number of threads we want. // Determine the number of threads we want.

View File

@@ -28,7 +28,8 @@ using namespace gfx;
namespace image { namespace image {
/* static */ DecoderType DecoderFactory::GetDecoderType(const char* aMimeType) { /* static */
DecoderType DecoderFactory::GetDecoderType(const char* aMimeType) {
// By default we don't know. // By default we don't know.
DecoderType type = DecoderType::UNKNOWN; DecoderType type = DecoderType::UNKNOWN;
@@ -80,8 +81,10 @@ namespace image {
return type; return type;
} }
/* static */ already_AddRefed<Decoder> DecoderFactory::GetDecoder( /* static */
DecoderType aType, RasterImage* aImage, bool aIsRedecode) { already_AddRefed<Decoder> DecoderFactory::GetDecoder(DecoderType aType,
RasterImage* aImage,
bool aIsRedecode) {
RefPtr<Decoder> decoder; RefPtr<Decoder> decoder;
switch (aType) { switch (aType) {
@@ -119,7 +122,8 @@ namespace image {
return decoder.forget(); return decoder.forget();
} }
/* static */ nsresult DecoderFactory::CreateDecoder( /* static */
nsresult DecoderFactory::CreateDecoder(
DecoderType aType, NotNull<RasterImage*> aImage, DecoderType aType, NotNull<RasterImage*> aImage,
NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize, NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize,
const IntSize& aOutputSize, DecoderFlags aDecoderFlags, const IntSize& aOutputSize, DecoderFlags aDecoderFlags,
@@ -173,7 +177,8 @@ namespace image {
return NS_OK; return NS_OK;
} }
/* static */ nsresult DecoderFactory::CreateAnimationDecoder( /* static */
nsresult DecoderFactory::CreateAnimationDecoder(
DecoderType aType, NotNull<RasterImage*> aImage, DecoderType aType, NotNull<RasterImage*> aImage,
NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize, NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize,
DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags,
@@ -227,7 +232,8 @@ namespace image {
return NS_OK; return NS_OK;
} }
/* static */ already_AddRefed<Decoder> DecoderFactory::CloneAnimationDecoder( /* static */
already_AddRefed<Decoder> DecoderFactory::CloneAnimationDecoder(
Decoder* aDecoder) { Decoder* aDecoder) {
MOZ_ASSERT(aDecoder); MOZ_ASSERT(aDecoder);
@@ -257,10 +263,10 @@ namespace image {
return decoder.forget(); return decoder.forget();
} }
/* static */ already_AddRefed<IDecodingTask> /* static */
DecoderFactory::CreateMetadataDecoder(DecoderType aType, already_AddRefed<IDecodingTask> DecoderFactory::CreateMetadataDecoder(
NotNull<RasterImage*> aImage, DecoderType aType, NotNull<RasterImage*> aImage,
NotNull<SourceBuffer*> aSourceBuffer) { NotNull<SourceBuffer*> aSourceBuffer) {
if (aType == DecoderType::UNKNOWN) { if (aType == DecoderType::UNKNOWN) {
return nullptr; return nullptr;
} }
@@ -281,14 +287,12 @@ DecoderFactory::CreateMetadataDecoder(DecoderType aType,
return task.forget(); return task.forget();
} }
/* static */ already_AddRefed<Decoder> /* static */
DecoderFactory::CreateDecoderForICOResource(DecoderType aType, already_AddRefed<Decoder> DecoderFactory::CreateDecoderForICOResource(
SourceBufferIterator&& aIterator, DecoderType aType, SourceBufferIterator&& aIterator,
NotNull<nsICODecoder*> aICODecoder, NotNull<nsICODecoder*> aICODecoder, bool aIsMetadataDecode,
bool aIsMetadataDecode, const Maybe<IntSize>& aExpectedSize, const Maybe<uint32_t>& aDataOffset
const Maybe<IntSize>& aExpectedSize, /* = Nothing() */) {
const Maybe<uint32_t>& aDataOffset
/* = Nothing() */) {
// Create the decoder. // Create the decoder.
RefPtr<Decoder> decoder; RefPtr<Decoder> decoder;
switch (aType) { switch (aType) {
@@ -330,7 +334,8 @@ DecoderFactory::CreateDecoderForICOResource(DecoderType aType,
return decoder.forget(); return decoder.forget();
} }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousDecoder( /* static */
already_AddRefed<Decoder> DecoderFactory::CreateAnonymousDecoder(
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer, DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer,
const Maybe<IntSize>& aOutputSize, DecoderFlags aDecoderFlags, const Maybe<IntSize>& aOutputSize, DecoderFlags aDecoderFlags,
SurfaceFlags aSurfaceFlags) { SurfaceFlags aSurfaceFlags) {
@@ -365,8 +370,8 @@ DecoderFactory::CreateDecoderForICOResource(DecoderType aType,
return decoder.forget(); return decoder.forget();
} }
/* static */ already_AddRefed<Decoder> /* static */
DecoderFactory::CreateAnonymousMetadataDecoder( already_AddRefed<Decoder> DecoderFactory::CreateAnonymousMetadataDecoder(
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer) { DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer) {
if (aType == DecoderType::UNKNOWN) { if (aType == DecoderType::UNKNOWN) {
return nullptr; return nullptr;

View File

@@ -136,8 +136,9 @@ bool ImageCacheKey::SchemeIs(const char* aScheme) {
return NS_SUCCEEDED(mURI->SchemeIs(aScheme, &matches)) && matches; return NS_SUCCEEDED(mURI->SchemeIs(aScheme, &matches)) && matches;
} }
/* static */ void* ImageCacheKey::GetSpecialCaseDocumentToken( /* static */
Document* aDocument, nsIURI* aURI) { void* ImageCacheKey::GetSpecialCaseDocumentToken(Document* aDocument,
nsIURI* aURI) {
// Cookie-averse documents can never have storage granted to them. Since they // Cookie-averse documents can never have storage granted to them. Since they
// may not have inner windows, they would require special handling below, so // may not have inner windows, they would require special handling below, so
// just bail out early here. // just bail out early here.

View File

@@ -29,7 +29,8 @@
namespace mozilla { namespace mozilla {
namespace image { namespace image {
/*static*/ void ImageFactory::Initialize() {} /*static*/
void ImageFactory::Initialize() {}
static uint32_t ComputeImageFlags(nsIURI* uri, const nsCString& aMimeType, static uint32_t ComputeImageFlags(nsIURI* uri, const nsCString& aMimeType,
bool isMultiPart) { bool isMultiPart) {
@@ -104,7 +105,8 @@ static void NotifyImageLoading(nsIURI* aURI) {
} }
#endif #endif
/* static */ already_AddRefed<Image> ImageFactory::CreateImage( /* static */
already_AddRefed<Image> ImageFactory::CreateImage(
nsIRequest* aRequest, ProgressTracker* aProgressTracker, nsIRequest* aRequest, ProgressTracker* aProgressTracker,
const nsCString& aMimeType, nsIURI* aURI, bool aIsMultiPart, const nsCString& aMimeType, nsIURI* aURI, bool aIsMultiPart,
uint32_t aInnerWindowId) { uint32_t aInnerWindowId) {
@@ -141,7 +143,8 @@ static already_AddRefed<Image> BadImage(const char* aMessage,
return aImage.forget(); return aImage.forget();
} }
/* static */ already_AddRefed<Image> ImageFactory::CreateAnonymousImage( /* static */
already_AddRefed<Image> ImageFactory::CreateAnonymousImage(
const nsCString& aMimeType, uint32_t aSizeHint /* = 0 */) { const nsCString& aMimeType, uint32_t aSizeHint /* = 0 */) {
nsresult rv; nsresult rv;
@@ -164,9 +167,9 @@ static already_AddRefed<Image> BadImage(const char* aMessage,
return newImage.forget(); return newImage.forget();
} }
/* static */ already_AddRefed<MultipartImage> /* static */
ImageFactory::CreateMultipartImage(Image* aFirstPart, already_AddRefed<MultipartImage> ImageFactory::CreateMultipartImage(
ProgressTracker* aProgressTracker) { Image* aFirstPart, ProgressTracker* aProgressTracker) {
MOZ_ASSERT(aFirstPart); MOZ_ASSERT(aFirstPart);
MOZ_ASSERT(aProgressTracker); MOZ_ASSERT(aProgressTracker);
@@ -218,7 +221,8 @@ uint32_t GetContentSize(nsIRequest* aRequest) {
return 0; return 0;
} }
/* static */ already_AddRefed<Image> ImageFactory::CreateRasterImage( /* static */
already_AddRefed<Image> ImageFactory::CreateRasterImage(
nsIRequest* aRequest, ProgressTracker* aProgressTracker, nsIRequest* aRequest, ProgressTracker* aProgressTracker,
const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags, const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
uint32_t aInnerWindowId) { uint32_t aInnerWindowId) {
@@ -245,7 +249,8 @@ uint32_t GetContentSize(nsIRequest* aRequest) {
return newImage.forget(); return newImage.forget();
} }
/* static */ already_AddRefed<Image> ImageFactory::CreateVectorImage( /* static */
already_AddRefed<Image> ImageFactory::CreateVectorImage(
nsIRequest* aRequest, ProgressTracker* aProgressTracker, nsIRequest* aRequest, ProgressTracker* aProgressTracker,
const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags, const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
uint32_t aInnerWindowId) { uint32_t aInnerWindowId) {

View File

@@ -36,7 +36,8 @@ class ImageMemoryReporter::WebRenderReporter final : public nsIMemoryReporter {
NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter) NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
/* static */ void ImageMemoryReporter::InitForWebRender() { /* static */
void ImageMemoryReporter::InitForWebRender() {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess()); MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess());
if (!sWrReporter) { if (!sWrReporter) {
sWrReporter = new WebRenderReporter(); sWrReporter = new WebRenderReporter();
@@ -44,7 +45,8 @@ NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
} }
} }
/* static */ void ImageMemoryReporter::ShutdownForWebRender() { /* static */
void ImageMemoryReporter::ShutdownForWebRender() {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess()); MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess());
if (sWrReporter) { if (sWrReporter) {
UnregisterStrongMemoryReporter(sWrReporter); UnregisterStrongMemoryReporter(sWrReporter);
@@ -52,14 +54,16 @@ NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
} }
} }
/* static */ void ImageMemoryReporter::ReportSharedSurfaces( /* static */
void ImageMemoryReporter::ReportSharedSurfaces(
nsIHandleReportCallback* aHandleReport, nsISupports* aData, nsIHandleReportCallback* aHandleReport, nsISupports* aData,
const layers::SharedSurfacesMemoryReport& aSharedSurfaces) { const layers::SharedSurfacesMemoryReport& aSharedSurfaces) {
ReportSharedSurfaces(aHandleReport, aData, ReportSharedSurfaces(aHandleReport, aData,
/* aIsForCompositor */ false, aSharedSurfaces); /* aIsForCompositor */ false, aSharedSurfaces);
} }
/* static */ void ImageMemoryReporter::ReportSharedSurfaces( /* static */
void ImageMemoryReporter::ReportSharedSurfaces(
nsIHandleReportCallback* aHandleReport, nsISupports* aData, nsIHandleReportCallback* aHandleReport, nsISupports* aData,
bool aIsForCompositor, bool aIsForCompositor,
const layers::SharedSurfacesMemoryReport& aSharedSurfaces) { const layers::SharedSurfacesMemoryReport& aSharedSurfaces) {
@@ -74,7 +78,8 @@ NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
} }
} }
/* static */ void ImageMemoryReporter::ReportSharedSurface( /* static */
void ImageMemoryReporter::ReportSharedSurface(
nsIHandleReportCallback* aHandleReport, nsISupports* aData, nsIHandleReportCallback* aHandleReport, nsISupports* aData,
bool aIsForCompositor, uint64_t aExternalId, bool aIsForCompositor, uint64_t aExternalId,
const layers::SharedSurfacesMemoryReport::SurfaceEntry& aEntry) { const layers::SharedSurfacesMemoryReport::SurfaceEntry& aEntry) {
@@ -123,7 +128,8 @@ NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
aData); aData);
} }
/* static */ void ImageMemoryReporter::AppendSharedSurfacePrefix( /* static */
void ImageMemoryReporter::AppendSharedSurfacePrefix(
nsACString& aPathPrefix, const SurfaceMemoryCounter& aCounter, nsACString& aPathPrefix, const SurfaceMemoryCounter& aCounter,
layers::SharedSurfacesMemoryReport& aSharedSurfaces) { layers::SharedSurfacesMemoryReport& aSharedSurfaces) {
uint64_t extId = aCounter.Values().ExternalId(); uint64_t extId = aCounter.Values().ExternalId();
@@ -148,7 +154,8 @@ NS_IMPL_ISUPPORTS(ImageMemoryReporter::WebRenderReporter, nsIMemoryReporter)
} }
} }
/* static */ void ImageMemoryReporter::TrimSharedSurfaces( /* static */
void ImageMemoryReporter::TrimSharedSurfaces(
const ImageMemoryCounter& aCounter, const ImageMemoryCounter& aCounter,
layers::SharedSurfacesMemoryReport& aSharedSurfaces) { layers::SharedSurfacesMemoryReport& aSharedSurfaces) {
if (aSharedSurfaces.mSurfaces.empty()) { if (aSharedSurfaces.mSurfaces.empty()) {

View File

@@ -26,26 +26,29 @@ using namespace mozilla::gfx;
namespace mozilla { namespace mozilla {
namespace image { namespace image {
/* static */ already_AddRefed<Image> ImageOps::Freeze(Image* aImage) { /* static */
already_AddRefed<Image> ImageOps::Freeze(Image* aImage) {
RefPtr<Image> frozenImage = new FrozenImage(aImage); RefPtr<Image> frozenImage = new FrozenImage(aImage);
return frozenImage.forget(); return frozenImage.forget();
} }
/* static */ already_AddRefed<imgIContainer> ImageOps::Freeze( /* static */
imgIContainer* aImage) { already_AddRefed<imgIContainer> ImageOps::Freeze(imgIContainer* aImage) {
nsCOMPtr<imgIContainer> frozenImage = nsCOMPtr<imgIContainer> frozenImage =
new FrozenImage(static_cast<Image*>(aImage)); new FrozenImage(static_cast<Image*>(aImage));
return frozenImage.forget(); return frozenImage.forget();
} }
/* static */ already_AddRefed<Image> ImageOps::Clip( /* static */
Image* aImage, nsIntRect aClip, const Maybe<nsSize>& aSVGViewportSize) { already_AddRefed<Image> ImageOps::Clip(Image* aImage, nsIntRect aClip,
const Maybe<nsSize>& aSVGViewportSize) {
RefPtr<Image> clippedImage = RefPtr<Image> clippedImage =
new ClippedImage(aImage, aClip, aSVGViewportSize); new ClippedImage(aImage, aClip, aSVGViewportSize);
return clippedImage.forget(); return clippedImage.forget();
} }
/* static */ already_AddRefed<imgIContainer> ImageOps::Clip( /* static */
already_AddRefed<imgIContainer> ImageOps::Clip(
imgIContainer* aImage, nsIntRect aClip, imgIContainer* aImage, nsIntRect aClip,
const Maybe<nsSize>& aSVGViewportSize) { const Maybe<nsSize>& aSVGViewportSize) {
nsCOMPtr<imgIContainer> clippedImage = nsCOMPtr<imgIContainer> clippedImage =
@@ -53,20 +56,23 @@ namespace image {
return clippedImage.forget(); return clippedImage.forget();
} }
/* static */ already_AddRefed<Image> ImageOps::Orient( /* static */
Image* aImage, Orientation aOrientation) { already_AddRefed<Image> ImageOps::Orient(Image* aImage,
Orientation aOrientation) {
RefPtr<Image> orientedImage = new OrientedImage(aImage, aOrientation); RefPtr<Image> orientedImage = new OrientedImage(aImage, aOrientation);
return orientedImage.forget(); return orientedImage.forget();
} }
/* static */ already_AddRefed<imgIContainer> ImageOps::Orient( /* static */
imgIContainer* aImage, Orientation aOrientation) { already_AddRefed<imgIContainer> ImageOps::Orient(imgIContainer* aImage,
Orientation aOrientation) {
nsCOMPtr<imgIContainer> orientedImage = nsCOMPtr<imgIContainer> orientedImage =
new OrientedImage(static_cast<Image*>(aImage), aOrientation); new OrientedImage(static_cast<Image*>(aImage), aOrientation);
return orientedImage.forget(); return orientedImage.forget();
} }
/* static */ already_AddRefed<imgIContainer> ImageOps::CreateFromDrawable( /* static */
already_AddRefed<imgIContainer> ImageOps::CreateFromDrawable(
gfxDrawable* aDrawable) { gfxDrawable* aDrawable) {
nsCOMPtr<imgIContainer> drawableImage = new DynamicImage(aDrawable); nsCOMPtr<imgIContainer> drawableImage = new DynamicImage(aDrawable);
return drawableImage.forget(); return drawableImage.forget();
@@ -134,17 +140,19 @@ ImageOps::CreateImageBuffer(already_AddRefed<nsIInputStream> aInputStream) {
return imageBuffer.forget(); return imageBuffer.forget();
} }
/* static */ nsresult ImageOps::DecodeMetadata( /* static */
already_AddRefed<nsIInputStream> aInputStream, const nsACString& aMimeType, nsresult ImageOps::DecodeMetadata(already_AddRefed<nsIInputStream> aInputStream,
ImageMetadata& aMetadata) { const nsACString& aMimeType,
ImageMetadata& aMetadata) {
nsCOMPtr<nsIInputStream> inputStream = std::move(aInputStream); nsCOMPtr<nsIInputStream> inputStream = std::move(aInputStream);
RefPtr<ImageBuffer> buffer = CreateImageBuffer(inputStream.forget()); RefPtr<ImageBuffer> buffer = CreateImageBuffer(inputStream.forget());
return DecodeMetadata(buffer, aMimeType, aMetadata); return DecodeMetadata(buffer, aMimeType, aMetadata);
} }
/* static */ nsresult ImageOps::DecodeMetadata(ImageBuffer* aBuffer, /* static */
const nsACString& aMimeType, nsresult ImageOps::DecodeMetadata(ImageBuffer* aBuffer,
ImageMetadata& aMetadata) { const nsACString& aMimeType,
ImageMetadata& aMetadata) {
if (!aBuffer) { if (!aBuffer) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@@ -1546,8 +1546,8 @@ void RasterImage::DoError() {
("RasterImage: [this=%p] Error detected for image\n", this)); ("RasterImage: [this=%p] Error detected for image\n", this));
} }
/* static */ void RasterImage::HandleErrorWorker::DispatchIfNeeded( /* static */
RasterImage* aImage) { void RasterImage::HandleErrorWorker::DispatchIfNeeded(RasterImage* aImage) {
RefPtr<HandleErrorWorker> worker = new HandleErrorWorker(aImage); RefPtr<HandleErrorWorker> worker = new HandleErrorWorker(aImage);
NS_DispatchToMainThread(worker); NS_DispatchToMainThread(worker);
} }

View File

@@ -53,16 +53,16 @@ NS_IMPL_ISUPPORTS(ShutdownObserver, nsIObserver)
// Public API // Public API
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/* static */ void ShutdownTracker::Initialize() { /* static */
void ShutdownTracker::Initialize() {
nsCOMPtr<nsIObserverService> os = services::GetObserverService(); nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) { if (os) {
os->AddObserver(new ShutdownObserver, "xpcom-will-shutdown", false); os->AddObserver(new ShutdownObserver, "xpcom-will-shutdown", false);
} }
} }
/* static */ bool ShutdownTracker::ShutdownHasStarted() { /* static */
return sShutdownHasStarted; bool ShutdownTracker::ShutdownHasStarted() { return sShutdownHasStarted; }
}
} // namespace image } // namespace image
} // namespace mozilla } // namespace mozilla

View File

@@ -256,7 +256,8 @@ nsresult SourceBuffer::Compact() {
return NS_OK; return NS_OK;
} }
/* static */ size_t SourceBuffer::RoundedUpCapacity(size_t aCapacity) { /* static */
size_t SourceBuffer::RoundedUpCapacity(size_t aCapacity) {
// Protect against overflow. // Protect against overflow.
if (MOZ_UNLIKELY(SIZE_MAX - aCapacity < MIN_CHUNK_CAPACITY)) { if (MOZ_UNLIKELY(SIZE_MAX - aCapacity < MIN_CHUNK_CAPACITY)) {
return aCapacity; return aCapacity;

View File

@@ -1382,7 +1382,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
// Public API // Public API
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/* static */ void SurfaceCache::Initialize() { /* static */
void SurfaceCache::Initialize() {
// Initialize preferences. // Initialize preferences.
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!sInstance, "Shouldn't initialize more than once"); MOZ_ASSERT(!sInstance, "Shouldn't initialize more than once");
@@ -1436,7 +1437,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
sInstance->InitMemoryReporter(); sInstance->InitMemoryReporter();
} }
/* static */ void SurfaceCache::Shutdown() { /* static */
void SurfaceCache::Shutdown() {
RefPtr<SurfaceCacheImpl> cache; RefPtr<SurfaceCacheImpl> cache;
{ {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
@@ -1446,9 +1448,10 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
} }
} }
/* static */ LookupResult SurfaceCache::Lookup(const ImageKey aImageKey, /* static */
const SurfaceKey& aSurfaceKey, LookupResult SurfaceCache::Lookup(const ImageKey aImageKey,
bool aMarkUsed) { const SurfaceKey& aSurfaceKey,
bool aMarkUsed) {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
LookupResult rv(MatchType::NOT_FOUND); LookupResult rv(MatchType::NOT_FOUND);
@@ -1465,8 +1468,10 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return rv; return rv;
} }
/* static */ LookupResult SurfaceCache::LookupBestMatch( /* static */
const ImageKey aImageKey, const SurfaceKey& aSurfaceKey, bool aMarkUsed) { LookupResult SurfaceCache::LookupBestMatch(const ImageKey aImageKey,
const SurfaceKey& aSurfaceKey,
bool aMarkUsed) {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
LookupResult rv(MatchType::NOT_FOUND); LookupResult rv(MatchType::NOT_FOUND);
@@ -1483,8 +1488,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return rv; return rv;
} }
/* static */ InsertOutcome SurfaceCache::Insert( /* static */
NotNull<ISurfaceProvider*> aProvider) { InsertOutcome SurfaceCache::Insert(NotNull<ISurfaceProvider*> aProvider) {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
InsertOutcome rv(InsertOutcome::FAILURE); InsertOutcome rv(InsertOutcome::FAILURE);
@@ -1501,8 +1506,9 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return rv; return rv;
} }
/* static */ bool SurfaceCache::CanHold(const IntSize& aSize, /* static */
uint32_t aBytesPerPixel /* = 4 */) { bool SurfaceCache::CanHold(const IntSize& aSize,
uint32_t aBytesPerPixel /* = 4 */) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (!sInstance) { if (!sInstance) {
return false; return false;
@@ -1512,7 +1518,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return sInstance->CanHold(cost); return sInstance->CanHold(cost);
} }
/* static */ bool SurfaceCache::CanHold(size_t aSize) { /* static */
bool SurfaceCache::CanHold(size_t aSize) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (!sInstance) { if (!sInstance) {
return false; return false;
@@ -1521,8 +1528,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return sInstance->CanHold(aSize); return sInstance->CanHold(aSize);
} }
/* static */ void SurfaceCache::SurfaceAvailable( /* static */
NotNull<ISurfaceProvider*> aProvider) { void SurfaceCache::SurfaceAvailable(NotNull<ISurfaceProvider*> aProvider) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (!sInstance) { if (!sInstance) {
return; return;
@@ -1531,28 +1538,32 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
sInstance->SurfaceAvailable(aProvider, lock); sInstance->SurfaceAvailable(aProvider, lock);
} }
/* static */ void SurfaceCache::LockImage(const ImageKey aImageKey) { /* static */
void SurfaceCache::LockImage(const ImageKey aImageKey) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (sInstance) { if (sInstance) {
return sInstance->LockImage(aImageKey); return sInstance->LockImage(aImageKey);
} }
} }
/* static */ void SurfaceCache::UnlockImage(const ImageKey aImageKey) { /* static */
void SurfaceCache::UnlockImage(const ImageKey aImageKey) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (sInstance) { if (sInstance) {
return sInstance->UnlockImage(aImageKey, lock); return sInstance->UnlockImage(aImageKey, lock);
} }
} }
/* static */ void SurfaceCache::UnlockEntries(const ImageKey aImageKey) { /* static */
void SurfaceCache::UnlockEntries(const ImageKey aImageKey) {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (sInstance) { if (sInstance) {
return sInstance->UnlockEntries(aImageKey, lock); return sInstance->UnlockEntries(aImageKey, lock);
} }
} }
/* static */ void SurfaceCache::RemoveImage(const ImageKey aImageKey) { /* static */
void SurfaceCache::RemoveImage(const ImageKey aImageKey) {
RefPtr<ImageSurfaceCache> discard; RefPtr<ImageSurfaceCache> discard;
{ {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
@@ -1562,7 +1573,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
} }
} }
/* static */ void SurfaceCache::PruneImage(const ImageKey aImageKey) { /* static */
void SurfaceCache::PruneImage(const ImageKey aImageKey) {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
{ {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
@@ -1573,7 +1585,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
} }
} }
/* static */ void SurfaceCache::DiscardAll() { /* static */
void SurfaceCache::DiscardAll() {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
{ {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
@@ -1584,7 +1597,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
} }
} }
/* static */ void SurfaceCache::CollectSizeOfSurfaces( /* static */
void SurfaceCache::CollectSizeOfSurfaces(
const ImageKey aImageKey, nsTArray<SurfaceMemoryCounter>& aCounters, const ImageKey aImageKey, nsTArray<SurfaceMemoryCounter>& aCounters,
MallocSizeOf aMallocSizeOf) { MallocSizeOf aMallocSizeOf) {
nsTArray<RefPtr<CachedSurface>> discard; nsTArray<RefPtr<CachedSurface>> discard;
@@ -1599,7 +1613,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
} }
} }
/* static */ size_t SurfaceCache::MaximumCapacity() { /* static */
size_t SurfaceCache::MaximumCapacity() {
StaticMutexAutoLock lock(sInstanceMutex); StaticMutexAutoLock lock(sInstanceMutex);
if (!sInstance) { if (!sInstance) {
return 0; return 0;
@@ -1608,7 +1623,8 @@ NS_IMPL_ISUPPORTS(SurfaceCacheImpl::MemoryPressureObserver, nsIObserver)
return sInstance->MaximumCapacity(); return sInstance->MaximumCapacity();
} }
/* static */ bool SurfaceCache::IsLegalSize(const IntSize& aSize) { /* static */
bool SurfaceCache::IsLegalSize(const IntSize& aSize) {
// reject over-wide or over-tall images // reject over-wide or over-tall images
const int32_t k64KLimit = 0x0000FFFF; const int32_t k64KLimit = 0x0000FFFF;
if (MOZ_UNLIKELY(aSize.width > k64KLimit || aSize.height > k64KLimit)) { if (MOZ_UNLIKELY(aSize.width > k64KLimit || aSize.height > k64KLimit)) {

View File

@@ -10,9 +10,8 @@
namespace mozilla { namespace mozilla {
namespace image { namespace image {
/* static */ void SurfaceCacheUtils::DiscardAll() { /* static */
SurfaceCache::DiscardAll(); void SurfaceCacheUtils::DiscardAll() { SurfaceCache::DiscardAll(); }
}
} // namespace image } // namespace image
} // namespace mozilla } // namespace mozilla

View File

@@ -418,8 +418,8 @@ void nsJPEGEncoder::NotifyListener() {
} }
} }
/* static */ void nsJPEGEncoderInternal::initDestination( /* static */
jpeg_compress_struct* cinfo) { void nsJPEGEncoderInternal::initDestination(jpeg_compress_struct* cinfo) {
nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data); nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data);
NS_ASSERTION(!that->mImageBuffer, "Image buffer already initialized"); NS_ASSERTION(!that->mImageBuffer, "Image buffer already initialized");
@@ -431,8 +431,8 @@ void nsJPEGEncoder::NotifyListener() {
cinfo->dest->free_in_buffer = that->mImageBufferSize; cinfo->dest->free_in_buffer = that->mImageBufferSize;
} }
/* static */ boolean nsJPEGEncoderInternal::emptyOutputBuffer( /* static */
jpeg_compress_struct* cinfo) { boolean nsJPEGEncoderInternal::emptyOutputBuffer(jpeg_compress_struct* cinfo) {
nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data); nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data);
NS_ASSERTION(that->mImageBuffer, "No buffer to empty!"); NS_ASSERTION(that->mImageBuffer, "No buffer to empty!");
@@ -467,8 +467,8 @@ void nsJPEGEncoder::NotifyListener() {
return 1; return 1;
} }
/* static */ void nsJPEGEncoderInternal::termDestination( /* static */
jpeg_compress_struct* cinfo) { void nsJPEGEncoderInternal::termDestination(jpeg_compress_struct* cinfo) {
nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data); nsJPEGEncoder* that = static_cast<nsJPEGEncoder*>(cinfo->client_data);
if (!that->mImageBuffer) { if (!that->mImageBuffer) {
return; return;
@@ -479,7 +479,8 @@ void nsJPEGEncoder::NotifyListener() {
that->NotifyListener(); that->NotifyListener();
} }
/* static */ void nsJPEGEncoderInternal::errorExit(jpeg_common_struct* cinfo) { /* static */
void nsJPEGEncoderInternal::errorExit(jpeg_common_struct* cinfo) {
nsresult error_code; nsresult error_code;
encoder_error_mgr* err = (encoder_error_mgr*)cinfo->err; encoder_error_mgr* err = (encoder_error_mgr*)cinfo->err;

View File

@@ -914,7 +914,8 @@ static nsresult NewImageChannel(
return NS_OK; return NS_OK;
} }
/* static */ uint32_t imgCacheEntry::SecondsFromPRTime(PRTime prTime) { /* static */
uint32_t imgCacheEntry::SecondsFromPRTime(PRTime prTime) {
return uint32_t(int64_t(prTime) / int64_t(PR_USEC_PER_SEC)); return uint32_t(int64_t(prTime) / int64_t(PR_USEC_PER_SEC));
} }
@@ -1158,7 +1159,8 @@ NS_IMPL_ISUPPORTS(imgLoader, imgILoader, nsIContentSniffer, imgICache,
static imgLoader* gNormalLoader = nullptr; static imgLoader* gNormalLoader = nullptr;
static imgLoader* gPrivateBrowsingLoader = nullptr; static imgLoader* gPrivateBrowsingLoader = nullptr;
/* static */ already_AddRefed<imgLoader> imgLoader::CreateImageLoader() { /* static */
already_AddRefed<imgLoader> imgLoader::CreateImageLoader() {
// In some cases, such as xpctests, XPCOM modules are not automatically // In some cases, such as xpctests, XPCOM modules are not automatically
// initialized. We need to make sure that our module is initialized before // initialized. We need to make sure that our module is initialized before
// we hand out imgLoader instances and code starts using them. // we hand out imgLoader instances and code starts using them.