Index: bench/nanobench.cpp |
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp |
index eb48ec228d6b35886d6c8a87cd5e1c344f9479e3..f2b8d699f944c5f5e078c9b1c253a1a7dda80a62 100644 |
--- a/bench/nanobench.cpp |
+++ b/bench/nanobench.cpp |
@@ -9,10 +9,12 @@ |
#include "Benchmark.h" |
#include "CrashHandler.h" |
+#include "DecodingBench.h" |
#include "GMBench.h" |
#include "ProcStats.h" |
#include "ResultsWriter.h" |
#include "RecordingBench.h" |
+#include "Resources.h" |
#include "SKPBench.h" |
#include "Stats.h" |
#include "Timer.h" |
@@ -29,6 +31,8 @@ |
#include "SkSurface.h" |
#include "SkTaskGroup.h" |
+#include <stdio.h> |
+ |
msarett
2015/02/11 21:57:01
I will remove this. I was using it to debug and i
mtklein
2015/02/12 00:29:34
One day you will find yourself typing SkDebugf acc
msarett
2015/02/12 18:52:56
:)
|
#if SK_SUPPORT_GPU |
#include "gl/GrGLDefines.h" |
#include "GrContextFactory.h" |
@@ -439,7 +443,9 @@ public: |
, fCurrentRecording(0) |
, fCurrentScale(0) |
, fCurrentSKP(0) |
- , fCurrentUseMPD(0) { |
+ , fCurrentUseMPD(0) |
+ , fCurrentImage(0) |
+ , fCurrentColorType(0) { |
for (int i = 0; i < FLAGS_skps.count(); i++) { |
if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
fSKPs.push_back() = FLAGS_skps[i]; |
@@ -469,6 +475,28 @@ public: |
if (FLAGS_mpd) { |
fUseMPDs.push_back() = true; |
} |
+ |
+ // Prepare the images for decoding |
+ for (int i = 0; i < FLAGS_images.count(); i++) { |
+ const char* flag = FLAGS_images[i]; |
+ // If the value passed in is a directory, add all the images |
+ if (sk_isdir(flag)) { |
+ SkOSFile::Iter it(flag); |
+ SkString file; |
+ while (it.next(&file)) { |
+ fImages.push_back() = SkOSPath::Join(flag, file.c_str()); |
+ } |
+ } |
+ // Also add the value if it is a single image |
+ else if (sk_exists(flag)) { |
scroggo
2015/02/12 14:19:02
This should go on the same line as the closing bra
msarett
2015/02/12 18:52:56
Done.
|
+ fImages.push_back() = flag; |
+ } |
+ } |
+ |
+ // Choose the candidate color types for image decoding |
+ SkColorType colorTypes[] = |
+ { kN32_SkColorType, kRGB_565_SkColorType, kAlpha_8_SkColorType }; |
_cary
2015/02/12 15:18:05
make this const
msarett
2015/02/12 18:52:56
Done.
|
+ fColorTypes.push_back_n(SK_ARRAY_COUNT(colorTypes), colorTypes); |
} |
static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { |
@@ -562,6 +590,24 @@ public: |
fCurrentScale++; |
} |
+ // Run the DecodingBenches |
+ SkString file; |
+ while (fCurrentImage < fImages.count()) { |
+ while (fCurrentColorType < fColorTypes.count()) { |
+ SkString path = fImages[fCurrentImage]; |
_cary
2015/02/12 15:18:05
const SkString& path
msarett
2015/02/12 18:52:56
Done.
|
+ SkColorType colorType = fColorTypes[fCurrentColorType]; |
+ fCurrentColorType++; |
+ // Check if the image decodes before creating the benchmark |
+ SkBitmap bitmap; |
+ if (SkImageDecoder::DecodeFile(path.c_str(), &bitmap, |
+ colorType, SkImageDecoder::kDecodePixels_Mode)) { |
+ return SkNEW_ARGS(DecodingBench, (path, colorType)); |
+ } |
+ } |
+ fCurrentColorType = 0; |
+ fCurrentImage++; |
+ } |
+ |
return NULL; |
} |
@@ -591,6 +637,8 @@ private: |
SkTArray<SkScalar> fScales; |
SkTArray<SkString> fSKPs; |
SkTArray<bool> fUseMPDs; |
+ SkTArray<SkString> fImages; |
+ SkTArray<SkColorType> fColorTypes; |
double fSKPBytes, fSKPOps; |
@@ -600,6 +648,8 @@ private: |
int fCurrentScale; |
int fCurrentSKP; |
int fCurrentUseMPD; |
+ int fCurrentImage; |
+ int fCurrentColorType; |
}; |
int nanobench_main(); |