Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: src/core/SkBitmapHeap.cpp

Issue 15070011: One SkTSearch to rule them all. Allow key to be of different type than the array. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fixes to compile on gcc Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapHeap.h ('k') | src/core/SkPathMeasure.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapHeap.cpp
diff --git a/src/core/SkBitmapHeap.cpp b/src/core/SkBitmapHeap.cpp
index 48194b1eaaeba37351dddb4de84b3bbcf4663f2e..f3428db64f13039bdf025d8bb5652c44bff7a229 100644
--- a/src/core/SkBitmapHeap.cpp
+++ b/src/core/SkBitmapHeap.cpp
@@ -38,26 +38,24 @@ void SkBitmapHeapEntry::addReferences(int count) {
///////////////////////////////////////////////////////////////////////////////
-int SkBitmapHeap::LookupEntry::Compare(const SkBitmapHeap::LookupEntry *a,
- const SkBitmapHeap::LookupEntry *b) {
- if (a->fGenerationId < b->fGenerationId) {
- return -1;
- } else if (a->fGenerationId > b->fGenerationId) {
- return 1;
- } else if (a->fPixelOffset < b->fPixelOffset) {
- return -1;
- } else if (a->fPixelOffset > b->fPixelOffset) {
- return 1;
- } else if (a->fWidth < b->fWidth) {
- return -1;
- } else if (a->fWidth > b->fWidth) {
- return 1;
- } else if (a->fHeight < b->fHeight) {
- return -1;
- } else if (a->fHeight > b->fHeight) {
- return 1;
+bool SkBitmapHeap::LookupEntry::Less(const SkBitmapHeap::LookupEntry& a,
+ const SkBitmapHeap::LookupEntry& b) {
+ if (a.fGenerationId < b.fGenerationId) {
+ return true;
+ } else if (a.fGenerationId > b.fGenerationId) {
+ return false;
+ } else if (a.fPixelOffset < b.fPixelOffset) {
+ return true;
+ } else if (a.fPixelOffset > b.fPixelOffset) {
+ return false;
+ } else if (a.fWidth < b.fWidth) {
+ return true;
+ } else if (a.fWidth > b.fWidth) {
+ return false;
+ } else if (a.fHeight < b.fHeight) {
+ return true;
}
- return 0;
+ return false;
}
///////////////////////////////////////////////////////////////////////////////
@@ -231,9 +229,10 @@ size_t SkBitmapHeap::freeMemoryIfPossible(size_t bytesToFree) {
}
int SkBitmapHeap::findInLookupTable(const LookupEntry& indexEntry, SkBitmapHeapEntry** entry) {
- int index = SkTSearch<const LookupEntry>((const LookupEntry**)fLookupTable.begin(),
+ int index = SkTSearch<const LookupEntry, LookupEntry::Less>(
+ (const LookupEntry**)fLookupTable.begin(),
fLookupTable.count(),
- &indexEntry, sizeof(void*), LookupEntry::Compare);
+ &indexEntry, sizeof(void*));
if (index < 0) {
// insert ourselves into the bitmapIndex
« no previous file with comments | « src/core/SkBitmapHeap.h ('k') | src/core/SkPathMeasure.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698