Fix divide-by-zero in program cache tracking.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 21 Mar 2013 12:46:01 +0000 (12:46 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 21 Mar 2013 12:46:01 +0000 (12:46 +0000)
This also adds tracking to developer builds.

Author: jvanverth@google.com

Reviewed By: robertphillips@google.com

Review URL: https://chromiumcodereview.appspot.com/12426019

git-svn-id: http://skia.googlecode.com/svn/trunk@8284 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/gl/GrGpuGL.h
src/gpu/gl/GrGpuGL_program.cpp

index e589ef2a70f65403b5a218a30ac8dba6ce8262d3..e871f220d5a3e7a5486dcfb7a82635317806b7f1 100644 (file)
@@ -24,7 +24,7 @@
 #include "GrGLVertexBuffer.h"
 #include "../GrTHashCache.h"
 
-#ifdef SK_DEBUG
+#ifdef SK_DEVELOPER
 #define PROGRAM_CACHE_STATS
 #endif
 
index 50810892161eeb2cc8a7b2f000f3f4a7597b5b22..8111a03ca706091180f36f7f9898412b813e16da 100644 (file)
@@ -33,7 +33,8 @@ GrGpuGL::ProgramCache::~ProgramCache() {
     SkDebugf("--- Program Cache ---\n");
     SkDebugf("Total requests: %d\n", fTotalRequests);
     SkDebugf("Cache misses: %d\n", fCacheMisses);
-    SkDebugf("Cache miss %%: %f\n", (float)fCacheMisses/(float)fTotalRequests);
+    SkDebugf("Cache miss %%: %f\n", (fTotalRequests > 0) 
+                                    ? (float)fCacheMisses/(float)fTotalRequests : 0.0f);
     SkDebugf("---------------------\n");
 #endif
 }