diff options
author | 2013-02-15 12:47:26 -0800 | |
---|---|---|
committer | 2013-02-15 12:47:26 -0800 | |
commit | 13ba0054846ce630ca31e8f26169fd9388faee02 (patch) | |
tree | 2bbd8dbad1fee388dd2e408bf54cc4b5caa46ff3 | |
parent | 00e592272ee44cba41832e3cf0a0ffb2de56585d (diff) |
Remove obsolete header file
We now use the same mechanism to compare keys everywhere in libhwui.
Change-Id: I8b3cb25b13f4f38eb6f12aed0356f796a773617c
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.h | 1 | ||||
-rw-r--r-- | libs/hwui/Matrix.cpp | 1 | ||||
-rw-r--r-- | libs/hwui/Patch.h | 1 | ||||
-rw-r--r-- | libs/hwui/PatchCache.cpp | 31 | ||||
-rw-r--r-- | libs/hwui/PatchCache.h | 44 | ||||
-rw-r--r-- | libs/hwui/utils/Compare.h | 36 |
6 files changed, 52 insertions, 62 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.h b/core/jni/android/graphics/TextLayoutCache.h index 29805ee708f9..6858c0e94a6c 100644 --- a/core/jni/android/graphics/TextLayoutCache.h +++ b/core/jni/android/graphics/TextLayoutCache.h @@ -24,7 +24,6 @@ #include <utils/String16.h> #include <utils/LruCache.h> #include <utils/KeyedVector.h> -#include <utils/Compare.h> #include <utils/RefBase.h> #include <utils/Singleton.h> diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 79fae2b9410d..5cec5a83c9a2 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -24,7 +24,6 @@ #include <SkMatrix.h> -#include "utils/Compare.h" #include "Matrix.h" namespace android { diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h index cab0e540c82c..ee7bf700c355 100644 --- a/libs/hwui/Patch.h +++ b/libs/hwui/Patch.h @@ -25,7 +25,6 @@ #include "Rect.h" #include "Vertex.h" -#include "utils/Compare.h" namespace android { namespace uirenderer { diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp index 8ee8f5c365b2..f48f8572cbc2 100644 --- a/libs/hwui/PatchCache.cpp +++ b/libs/hwui/PatchCache.cpp @@ -42,6 +42,35 @@ PatchCache::~PatchCache() { // Caching /////////////////////////////////////////////////////////////////////////////// +int PatchCache::PatchDescription::compare( + const PatchCache::PatchDescription& lhs, const PatchCache::PatchDescription& rhs) { + int deltaInt = lhs.bitmapWidth - rhs.bitmapWidth; + if (deltaInt != 0) return deltaInt; + + deltaInt = lhs.bitmapHeight - rhs.bitmapHeight; + if (deltaInt != 0) return deltaInt; + + if (lhs.pixelWidth < rhs.pixelWidth) return -1; + if (lhs.pixelWidth > lhs.pixelWidth) return +1; + + if (lhs.pixelHeight < rhs.pixelHeight) return -1; + if (lhs.pixelHeight > lhs.pixelHeight) return +1; + + deltaInt = lhs.xCount - rhs.xCount; + if (deltaInt != 0) return deltaInt; + + deltaInt = lhs.yCount - rhs.yCount; + if (deltaInt != 0) return deltaInt; + + deltaInt = lhs.emptyCount - rhs.emptyCount; + if (deltaInt != 0) return deltaInt; + + deltaInt = lhs.colorKey - rhs.colorKey; + if (deltaInt != 0) return deltaInt; + + return 0; +} + void PatchCache::clear() { size_t count = mCache.size(); for (size_t i = 0; i < count; i++) { @@ -50,7 +79,7 @@ void PatchCache::clear() { mCache.clear(); } -Patch* PatchCache::get(const float bitmapWidth, const float bitmapHeight, +Patch* PatchCache::get(const uint32_t bitmapWidth, const uint32_t bitmapHeight, const float pixelWidth, const float pixelHeight, const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors, const uint32_t width, const uint32_t height, const int8_t numColors) { diff --git a/libs/hwui/PatchCache.h b/libs/hwui/PatchCache.h index 505798aec3a7..0822cba4de35 100644 --- a/libs/hwui/PatchCache.h +++ b/libs/hwui/PatchCache.h @@ -19,7 +19,6 @@ #include <utils/KeyedVector.h> -#include "utils/Compare.h" #include "Debug.h" #include "Patch.h" @@ -47,7 +46,7 @@ public: PatchCache(uint32_t maxCapacity); ~PatchCache(); - Patch* get(const float bitmapWidth, const float bitmapHeight, + Patch* get(const uint32_t bitmapWidth, const uint32_t bitmapHeight, const float pixelWidth, const float pixelHeight, const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors, const uint32_t width, const uint32_t height, const int8_t numColors); @@ -70,7 +69,7 @@ private: xCount(0), yCount(0), emptyCount(0), colorKey(0) { } - PatchDescription(const float bitmapWidth, const float bitmapHeight, + PatchDescription(const uint32_t bitmapWidth, const uint32_t bitmapHeight, const float pixelWidth, const float pixelHeight, const uint32_t xCount, const uint32_t yCount, const int8_t emptyCount, const uint32_t colorKey): @@ -80,28 +79,29 @@ private: 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; + static int compare(const PatchDescription& lhs, const PatchDescription& rhs); + + bool operator==(const PatchDescription& other) const { + return compare(*this, other) == 0; + } + + bool operator!=(const PatchDescription& other) const { + return compare(*this, other) != 0; + } + + friend inline int strictly_order_type(const PatchDescription& lhs, + const PatchDescription& rhs) { + return PatchDescription::compare(lhs, rhs) < 0; + } + + friend inline int compare_type(const PatchDescription& lhs, + const PatchDescription& rhs) { + return PatchDescription::compare(lhs, rhs); } private: - float bitmapWidth; - float bitmapHeight; + uint32_t bitmapWidth; + uint32_t bitmapHeight; float pixelWidth; float pixelHeight; uint32_t xCount; diff --git a/libs/hwui/utils/Compare.h b/libs/hwui/utils/Compare.h deleted file mode 100644 index fdd9acf7a6e3..000000000000 --- a/libs/hwui/utils/Compare.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -#ifndef ANDROID_HWUI_COMPARE_H -#define ANDROID_HWUI_COMPARE_H - -#include <cmath> - -/** - * Compare floats. - */ -#define LTE_FLOAT(a) \ - if (a < rhs.a) return true; \ - if (a == rhs.a) - -/** - * Compare integers. - */ -#define LTE_INT(a) \ - if (a < rhs.a) return true; \ - if (a == rhs.a) - -#endif // ANDROID_HWUI_COMPARE_H |