michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "MaskLayerImageCache.h" michael@0: #include "ImageContainer.h" michael@0: michael@0: using namespace mozilla::layers; michael@0: michael@0: namespace mozilla { michael@0: michael@0: MaskLayerImageCache::MaskLayerImageCache() michael@0: { michael@0: MOZ_COUNT_CTOR(MaskLayerImageCache); michael@0: } michael@0: MaskLayerImageCache::~MaskLayerImageCache() michael@0: { michael@0: MOZ_COUNT_DTOR(MaskLayerImageCache); michael@0: } michael@0: michael@0: michael@0: /* static */ PLDHashOperator michael@0: MaskLayerImageCache::SweepFunc(MaskLayerImageEntry* aEntry, michael@0: void* aUserArg) michael@0: { michael@0: const MaskLayerImageCache::MaskLayerImageKey* key = aEntry->mKey; michael@0: michael@0: if (key->mLayerCount == 0) { michael@0: return PL_DHASH_REMOVE; michael@0: } michael@0: michael@0: return PL_DHASH_NEXT; michael@0: } michael@0: michael@0: void michael@0: MaskLayerImageCache::Sweep() michael@0: { michael@0: mMaskImageContainers.EnumerateEntries(SweepFunc, nullptr); michael@0: } michael@0: michael@0: ImageContainer* michael@0: MaskLayerImageCache::FindImageFor(const MaskLayerImageKey** aKey) michael@0: { michael@0: if (MaskLayerImageEntry* entry = mMaskImageContainers.GetEntry(**aKey)) { michael@0: *aKey = entry->mKey.get(); michael@0: return entry->mContainer; michael@0: } michael@0: michael@0: return nullptr; michael@0: } michael@0: michael@0: void michael@0: MaskLayerImageCache::PutImage(const MaskLayerImageKey* aKey, ImageContainer* aContainer) michael@0: { michael@0: MaskLayerImageEntry* entry = mMaskImageContainers.PutEntry(*aKey); michael@0: entry->mContainer = aContainer; michael@0: } michael@0: michael@0: }