PatchCache.h revision c15008e72ec00ca20a271c3006dac649fd07533b
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_HWUI_PATCH_CACHE_H 18#define ANDROID_HWUI_PATCH_CACHE_H 19 20#include <utils/KeyedVector.h> 21 22#include "Debug.h" 23#include "Patch.h" 24 25namespace android { 26namespace uirenderer { 27 28/////////////////////////////////////////////////////////////////////////////// 29// Defines 30/////////////////////////////////////////////////////////////////////////////// 31 32// Debug 33#if DEBUG_PATCHES 34 #define PATCH_LOGD(...) LOGD(__VA_ARGS__) 35#else 36 #define PATCH_LOGD(...) 37#endif 38 39/////////////////////////////////////////////////////////////////////////////// 40// Cache 41/////////////////////////////////////////////////////////////////////////////// 42 43class PatchCache { 44public: 45 PatchCache(); 46 PatchCache(uint32_t maxCapacity); 47 ~PatchCache(); 48 49 Patch* get(const float bitmapWidth, const float bitmapHeight, 50 const float pixelWidth, const float pixelHeight, 51 const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors, 52 const uint32_t width, const uint32_t height, const int8_t numColors); 53 void clear(); 54 55 uint32_t getSize() const { 56 return mCache.size(); 57 } 58 59 uint32_t getMaxSize() const { 60 return mMaxEntries; 61 } 62 63private: 64 uint32_t mMaxEntries; 65 KeyedVector<PatchDescription, Patch*> mCache; 66}; // class PatchCache 67 68}; // namespace uirenderer 69}; // namespace android 70 71#endif // ANDROID_HWUI_PATCH_CACHE_H 72