Replace log2 with SkNextLog2
authorBrian Osman <brianosman@google.com>
Fri, 11 Aug 2017 17:34:02 +0000 (13:34 -0400)
committerMatthew Leibowitz <mattleibow@live.com>
Mon, 14 Aug 2017 18:48:52 +0000 (20:48 +0200)
log2 didn't exist on Android until API 18, and it's doing double
precision math. I think this integer version is what we want?

Bug: skia:
Change-Id: I4909153c56a266688355349cda5d553b69f5c942
Reviewed-on: https://skia-review.googlesource.com/33680
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>

src/gpu/text/GrAtlasGlyphCache.cpp

index 39c3e10..94c8ca7 100644 (file)
@@ -12,6 +12,7 @@
 #include "GrResourceProvider.h"
 #include "GrSurfacePriv.h"
 #include "SkAutoMalloc.h"
+#include "SkMathPriv.h"
 #include "SkString.h"
 
 #include "SkDistanceFieldGen.h"
@@ -39,7 +40,7 @@ bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) {
 GrAtlasGlyphCache::GrAtlasGlyphCache(GrContext* context, float maxTextureBytes)
         : fContext(context), fPreserveStrike(nullptr) {
     // Calculate RGBA size. Must be between 1024 x 512 and MaxTextureSize x MaxTextureSize / 2
-    int log2MaxTextureSize = log2(context->caps()->maxTextureSize());
+    int log2MaxTextureSize = SkPrevLog2(context->caps()->maxTextureSize());
     int log2MaxDim = 10;
     for (; log2MaxDim <= log2MaxTextureSize; ++log2MaxDim) {
         int maxDim = 1 << log2MaxDim;