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

Unified Diff: src/gpu/gl/GrGLCaps.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/gpu/effects/GrTextureStripAtlas.cpp ('k') | src/gpu/gl/GrGLExtensions.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLCaps.cpp
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 5568c48123834ca6328bd207240f586c2adfc6e5..8b296e360bfd5f5c61dc7b2b82e17d3b8bb7b899 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -9,6 +9,7 @@
#include "GrGLCaps.h"
#include "GrGLContext.h"
#include "SkTSearch.h"
+#include "SkTSort.h"
SK_DEFINE_INST_COUNT(GrGLCaps)
@@ -335,18 +336,16 @@ bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
}
namespace {
-int coverage_mode_compare(const GrGLCaps::MSAACoverageMode* left,
- const GrGLCaps::MSAACoverageMode* right) {
- if (left->fCoverageSampleCnt < right->fCoverageSampleCnt) {
- return -1;
- } else if (right->fCoverageSampleCnt < left->fCoverageSampleCnt) {
- return 1;
- } else if (left->fColorSampleCnt < right->fColorSampleCnt) {
- return -1;
- } else if (right->fColorSampleCnt < left->fColorSampleCnt) {
- return 1;
+bool cov_mode_less(const GrGLCaps::MSAACoverageMode& left,
+ const GrGLCaps::MSAACoverageMode& right) {
+ if (left.fCoverageSampleCnt < right.fCoverageSampleCnt) {
+ return true;
+ } else if (right.fCoverageSampleCnt < left.fCoverageSampleCnt) {
+ return false;
+ } else if (left.fColorSampleCnt < right.fColorSampleCnt) {
+ return true;
}
- return 0;
+ return false;
}
}
@@ -389,10 +388,11 @@ void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
(int*)&fMSAACoverageModes[0]);
// The NV driver seems to return the modes already sorted but the
// spec doesn't require this. So we sort.
- qsort(&fMSAACoverageModes[0],
- count,
- sizeof(MSAACoverageMode),
- SkCastForQSort(coverage_mode_compare));
+ typedef SkTLessFunctionToFunctorAdaptor<MSAACoverageMode, cov_mode_less> SortFunctor;
+ SortFunctor sortFunctor;
+ SkTQSort<MSAACoverageMode, SortFunctor>(fMSAACoverageModes.begin(),
+ fMSAACoverageModes.end() - 1,
+ sortFunctor);
}
}
}
@@ -406,11 +406,10 @@ const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampl
int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt;
desiredSampleCount = GrMin(desiredSampleCount, max);
MSAACoverageMode desiredMode = {desiredSampleCount, 0};
- int idx = SkTSearch<MSAACoverageMode>(&fMSAACoverageModes[0],
- fMSAACoverageModes.count(),
- desiredMode,
- sizeof(MSAACoverageMode),
- &coverage_mode_compare);
+ int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverageModes[0],
+ fMSAACoverageModes.count(),
+ desiredMode,
+ sizeof(MSAACoverageMode));
if (idx < 0) {
idx = ~idx;
}
« no previous file with comments | « src/gpu/effects/GrTextureStripAtlas.cpp ('k') | src/gpu/gl/GrGLExtensions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698