2010-07-08 19:17:03 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#ifndef ANDROID_HWUI_PATCH_CACHE_H
|
|
|
|
#define ANDROID_HWUI_PATCH_CACHE_H
|
2010-07-08 19:17:03 -07:00
|
|
|
|
2010-10-08 18:36:15 -07:00
|
|
|
#include <utils/KeyedVector.h>
|
|
|
|
|
2010-12-10 12:33:05 -08:00
|
|
|
#include "utils/Compare.h"
|
2010-11-10 11:59:15 -08:00
|
|
|
#include "Debug.h"
|
2010-07-08 19:17:03 -07:00
|
|
|
#include "Patch.h"
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Defines
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Debug
|
|
|
|
#if DEBUG_PATCHES
|
2011-12-20 16:23:08 +00:00
|
|
|
#define PATCH_LOGD(...) ALOGD(__VA_ARGS__)
|
2010-07-08 19:17:03 -07:00
|
|
|
#else
|
|
|
|
#define PATCH_LOGD(...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Cache
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-10-08 18:36:15 -07:00
|
|
|
class PatchCache {
|
2010-07-08 19:17:03 -07:00
|
|
|
public:
|
2010-08-23 21:05:08 -07:00
|
|
|
PatchCache();
|
2010-07-08 19:17:03 -07:00
|
|
|
PatchCache(uint32_t maxCapacity);
|
|
|
|
~PatchCache();
|
|
|
|
|
2010-10-08 18:36:15 -07:00
|
|
|
Patch* get(const float bitmapWidth, const float bitmapHeight,
|
|
|
|
const float pixelWidth, const float pixelHeight,
|
2010-10-12 15:59:26 -07:00
|
|
|
const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors,
|
|
|
|
const uint32_t width, const uint32_t height, const int8_t numColors);
|
2010-07-08 19:17:03 -07:00
|
|
|
void clear();
|
|
|
|
|
2010-11-10 11:59:15 -08:00
|
|
|
uint32_t getSize() const {
|
|
|
|
return mCache.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t getMaxSize() const {
|
|
|
|
return mMaxEntries;
|
|
|
|
}
|
|
|
|
|
2010-07-08 19:17:03 -07:00
|
|
|
private:
|
2010-11-30 12:04:14 -08:00
|
|
|
/**
|
|
|
|
* Description of a patch.
|
|
|
|
*/
|
|
|
|
struct PatchDescription {
|
|
|
|
PatchDescription(): bitmapWidth(0), bitmapHeight(0), pixelWidth(0), pixelHeight(0),
|
|
|
|
xCount(0), yCount(0), emptyCount(0), colorKey(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
PatchDescription(const float bitmapWidth, const float bitmapHeight,
|
|
|
|
const float pixelWidth, const float pixelHeight,
|
|
|
|
const uint32_t xCount, const uint32_t yCount,
|
|
|
|
const int8_t emptyCount, const uint32_t colorKey):
|
|
|
|
bitmapWidth(bitmapWidth), bitmapHeight(bitmapHeight),
|
|
|
|
pixelWidth(pixelWidth), pixelHeight(pixelHeight),
|
|
|
|
xCount(xCount), yCount(yCount),
|
|
|
|
emptyCount(emptyCount), colorKey(colorKey) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const PatchDescription& rhs) const {
|
|
|
|
LTE_FLOAT(bitmapWidth) {
|
|
|
|
LTE_FLOAT(bitmapHeight) {
|
|
|
|
LTE_FLOAT(pixelWidth) {
|
|
|
|
LTE_FLOAT(pixelHeight) {
|
|
|
|
LTE_INT(xCount) {
|
|
|
|
LTE_INT(yCount) {
|
|
|
|
LTE_INT(emptyCount) {
|
|
|
|
LTE_INT(colorKey) return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
float bitmapWidth;
|
|
|
|
float bitmapHeight;
|
|
|
|
float pixelWidth;
|
|
|
|
float pixelHeight;
|
|
|
|
uint32_t xCount;
|
|
|
|
uint32_t yCount;
|
|
|
|
int8_t emptyCount;
|
|
|
|
uint32_t colorKey;
|
|
|
|
|
|
|
|
}; // struct PatchDescription
|
|
|
|
|
2010-10-08 18:36:15 -07:00
|
|
|
uint32_t mMaxEntries;
|
|
|
|
KeyedVector<PatchDescription, Patch*> mCache;
|
2010-11-30 12:04:14 -08:00
|
|
|
|
2010-07-08 19:17:03 -07:00
|
|
|
}; // class PatchCache
|
|
|
|
|
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#endif // ANDROID_HWUI_PATCH_CACHE_H
|