PatchCache.h revision fb8b763f762ae21923c58d64caa729b012f40e05
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 23namespace android { 24namespace 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 44class PatchCache: public OnEntryRemoved<PatchDescription, Patch*> { 45public: 46 PatchCache(); 47 PatchCache(uint32_t maxCapacity); 48 ~PatchCache(); 49 50 /** 51 * Used as a callback when an entry is removed from the cache. 52 * Do not invoke directly. 53 */ 54 void operator()(PatchDescription& description, Patch*& mesh); 55 56 Patch* get(const Res_png_9patch* patch); 57 void clear(); 58 59private: 60 GenerationCache<PatchDescription, Patch*> mCache; 61}; // class PatchCache 62 63}; // namespace uirenderer 64}; // namespace android 65 66#endif // ANDROID_UI_PATCH_CACHE_H 67