1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "MaskLayerImageCache.h"
9 #include "ImageContainer.h"
10 #include "mozilla/layers/KnowsCompositor.h"
12 using namespace mozilla::layers
;
16 MaskLayerImageCache::MaskLayerImageCache() {
17 MOZ_COUNT_CTOR(MaskLayerImageCache
);
19 MaskLayerImageCache::~MaskLayerImageCache() {
20 MOZ_COUNT_DTOR(MaskLayerImageCache
);
23 void MaskLayerImageCache::Sweep() {
24 for (auto iter
= mMaskImageContainers
.Iter(); !iter
.Done(); iter
.Next()) {
25 const auto& key
= iter
.Get()->mKey
;
26 if (key
->HasZeroLayerCount()) {
32 ImageContainer
* MaskLayerImageCache::FindImageFor(
33 const MaskLayerImageKey
** aKey
) {
34 if (MaskLayerImageEntry
* entry
= mMaskImageContainers
.GetEntry(**aKey
)) {
35 *aKey
= entry
->mKey
.get();
36 return entry
->mContainer
;
42 void MaskLayerImageCache::PutImage(const MaskLayerImageKey
* aKey
,
43 ImageContainer
* aContainer
) {
44 MaskLayerImageEntry
* entry
= mMaskImageContainers
.PutEntry(*aKey
);
45 entry
->mContainer
= aContainer
;
48 MaskLayerImageCache::MaskLayerImageKey::MaskLayerImageKey()
49 : mRoundedClipRects(), mLayerCount(0) {
50 MOZ_COUNT_CTOR(MaskLayerImageKey
);
53 MaskLayerImageCache::MaskLayerImageKey::MaskLayerImageKey(
54 const MaskLayerImageKey
& aKey
)
55 : mRoundedClipRects(aKey
.mRoundedClipRects
.Clone()),
56 mLayerCount(aKey
.mLayerCount
) {
57 MOZ_COUNT_CTOR(MaskLayerImageKey
);
60 MaskLayerImageCache::MaskLayerImageKey::~MaskLayerImageKey() {
61 MOZ_COUNT_DTOR(MaskLayerImageKey
);
64 } // namespace mozilla