Romain Guy | f7f9355 | 2010-07-08 19:17:03 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 20 | #include "Patch.h" |
| 21 | #include "GenerationCache.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace uirenderer { |
| 25 | |
| 26 | /////////////////////////////////////////////////////////////////////////////// |
| 27 | // Defines |
| 28 | /////////////////////////////////////////////////////////////////////////////// |
| 29 | |
| 30 | // Debug |
| 31 | #define DEBUG_PATCHES 0 |
| 32 | |
| 33 | // Debug |
| 34 | #if DEBUG_PATCHES |
| 35 | #define PATCH_LOGD(...) LOGD(__VA_ARGS__) |
| 36 | #else |
| 37 | #define PATCH_LOGD(...) |
| 38 | #endif |
| 39 | |
| 40 | /////////////////////////////////////////////////////////////////////////////// |
| 41 | // Cache |
| 42 | /////////////////////////////////////////////////////////////////////////////// |
| 43 | |
| 44 | class PatchCache: public OnEntryRemoved<PatchDescription, Patch*> { |
| 45 | public: |
| 46 | PatchCache(uint32_t maxCapacity); |
| 47 | ~PatchCache(); |
| 48 | |
| 49 | /** |
| 50 | * Used as a callback when an entry is removed from the cache. |
| 51 | * Do not invoke directly. |
| 52 | */ |
| 53 | void operator()(PatchDescription& description, Patch*& mesh); |
| 54 | |
| 55 | Patch* get(const Res_png_9patch* patch); |
| 56 | void clear(); |
| 57 | |
| 58 | private: |
| 59 | GenerationCache<PatchDescription, Patch*> mCache; |
| 60 | }; // class PatchCache |
| 61 | |
| 62 | }; // namespace uirenderer |
| 63 | }; // namespace android |
| 64 | |
| 65 | #endif // ANDROID_UI_PATCH_CACHE_H |