Created
January 18, 2016 18:50
-
-
Save astojilj/5ab88c3fa1650aa18e94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/SkImageCacherator.cpp b/src/core/SkImageCacherator.cpp | |
index 9074924..767900c 100644 | |
--- a/src/core/SkImageCacherator.cpp | |
+++ b/src/core/SkImageCacherator.cpp | |
@@ -81,6 +81,29 @@ static bool check_output_bitmap(const SkBitmap& bitmap, uint32_t expectedID) { | |
return true; | |
} | |
+#define SKGR_DEBUG | |
+#ifdef SKGR_DEBUG | |
+ | |
+#include <android/log.h> | |
+ | |
+#include <time.h> | |
+ | |
+using namespace std; | |
+static double elapsed(timespec start, timespec end) | |
+{ | |
+ return (end.tv_sec-start.tv_sec)*1000 + (end.tv_nsec-start.tv_nsec) * 0.000001; | |
+} | |
+ | |
+#define ELAPSE_START timespec time1, time2; clock_gettime(CLOCK_MONOTONIC, &time1); | |
+ | |
+#define ELAPSE_END(a, ...) clock_gettime(CLOCK_MONOTONIC, &time2); \ | |
+ double elapsedMiliseconds = elapsed(time1, time2); \ | |
+ __android_log_print(ANDROID_LOG_INFO, a, "%s:took %fms for %d*%d colorType %d", __FUNCTION__, elapsedMiliseconds, __VA_ARGS__); | |
+#else | |
+#define ELAPSE_START | |
+#define ELAPSE_END(a, ...) | |
+#endif | |
+ | |
// Note, this returns a new, mutable, bitmap, with a new genID. | |
// If you want the immutable bitmap with the same ID as our cacherator, call tryLockAsBitmap() | |
// | |
@@ -92,7 +115,10 @@ bool SkImageCacherator::generateBitmap(SkBitmap* bitmap) { | |
if (fInfo.dimensions() == genInfo.dimensions()) { | |
SkASSERT(fOrigin.x() == 0 && fOrigin.y() == 0); | |
// fast-case, no copy needed | |
- return generator->tryGenerateBitmap(bitmap, fInfo, allocator); | |
+ ELAPSE_START | |
+ bool returned = generator->tryGenerateBitmap(bitmap, fInfo, allocator); | |
+ ELAPSE_END("GFX", fInfo.width(), fInfo.height(), fInfo.colorType()); | |
+ return returned; | |
} else { | |
// need to handle subsetting, so we first generate the full size version, and then | |
// "read" from it to get our subset. See https://bug.skia.org/4213 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment