blob: deba40d88c58e19f0dd32ac6b759cf413937568a [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
Romain Guy5b3b3522010-10-27 18:57:51 -070017#ifndef ANDROID_HWUI_PATCH_CACHE_H
18#define ANDROID_HWUI_PATCH_CACHE_H
Romain Guyf7f93552010-07-08 19:17:03 -070019
Romain Guy2728f962010-10-08 18:36:15 -070020#include <utils/KeyedVector.h>
21
Romain Guyf7f93552010-07-08 19:17:03 -070022#include "Patch.h"
Romain Guyf7f93552010-07-08 19:17:03 -070023
24namespace android {
25namespace uirenderer {
26
27///////////////////////////////////////////////////////////////////////////////
28// Defines
29///////////////////////////////////////////////////////////////////////////////
30
31// Debug
Romain Guy1f114a52010-10-12 17:47:34 -070032#define DEBUG_PATCHES 0
Romain Guyf7f93552010-07-08 19:17:03 -070033
34// Debug
35#if DEBUG_PATCHES
36 #define PATCH_LOGD(...) LOGD(__VA_ARGS__)
37#else
38 #define PATCH_LOGD(...)
39#endif
40
41///////////////////////////////////////////////////////////////////////////////
42// Cache
43///////////////////////////////////////////////////////////////////////////////
44
Romain Guy2728f962010-10-08 18:36:15 -070045class PatchCache {
Romain Guyf7f93552010-07-08 19:17:03 -070046public:
Romain Guyfb8b7632010-08-23 21:05:08 -070047 PatchCache();
Romain Guyf7f93552010-07-08 19:17:03 -070048 PatchCache(uint32_t maxCapacity);
49 ~PatchCache();
50
Romain Guy2728f962010-10-08 18:36:15 -070051 Patch* get(const float bitmapWidth, const float bitmapHeight,
52 const float pixelWidth, const float pixelHeight,
Romain Guy4bb94202010-10-12 15:59:26 -070053 const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors,
54 const uint32_t width, const uint32_t height, const int8_t numColors);
Romain Guyf7f93552010-07-08 19:17:03 -070055 void clear();
56
57private:
Romain Guy2728f962010-10-08 18:36:15 -070058 uint32_t mMaxEntries;
59 KeyedVector<PatchDescription, Patch*> mCache;
Romain Guyf7f93552010-07-08 19:17:03 -070060}; // class PatchCache
61
62}; // namespace uirenderer
63}; // namespace android
64
Romain Guy5b3b3522010-10-27 18:57:51 -070065#endif // ANDROID_HWUI_PATCH_CACHE_H