blob: 6dad8314d069698b0da8749bdd504e1bd98fa2b6 [file] [log] [blame]
Romain Guyf7f93552010-07-08 19:17:03 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_UI_PATCH_CACHE_H
18#define ANDROID_UI_PATCH_CACHE_H
19
Romain Guy9aaa8262010-09-08 15:15:43 -070020#include <utils/ResourceTypes.h>
21
Romain Guyf7f93552010-07-08 19:17:03 -070022#include "Patch.h"
23#include "GenerationCache.h"
24
25namespace android {
26namespace uirenderer {
27
28///////////////////////////////////////////////////////////////////////////////
29// Defines
30///////////////////////////////////////////////////////////////////////////////
31
32// Debug
33#define DEBUG_PATCHES 0
34
35// Debug
36#if DEBUG_PATCHES
37 #define PATCH_LOGD(...) LOGD(__VA_ARGS__)
38#else
39 #define PATCH_LOGD(...)
40#endif
41
42///////////////////////////////////////////////////////////////////////////////
43// Cache
44///////////////////////////////////////////////////////////////////////////////
45
46class PatchCache: public OnEntryRemoved<PatchDescription, Patch*> {
47public:
Romain Guyfb8b7632010-08-23 21:05:08 -070048 PatchCache();
Romain Guyf7f93552010-07-08 19:17:03 -070049 PatchCache(uint32_t maxCapacity);
50 ~PatchCache();
51
52 /**
53 * Used as a callback when an entry is removed from the cache.
54 * Do not invoke directly.
55 */
56 void operator()(PatchDescription& description, Patch*& mesh);
57
58 Patch* get(const Res_png_9patch* patch);
59 void clear();
60
61private:
62 GenerationCache<PatchDescription, Patch*> mCache;
63}; // class PatchCache
64
65}; // namespace uirenderer
66}; // namespace android
67
68#endif // ANDROID_UI_PATCH_CACHE_H