PatchCache.h revision 9aaa8269a3e7291aab84d01c3fc9c744d8f2d2f4
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 <utils/ResourceTypes.h> 21 22#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: 48 PatchCache(); 49 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 69