PatchCache.h revision 4bb942083a0d4db746adf95349108dd8ef842e32
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/KeyedVector.h> 21 22#include "Patch.h" 23 24namespace android { 25namespace uirenderer { 26 27/////////////////////////////////////////////////////////////////////////////// 28// Defines 29/////////////////////////////////////////////////////////////////////////////// 30 31// Debug 32#define DEBUG_PATCHES 1 33 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 45class PatchCache { 46public: 47 PatchCache(); 48 PatchCache(uint32_t maxCapacity); 49 ~PatchCache(); 50 51 Patch* get(const float bitmapWidth, const float bitmapHeight, 52 const float pixelWidth, const float pixelHeight, 53 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); 55 void clear(); 56 57private: 58 uint32_t mMaxEntries; 59 KeyedVector<PatchDescription, Patch*> mCache; 60}; // class PatchCache 61 62}; // namespace uirenderer 63}; // namespace android 64 65#endif // ANDROID_UI_PATCH_CACHE_H 66