blob: 42328f425500d9adcc578df5dc55bced7a934882 [file] [log] [blame]
Romain Guyce0537b2010-06-29 21:05:21 -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_TEXTURE_CACHE_H
18#define ANDROID_UI_TEXTURE_CACHE_H
19
20#include <SkBitmap.h>
21
22#include "Texture.h"
23#include "GenerationCache.h"
24
25namespace android {
26namespace uirenderer {
27
28class TextureCache: public OnEntryRemoved<SkBitmap*, Texture*> {
29public:
30 TextureCache(unsigned int maxEntries);
31 ~TextureCache();
32
33 void operator()(SkBitmap* key, Texture* value);
34
35 Texture* get(SkBitmap* bitmap);
36 Texture* remove(SkBitmap* bitmap);
37 void clear();
38
39private:
40 Texture* generateTexture(SkBitmap* bitmap);
41
42 GenerationCache<SkBitmap, Texture> mCache;
43}; // class TextureCache
44
45}; // namespace uirenderer
46}; // namespace android
47
48#endif // ANDROID_UI_TEXTURE_CACHE_H