a2f4be76a9
BUG=skia: Committed: https://skia.googlesource.com/skia/+/50d2b3114b3e59dc84811881591bf25b2c1ecb9f CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu13.10-GCC4.8-Arm7-Release-Android_Neon-Trybot http://build.chromium.org/p/client.skia.compile/builders/Build-Ubuntu13.10-GCC4.8-Arm7-Release-Android_Neon/builds/2120/steps/build%20most/logs/stdio Review URL: https://codereview.chromium.org/936633002
26 lines
891 B
C++
26 lines
891 B
C++
#include "Benchmark.h"
|
|
#include "SkPMFloat.h"
|
|
#include "SkRandom.h"
|
|
|
|
struct PMFloatBench : public Benchmark {
|
|
explicit PMFloatBench(bool clamp) : fClamp(clamp) {}
|
|
|
|
const char* onGetName() SK_OVERRIDE { return fClamp ? "SkPMFloat_clamp" : "SkPMFloat_get"; }
|
|
bool isSuitableFor(Backend backend) SK_OVERRIDE { return backend == kNonRendering_Backend; }
|
|
|
|
void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
|
|
SkRandom rand;
|
|
for (int i = 0; i < loops; i++) {
|
|
SkPMColor c = SkPreMultiplyColor(rand.nextU());
|
|
SkPMFloat pmf;
|
|
pmf.set(c);
|
|
SkPMColor back = fClamp ? pmf.clamped() : pmf.get();
|
|
if (c != back) { SkFAIL("no joy"); } // This conditional makes this not compile away.
|
|
}
|
|
}
|
|
|
|
bool fClamp;
|
|
};
|
|
DEF_BENCH(return new PMFloatBench( true);)
|
|
DEF_BENCH(return new PMFloatBench(false);)
|