Commit 0a657bbc authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Snapshot from http://skia.googlecode.com/svn/trunk@12108

Change-Id: Ia710b27d97e938df06014b7b61a3767bd3be1eb5
parent e27eefc4

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -14,7 +14,7 @@ deps = {
"third_party/externals/angle" : "https://chromium.googlesource.com/external/angleproject.git@e574e26f48223a6718feab841b4a7720785b497a",
"third_party/externals/fontconfig" : "https://skia.googlesource.com/third_party/fontconfig.git@2.10.93",
"third_party/externals/freetype" : "https://skia.googlesource.com/third_party/freetype2.git@VER-2-5-0-1",
"third_party/externals/gyp" : "https://chromium.googlesource.com/external/gyp.git@e5179456241c17cb6cdd106e4744882d32081df5",
"third_party/externals/gyp" : "https://chromium.googlesource.com/external/gyp.git@0635a6e266eb4cdd01e942331997f76b3737be79",
"third_party/externals/iconv" : "https://skia.googlesource.com/third_party/libiconv.git@v1.14",
"third_party/externals/libjpeg" : "https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@82ce8a6d4ebe12a177c0c3597192f2b4f09e81c3",
"third_party/externals/jsoncpp" : "https://chromium.googlesource.com/external/jsoncpp/jsoncpp.git@ab1e40f3bce061ea6f9bdc60351d6cde2a4f872b",
......
......@@ -48,6 +48,7 @@ VALID_TARGETS := \
SampleApp_APK \
skhello \
skia_lib \
skpskgr_test \
tests \
tools \
skpdiff
......
......@@ -33,8 +33,6 @@ else
DEFINES += -DSK_RELEASE -DGR_DEBUG=0
endif
DEFINES += -DGR_IMPLEMENTATION=1
ifneq ($(SKIA_PDF_SUPPORT),false)
DEFINES += -DSK_SUPPORT_PDF
DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>"
......@@ -134,7 +132,7 @@ ifeq ($(SKIA_BUILD_FOR),mac)
else
LINKER_OPTS += -lpng -lfreetype -lrt
DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1
DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG
ifeq ($(SKIA_MESA),true)
LINKER_OPTS += -lOSMesa -lGLU
DEFINES += -DSK_MESA
......
reed@google.com
bsalomon@google.com
Name: skia
URL: http://code.google.com/p/skia
Version: unknown
Security Critical: yes
License: BSD
......@@ -23,14 +23,9 @@ class AAClipBench : public SkBenchmark {
bool fDoPath;
bool fDoAA;
enum {
N = SkBENCHLOOP(200),
};
public:
AAClipBench(void* param, bool doPath, bool doAA)
: INHERITED(param)
, fDoPath(doPath)
AAClipBench(bool doPath, bool doAA)
: fDoPath(doPath)
, fDoAA(doAA) {
fName.printf("aaclip_%s_%s",
......@@ -53,7 +48,7 @@ protected:
SkPaint paint;
this->setupPaint(&paint);
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
// jostle the clip regions each time to prevent caching
fClipRect.offset((i % 2) == 0 ? SkIntToScalar(10) : SkIntToScalar(-10), 0);
fClipPath.reset();
......@@ -96,17 +91,13 @@ class NestedAAClipBench : public SkBenchmark {
SkRect fDrawRect;
SkRandom fRandom;
static const int kNumDraws = SkBENCHLOOP(2);
static const int kNestingDepth = 3;
static const int kImageSize = 400;
SkPoint fSizes[kNestingDepth+1];
public:
NestedAAClipBench(void* param, bool doAA)
: INHERITED(param)
, fDoAA(doAA) {
NestedAAClipBench(bool doAA) : fDoAA(doAA) {
fName.printf("nested_aaclip_%s", doAA ? "AA" : "BW");
fDrawRect = SkRect::MakeLTRB(0, 0,
......@@ -169,7 +160,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
for (int i = 0; i < kNumDraws; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
SkPoint offset = SkPoint::Make(0, 0);
this->recurse(canvas, 0, offset);
}
......@@ -188,12 +179,8 @@ class AAClipBuilderBench : public SkBenchmark {
bool fDoPath;
bool fDoAA;
enum {
N = SkBENCHLOOP(200),
};
public:
AAClipBuilderBench(void* param, bool doPath, bool doAA) : INHERITED(param) {
AAClipBuilderBench(bool doPath, bool doAA) {
fDoPath = doPath;
fDoAA = doAA;
......@@ -212,7 +199,7 @@ protected:
SkPaint paint;
this->setupPaint(&paint);
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
SkAAClip clip;
if (fDoPath) {
clip.setPath(fPath, &fRegion, fDoAA);
......@@ -228,7 +215,7 @@ private:
////////////////////////////////////////////////////////////////////////////////
class AAClipRegionBench : public SkBenchmark {
public:
AAClipRegionBench(void* param) : INHERITED(param) {
AAClipRegionBench() {
SkPath path;
// test conversion of a complex clip to a aaclip
path.addCircle(0, 0, SkIntToScalar(200));
......@@ -244,47 +231,27 @@ public:
protected:
virtual const char* onGetName() { return "aaclip_setregion"; }
virtual void onDraw(SkCanvas*) {
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
SkAAClip clip;
clip.setRegion(fRegion);
}
}
private:
enum {
N = SkBENCHLOOP(400),
};
SkRegion fRegion;
typedef SkBenchmark INHERITED;
};
////////////////////////////////////////////////////////////////////////////////
static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, false)); }
static SkBenchmark* Fact1(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, false, true)); }
static SkBenchmark* Fact2(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, false)); }
static SkBenchmark* Fact3(void* p) { return SkNEW_ARGS(AAClipBuilderBench, (p, true, true)); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
static BenchRegistry gReg2(Fact2);
static BenchRegistry gReg3(Fact3);
static SkBenchmark* Fact01(void* p) { return SkNEW_ARGS(AAClipRegionBench, (p)); }
static BenchRegistry gReg01(Fact01);
static SkBenchmark* Fact000(void* p) { return SkNEW_ARGS(AAClipBench, (p, false, false)); }
static SkBenchmark* Fact001(void* p) { return SkNEW_ARGS(AAClipBench, (p, false, true)); }
static SkBenchmark* Fact002(void* p) { return SkNEW_ARGS(AAClipBench, (p, true, false)); }
static SkBenchmark* Fact003(void* p) { return SkNEW_ARGS(AAClipBench, (p, true, true)); }
static BenchRegistry gReg000(Fact000);
static BenchRegistry gReg001(Fact001);
static BenchRegistry gReg002(Fact002);
static BenchRegistry gReg003(Fact003);
static SkBenchmark* Fact004(void* p) { return SkNEW_ARGS(NestedAAClipBench, (p, false)); }
static SkBenchmark* Fact005(void* p) { return SkNEW_ARGS(NestedAAClipBench, (p, true)); }
static BenchRegistry gReg004(Fact004);
static BenchRegistry gReg005(Fact005);
DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, false)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (false, true)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, false)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBuilderBench, (true, true)); )
DEF_BENCH( return SkNEW_ARGS(AAClipRegionBench, ()); )
DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, false)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBench, (false, true)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, false)); )
DEF_BENCH( return SkNEW_ARGS(AAClipBench, (true, true)); )
DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (false)); )
DEF_BENCH( return SkNEW_ARGS(NestedAAClipBench, (true)); )
......@@ -7,7 +7,6 @@
#include "SkBenchmark.h"
#include "SkCanvas.h"
#include "SkRandom.h"
#include "SkShader.h"
#include "SkString.h"
#include "SkBicubicImageFilter.h"
......@@ -20,10 +19,10 @@ class BicubicBench : public SkBenchmark {
SkString fName;
public:
BicubicBench(void* param, float x, float y)
: INHERITED(param), fScale(SkSize::Make(SkFloatToScalar(x), SkFloatToScalar(y))) {
BicubicBench(float x, float y)
: fScale(SkSize::Make(SkFloatToScalar(x), SkFloatToScalar(y))) {
fName.printf("bicubic_%gx%g",
SkScalarToFloat(fScale.fWidth), SkScalarToFloat(fScale.fHeight));
SkScalarToFloat(fScale.fWidth), SkScalarToFloat(fScale.fHeight));
}
protected:
......@@ -37,26 +36,23 @@ protected:
paint.setAntiAlias(true);
SkRandom rand;
SkRect r = SkRect::MakeWH(40, 40);
SkAutoTUnref<SkImageFilter> bicubic(SkBicubicImageFilter::CreateMitchell(fScale));
paint.setImageFilter(bicubic);
canvas->save();
canvas->clipRect(r);
canvas->drawOval(r, paint);
canvas->restore();
for (int i = 0; i < this->getLoops(); i++) {
canvas->save();
canvas->clipRect(r);
canvas->drawOval(r, paint);
canvas->restore();
}
}
private:
typedef SkBenchmark INHERITED;
};
static SkBenchmark* Fact00(void* p) { return new BicubicBench(p, 10.0f, 10.0f); }
static SkBenchmark* Fact01(void* p) { return new BicubicBench(p, 2.5f, 10.0f); }
static SkBenchmark* Fact02(void* p) { return new BicubicBench(p, 10.0f, 2.5f); }
static SkBenchmark* Fact03(void* p) { return new BicubicBench(p, 2.5f, 2.5f); }
static BenchRegistry gReg00(Fact00);
static BenchRegistry gReg01(Fact01);
static BenchRegistry gReg02(Fact02);
static BenchRegistry gReg03(Fact03);
DEF_BENCH( return new BicubicBench(10.0f, 10.0f); )
DEF_BENCH( return new BicubicBench(2.5f, 10.0f); )
DEF_BENCH( return new BicubicBench(10.0f, 2.5f); )
DEF_BENCH( return new BicubicBench(2.5f, 2.5f); )
......@@ -33,9 +33,9 @@ static uint8_t compute666Index(SkPMColor c) {
return convByteTo6(r) * 36 + convByteTo6(g) * 6 + convByteTo6(b);
}
static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
SkColorTable* ctable = new SkColorTable(216);
SkPMColor* colors = ctable->lockColors();
static void convertToIndex666(const SkBitmap& src, SkBitmap* dst, bool isOpaque) {
SkPMColor storage[216];
SkPMColor* colors = storage;
// rrr ggg bbb
for (int r = 0; r < 6; r++) {
int rr = conv6ToByte(r);
......@@ -47,7 +47,8 @@ static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
}
}
}
ctable->unlockColors(true);
SkColorTable* ctable = new SkColorTable(storage, 216,
isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height());
dst->allocPixels(ctable);
ctable->unref();
......@@ -81,15 +82,12 @@ class BitmapBench : public SkBenchmark {
bool fIsVolatile;
SkBitmap::Config fConfig;
SkString fName;
enum { BICUBIC_DUR_SCALE = 20 };
enum { N = SkBENCHLOOP(15 * BICUBIC_DUR_SCALE) };
enum { W = 128 };
enum { H = 128 };
public:
BitmapBench(void* param, bool isOpaque, SkBitmap::Config c,
BitmapBench(bool isOpaque, SkBitmap::Config c,
bool forceUpdate = false, bool bitmapVolatile = false)
: INHERITED(param)
, fIsOpaque(isOpaque)
: fIsOpaque(isOpaque)
, fForceUpdate(forceUpdate)
, fIsVolatile(bitmapVolatile)
, fConfig(c) {
......@@ -123,15 +121,12 @@ protected:
onDrawIntoBitmap(bm);
if (SkBitmap::kIndex8_Config == fConfig) {
convertToIndex666(bm, &fBitmap);
convertToIndex666(bm, &fBitmap, fIsOpaque);
} else {
fBitmap = bm;
}
if (fBitmap.getColorTable()) {
fBitmap.getColorTable()->setIsOpaque(fIsOpaque);
}
fBitmap.setIsOpaque(fIsOpaque);
fBitmap.setAlphaType(fIsOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
fBitmap.setIsVolatile(fIsVolatile);
}
......@@ -146,14 +141,7 @@ protected:
const SkScalar x0 = SkIntToScalar(-bitmap.width() / 2);
const SkScalar y0 = SkIntToScalar(-bitmap.height() / 2);
int count = N;
#ifdef SK_RELEASE
// in DEBUG, N is always 1
if (SkPaint::kHigh_FilterLevel == paint.getFilterLevel()) {
count /= BICUBIC_DUR_SCALE;
}
#endif
for (int i = 0; i < count; i++) {
for (int i = 0; i < this->getLoops(); i++) {
SkScalar x = x0 + rand.nextUScalar1() * dim.fX;
SkScalar y = y0 + rand.nextUScalar1() * dim.fY;
......@@ -164,17 +152,6 @@ protected:
}
}
virtual float onGetDurationScale() SK_OVERRIDE {
SkPaint paint;
this->setupPaint(&paint);
#ifdef SK_DEBUG
return 1;
#else
return SkPaint::kHigh_FilterLevel == paint.getFilterLevel() ?
(float)BICUBIC_DUR_SCALE : 1;
#endif
}
virtual void onDrawIntoBitmap(const SkBitmap& bm) {
const int w = bm.width();
const int h = bm.height();
......@@ -219,11 +196,10 @@ static bool isBicubic(uint32_t flags) {
class FilterBitmapBench : public BitmapBench {
uint32_t fFlags;
SkString fFullName;
enum { N = SkBENCHLOOP(300) };
public:
FilterBitmapBench(void* param, bool isOpaque, SkBitmap::Config c,
FilterBitmapBench(bool isOpaque, SkBitmap::Config c,
bool forceUpdate, bool isVolitile, uint32_t flags)
: INHERITED(param, isOpaque, c, forceUpdate, isVolitile)
: INHERITED(isOpaque, c, forceUpdate, isVolitile)
, fFlags(flags) {
}
......@@ -300,9 +276,9 @@ private:
SkString fFullName;
SourceAlpha fSourceAlpha;
public:
SourceAlphaBitmapBench(void* param, SourceAlpha alpha, SkBitmap::Config c,
SourceAlphaBitmapBench(SourceAlpha alpha, SkBitmap::Config c,
bool forceUpdate = false, bool bitmapVolatile = false)
: INHERITED(param, false, c, forceUpdate, bitmapVolatile)
: INHERITED(false, c, forceUpdate, bitmapVolatile)
, fSourceAlpha(alpha) {
}
......@@ -379,31 +355,31 @@ private:
typedef BitmapBench INHERITED;
};
DEF_BENCH( return new BitmapBench(p, false, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new BitmapBench(p, true, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new BitmapBench(p, true, SkBitmap::kRGB_565_Config); )
DEF_BENCH( return new BitmapBench(p, false, SkBitmap::kIndex8_Config); )
DEF_BENCH( return new BitmapBench(p, true, SkBitmap::kIndex8_Config); )
DEF_BENCH( return new BitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, true); )
DEF_BENCH( return new BitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, false); )
DEF_BENCH( return new BitmapBench(false, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new BitmapBench(true, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new BitmapBench(true, SkBitmap::kRGB_565_Config); )
DEF_BENCH( return new BitmapBench(false, SkBitmap::kIndex8_Config); )
DEF_BENCH( return new BitmapBench(true, SkBitmap::kIndex8_Config); )
DEF_BENCH( return new BitmapBench(true, SkBitmap::kARGB_8888_Config, true, true); )
DEF_BENCH( return new BitmapBench(true, SkBitmap::kARGB_8888_Config, true, false); )
// scale filter -> S32_opaque_D32_filter_DX_{SSE2,SSSE3} and Fact9 is also for S32_D16_filter_DX_SSE2
DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, true, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, true, kScale_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kBilerp_Flag); )
// scale rotate filter -> S32_opaque_D32_filter_DXDY_{SSE2,SSSE3}
DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, true, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, true, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(true, SkBitmap::kARGB_8888_Config, true, false, kScale_Flag | kRotate_Flag | kBilerp_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); )
DEF_BENCH( return new FilterBitmapBench(p, false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); )
DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kBilerp_Flag | kBicubic_Flag); )
DEF_BENCH( return new FilterBitmapBench(false, SkBitmap::kARGB_8888_Config, false, false, kScale_Flag | kRotate_Flag | kBilerp_Flag | kBicubic_Flag); )
// source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon}
DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kOpaque_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTransparent_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTwoStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kThreeStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kOpaque_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTransparent_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kTwoStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new SourceAlphaBitmapBench(SourceAlphaBitmapBench::kThreeStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); )
......@@ -39,19 +39,20 @@ static void draw_into_bitmap(const SkBitmap& bm) {
*/
class BitmapRectBench : public SkBenchmark {
SkBitmap fBitmap;
bool fDoFilter;
bool fSlightMatrix;
uint8_t fAlpha;
SkString fName;
SkRect fSrcR, fDstR;
SkBitmap fBitmap;
bool fSlightMatrix;
uint8_t fAlpha;
SkPaint::FilterLevel fFilterLevel;
SkString fName;
SkRect fSrcR, fDstR;
static const int kWidth = 128;
static const int kHeight = 128;
enum { N = SkBENCHLOOP(300) };
public:
BitmapRectBench(void* param, U8CPU alpha, bool doFilter, bool slightMatrix) : INHERITED(param) {
BitmapRectBench(U8CPU alpha, SkPaint::FilterLevel filterLevel,
bool slightMatrix) {
fAlpha = SkToU8(alpha);
fDoFilter = doFilter;
fFilterLevel = filterLevel;
fSlightMatrix = slightMatrix;
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, kWidth, kHeight);
......@@ -60,14 +61,15 @@ public:
protected:
virtual const char* onGetName() SK_OVERRIDE {
fName.printf("bitmaprect_%02X_%sfilter_%s",
fAlpha, fDoFilter ? "" : "no",
fAlpha,
SkPaint::kNone_FilterLevel == fFilterLevel ? "no" : "",
fSlightMatrix ? "trans" : "identity");
return fName.c_str();
}
virtual void onPreDraw() SK_OVERRIDE {
fBitmap.allocPixels();
fBitmap.setIsOpaque(true);
fBitmap.setAlphaType(kOpaque_SkAlphaType);
fBitmap.eraseColor(SK_ColorBLACK);
draw_into_bitmap(fBitmap);
......@@ -90,10 +92,10 @@ protected:
SkPaint paint;
this->setupPaint(&paint);
paint.setFilterBitmap(fDoFilter);
paint.setFilterLevel(fFilterLevel);
paint.setAlpha(fAlpha);
for (int i = 0; i < N; i++) {
for (int i = 0; i < this->getLoops(); i++) {
canvas->drawBitmapRectToRect(fBitmap, &fSrcR, fDstR, &paint);
}
}
......@@ -102,10 +104,10 @@ private:
typedef SkBenchmark INHERITED;
};
DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, false))
DEF_BENCH(return new BitmapRectBench(p, 0x80, false, false))
DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, false))
DEF_BENCH(return new BitmapRectBench(p, 0x80, true, false))
DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, false))
DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kNone_FilterLevel, false))
DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, false))
DEF_BENCH(return new BitmapRectBench(0x80, SkPaint::kLow_FilterLevel, false))
DEF_BENCH(return new BitmapRectBench(p, 0xFF, false, true))
DEF_BENCH(return new BitmapRectBench(p, 0xFF, true, true))
DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kNone_FilterLevel, true))
DEF_BENCH(return new BitmapRectBench(0xFF, SkPaint::kLow_FilterLevel, true))
......@@ -20,7 +20,7 @@ class BitmapScaleBench: public SkBenchmark {
SkString fName;
public:
BitmapScaleBench(void *param, int is, int os) : INHERITED(param) {
BitmapScaleBench( int is, int os) {
fInputSize = is;
fOutputSize = os;
......@@ -57,14 +57,14 @@ protected:
}
virtual void onPreDraw() {
fInputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fInputSize, fInputSize);
fInputBitmap.setConfig(SkBitmap::kARGB_8888_Config,
fInputSize, fInputSize, 0, kOpaque_SkAlphaType);
fInputBitmap.allocPixels();
fInputBitmap.eraseColor(SK_ColorWHITE);
fInputBitmap.setIsOpaque(true);
fOutputBitmap.setConfig(SkBitmap::kARGB_8888_Config, fOutputSize, fOutputSize);
fOutputBitmap.setConfig(SkBitmap::kARGB_8888_Config,
fOutputSize, fOutputSize, 0, kOpaque_SkAlphaType);
fOutputBitmap.allocPixels();
fOutputBitmap.setIsOpaque(true);
fMatrix.setScale( scale(), scale() );
}
......@@ -75,7 +75,7 @@ protected:
preBenchSetup();
for (int i = 0; i < SkBENCHLOOP(fLoopCount); i++) {
for (int i = 0; i < this->getLoops(); i++) {
doScaleImage();
}
}
......@@ -88,7 +88,7 @@ private:
class BitmapFilterScaleBench: public BitmapScaleBench {
public:
BitmapFilterScaleBench(void *param, int is, int os) : INHERITED(param, is, os) {
BitmapFilterScaleBench( int is, int os) : INHERITED(is, os) {
setName( "filter" );
}
protected:
......@@ -103,12 +103,12 @@ private:
typedef BitmapScaleBench INHERITED;
};
DEF_BENCH(return new BitmapFilterScaleBench(p, 10, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 30, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 80, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 80);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 30);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 90, 10);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 256, 64);)
DEF_BENCH(return new BitmapFilterScaleBench(p, 64, 256);)
DEF_BENCH(return new BitmapFilterScaleBench(10, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(30, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(80, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(90, 90);)
DEF_BENCH(return new BitmapFilterScaleBench(90, 80);)
DEF_BENCH(return new BitmapFilterScaleBench(90, 30);)
DEF_BENCH(return new BitmapFilterScaleBench(90, 10);)
DEF_BENCH(return new BitmapFilterScaleBench(256, 64);)
DEF_BENCH(return new BitmapFilterScaleBench(64, 256);)
......@@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
......@@ -32,12 +33,13 @@ class BlurBench : public SkBenchmark {
SkString fName;
public:
BlurBench(void* param, SkScalar rad, SkBlurMaskFilter::BlurStyle bs, uint32_t flags = 0) : INHERITED(param) {
BlurBench(SkScalar rad, SkBlurMaskFilter::BlurStyle bs, uint32_t flags = 0) {
fRadius = rad;
fStyle = bs;
fFlags = flags;
const char* name = rad > 0 ? gStyleName[bs] : "none";
const char* quality = flags & SkBlurMaskFilter::kHighQuality_BlurFlag ? "high_quality" : "low_quality";
const char* quality = flags & SkBlurMaskFilter::kHighQuality_BlurFlag ? "high_quality"
: "low_quality";
if (SkScalarFraction(rad) != 0) {
fName.printf("blur_%.2f_%s_%s", SkScalarToFloat(rad), name, quality);
} else {
......@@ -57,13 +59,15 @@ protected:
paint.setAntiAlias(true);
SkRandom rand;
for (int i = 0; i < SkBENCHLOOP(10); i++) {
for (int i = 0; i < this->getLoops(); i++) {
SkRect r = SkRect::MakeWH(rand.nextUScalar1() * 400,
rand.nextUScalar1() * 400);
r.offset(fRadius, fRadius);
if (fRadius > 0) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(fRadius, fStyle, fFlags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(fStyle,
SkBlurMask::ConvertRadiusToSigma(fRadius),
fFlags);
paint.setMaskFilter(mf)->unref();
}
canvas->drawOval(r, paint);
......@@ -74,32 +78,32 @@ private:
typedef SkBenchmark INHERITED;
};
DEF_BENCH(return new BlurBench(p, SMALL, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(p, SMALL, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(p, SMALL, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(p, SMALL, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(p, BIG, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(p, BIG, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(p, BIG, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(p, BIG, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REALBIG, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REALBIG, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REALBIG, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REALBIG, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REAL, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REAL, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REAL, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(p, REAL, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kSolid_BlurStyle);)
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kInner_BlurStyle);)
DEF_BENCH(return new BlurBench(p, SMALL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(p, BIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(p, REALBIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(p, REAL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
DEF_BENCH(return new BlurBench(p, 0, SkBlurMaskFilter::kNormal_BlurStyle);)
DEF_BENCH(return new BlurBench(0, SkBlurMaskFilter::kNormal_BlurStyle);)
......@@ -6,9 +6,9 @@
*/
#include "SkBenchmark.h"
#include "SkBitmapDevice.h"
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkShader.h"
......@@ -23,8 +23,8 @@
class BlurImageFilterBench : public SkBenchmark {
public:
BlurImageFilterBench(void* param, SkScalar sigmaX, SkScalar sigmaY, bool small) :
INHERITED(param), fIsSmall(small), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) {
BlurImageFilterBench(SkScalar sigmaX, SkScalar sigmaY, bool small) :
fIsSmall(small), fInitialized(false), fSigmaX(sigmaX), fSigmaY(sigmaY) {
fName.printf("blur_image_filter_%s_%.2f_%.2f", fIsSmall ? "small" : "large",
SkScalarToFloat(sigmaX), SkScalarToFloat(sigmaY));
}
......@@ -44,7 +44,10 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
for (int i = 0; i < this->getLoops(); i++) {
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
}
}
private:
......@@ -53,7 +56,7 @@ private:
const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
fCheckerboard.allocPixels();
SkDevice device(fCheckerboard);
SkBitmapDevice device(fCheckerboard);
SkCanvas canvas(&device);
canvas.clear(0x00000000);
SkPaint darkPaint;
......@@ -81,7 +84,7 @@ private:
typedef SkBenchmark INHERITED;
};
DEF_BENCH(return new BlurImageFilterBench(p, BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, true);)
DEF_BENCH(return new BlurImageFilterBench(p, BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, false);)
DEF_BENCH(return new BlurImageFilterBench(p, BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, true);)
DEF_BENCH(return new BlurImageFilterBench(p, BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, false);)
DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, true);)
DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_SMALL, BLUR_SIGMA_SMALL, false);)
DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, true);)
DEF_BENCH(return new BlurImageFilterBench(BLUR_SIGMA_LARGE, BLUR_SIGMA_LARGE, false);)
......@@ -15,7 +15,9 @@
#define SMALL SkIntToScalar(2)
#define REAL SkFloatToScalar(1.5f)
static const SkScalar kMedium = SkIntToScalar(5);
#define BIG SkIntToScalar(10)
static const SkScalar kMedBig = SkIntToScalar(20);
#define REALBIG SkFloatToScalar(30.5f)
class BlurRectBench: public SkBenchmark {
......@@ -24,7 +26,7 @@ class BlurRectBench: public SkBenchmark {
SkString fName;
public:
BlurRectBench(void *param, SkScalar rad) : INHERITED(param) {
BlurRectBench(SkScalar rad) {
fRadius = rad;
if (fRadius > SkIntToScalar(25)) {
......@@ -60,7 +62,7 @@ protected:
preBenchSetup(r);
for (int i = 0; i < SkBENCHLOOP(fLoopCount); i++) {
for (int i = 0; i < this->getLoops(); i++) {
makeBlurryRect(r);
}
}
......@@ -74,7 +76,7 @@ private:
class BlurRectDirectBench: public BlurRectBench {
public:
BlurRectDirectBench(void *param, SkScalar rad) : INHERITED(param, rad) {
BlurRectDirectBench(SkScalar rad) : INHERITED(rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
......@@ -83,12 +85,13 @@ class BlurRectDirectBench: public BlurRectBench {
name.printf("blurrect_direct_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
virtual void makeBlurryRect(const SkRect& r) SK_OVERRIDE {
SkMask mask;
SkBlurMask::BlurRect(&mask, r, this->radius(), SkBlurMask::kNormal_Style);
SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radius()),
&mask, r, SkBlurMask::kNormal_Style);
SkMask::FreeImage(mask.fImage);
}
private:
......@@ -98,7 +101,7 @@ private:
class BlurRectSeparableBench: public BlurRectBench {
public:
BlurRectSeparableBench(void *param, SkScalar rad) : INHERITED(param, rad) {
BlurRectSeparableBench(SkScalar rad) : INHERITED(rad) {
fSrcMask.fImage = NULL;
}
......@@ -125,14 +128,16 @@ private:
class BlurRectBoxFilterBench: public BlurRectSeparableBench {
public:
BlurRectBoxFilterBench(void *param, SkScalar rad) : INHERITED(param, rad) {
BlurRectBoxFilterBench(SkScalar rad) : INHERITED(rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
name.printf("blurrect_boxfilter_%.2f", SkScalarToFloat(rad));
} else {
name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
......@@ -140,9 +145,9 @@ protected:
virtual void makeBlurryRect(const SkRect&) SK_OVERRIDE {
SkMask mask;
mask.fImage = NULL;
SkBlurMask::Blur(&mask, fSrcMask, this->radius(),
SkBlurMask::kNormal_Style,
SkBlurMask::kHigh_Quality);
SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(this->radius()),
SkBlurMask::kNormal_Style,
SkBlurMask::kHigh_Quality);
SkMask::FreeImage(mask.fImage);
}
private:
......@@ -151,14 +156,16 @@ private:
class BlurRectGaussianBench: public BlurRectSeparableBench {
public:
BlurRectGaussianBench(void *param, SkScalar rad) : INHERITED(param, rad) {
BlurRectGaussianBench(SkScalar rad) : INHERITED(rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad));
} else {
name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
......@@ -166,32 +173,32 @@ protected:
virtual void makeBlurryRect(const SkRect&) SK_OVERRIDE {
SkMask mask;
mask.fImage = NULL;
SkBlurMask::BlurGroundTruth(&mask, fSrcMask, this->radius(),
SkBlurMask::kNormal_Style);
SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radius()),
&mask, fSrcMask, SkBlurMask::kNormal_Style);
SkMask::FreeImage(mask.fImage);
}
private:
typedef BlurRectSeparableBench INHERITED;
};
DEF_BENCH(return new BlurRectBoxFilterBench(p, SMALL);)
DEF_BENCH(return new BlurRectBoxFilterBench(p, BIG);)
DEF_BENCH(return new BlurRectBoxFilterBench(p, REALBIG);)
DEF_BENCH(return new BlurRectBoxFilterBench(p, REAL);)
DEF_BENCH(return new BlurRectGaussianBench(p, SMALL);)
DEF_BENCH(return new BlurRectGaussianBench(p, BIG);)
DEF_BENCH(return new BlurRectGaussianBench(p, REALBIG);)
DEF_BENCH(return new BlurRectGaussianBench(p, REAL);)
DEF_BENCH(return new BlurRectDirectBench(p, SMALL);)
DEF_BENCH(return new BlurRectDirectBench(p, BIG);)
DEF_BENCH(return new BlurRectDirectBench(p, REALBIG);)
DEF_BENCH(return new BlurRectDirectBench(p, REAL);)
DEF_BENCH(return new BlurRectDirectBench(p, SkIntToScalar(5));)
DEF_BENCH(return new BlurRectDirectBench(p, SkIntToScalar(20));)
DEF_BENCH(return new BlurRectBoxFilterBench(p, SkIntToScalar(5));)
DEF_BENCH(return new BlurRectBoxFilterBench(p, SkIntToScalar(20));)
DEF_BENCH(return new BlurRectBoxFilterBench(SMALL);)
DEF_BENCH(return new BlurRectBoxFilterBench(BIG);)
DEF_BENCH(return new BlurRectBoxFilterBench(REALBIG);)
DEF_BENCH(return new BlurRectBoxFilterBench(REAL);)
DEF_BENCH(return new BlurRectGaussianBench(SMALL);)
DEF_BENCH(return new BlurRectGaussianBench(BIG);)
DEF_BENCH(return new BlurRectGaussianBench(REALBIG);)
DEF_BENCH(return new BlurRectGaussianBench(REAL);)
DEF_BENCH(return new BlurRectDirectBench(SMALL);)
DEF_BENCH(return new BlurRectDirectBench(BIG);)
DEF_BENCH(return new BlurRectDirectBench(REALBIG);)
DEF_BENCH(return new BlurRectDirectBench(REAL);)
DEF_BENCH(return new BlurRectDirectBench(kMedium);)
DEF_BENCH(return new BlurRectDirectBench(kMedBig);)
DEF_BENCH(return new BlurRectBoxFilterBench(kMedium);)
DEF_BENCH(return new BlurRectBoxFilterBench(kMedBig);)
#if 0
// disable Gaussian benchmarks; the algorithm works well enough
......@@ -199,24 +206,24 @@ DEF_BENCH(return new BlurRectBoxFilterBench(p, SkIntToScalar(20));)
// to use in production for non-trivial radii, so no real point
// in having the bots benchmark it all the time.
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(1));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(2));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(3));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(4));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(5));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(6));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(7));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(8));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(9));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(10));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(11));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(12));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(13));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(14));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(15));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(16));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(17));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(18));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(19));)
DEF_BENCH(return new BlurRectGaussianBench(p, SkIntToScalar(20));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(1));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(2));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(3));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(4));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(5));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(6));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(7));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(8));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(9));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(10));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(11));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(12));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(13));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(14));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(15));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(16));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(17));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(18));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(19));)
DEF_BENCH(return new BlurRectGaussianBench(SkIntToScalar(20));)
#endif
/*
* Copyright 2013 Google Inc.
*
......@@ -16,12 +15,10 @@
* to write one subclass that can be a GM, bench, and/or Sample.
*/
namespace {
// Generates y values for the chart plots.
void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* dataPts) {
static void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* dataPts) {
dataPts->setCount(count);
static SkMWCRandom gRandom;
static SkRandom gRandom;
for (int i = 0; i < count; ++i) {
(*dataPts)[i] = gRandom.nextRangeScalar(yAvg - SkScalarHalf(ySpread),
yAvg + SkScalarHalf(ySpread));
......@@ -32,12 +29,12 @@ void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* d
// plot. The fill path is bounded below by the bottomData plot points or a horizontal line at
// yBase if bottomData == NULL.
// The plots are animated by rotating the data points by leftShift.
void gen_paths(const SkTDArray<SkScalar>& topData,
const SkTDArray<SkScalar>* bottomData,
SkScalar yBase,
SkScalar xLeft, SkScalar xDelta,
int leftShift,
SkPath* plot, SkPath* fill) {
static void gen_paths(const SkTDArray<SkScalar>& topData,
const SkTDArray<SkScalar>* bottomData,
SkScalar yBase,
SkScalar xLeft, SkScalar xDelta,
int leftShift,
SkPath* plot, SkPath* fill) {
plot->rewind();
fill->rewind();
plot->incReserve(topData.count());
......@@ -85,13 +82,11 @@ void gen_paths(const SkTDArray<SkScalar>& topData,
}
}
}
// A set of scrolling line plots with the area between each plot filled. Stresses out GPU path
// filling
class ChartBench : public SkBenchmark {
public:
ChartBench(void* param, bool aa) : SkBenchmark(param) {
ChartBench(bool aa) {
fShift = 0;
fAA = aa;
fSize.fWidth = -1;
......@@ -127,11 +122,11 @@ protected:
}
}
for (int frame = 0; frame < kFramesPerRun; ++frame) {
for (int frame = 0; frame < this->getLoops(); ++frame) {
canvas->clear(0xFFE0F0E0);
static SkMWCRandom colorRand;
static SkRandom colorRand;
static SkColor gColors[kNumGraphs] = { 0x0 };
if (0 == gColors[0]) {
for (int i = 0; i < kNumGraphs; ++i) {
......@@ -183,8 +178,6 @@ private:
kNumGraphs = 5,
kPixelsPerTick = 3,
kShiftPerFrame = 1,
kFramesPerRun = SkBENCHLOOP(5),
};
int fShift;
SkISize fSize;
......@@ -196,8 +189,5 @@ private:
//////////////////////////////////////////////////////////////////////////////
static SkBenchmark* Fact0(void* p) { return new ChartBench(p, true); }
static SkBenchmark* Fact1(void* p) { return new ChartBench(p, false); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
DEF_BENCH( return new ChartBench(true); )
DEF_BENCH( return new ChartBench(false); )
......@@ -23,13 +23,12 @@ class ComputeChecksumBench : public SkBenchmark {
enum {
U32COUNT = 256,
SIZE = U32COUNT * 4,
N = SkBENCHLOOP(100000),
};
uint32_t fData[U32COUNT];
ChecksumType fType;
public:
ComputeChecksumBench(void* param, ChecksumType type) : INHERITED(param), fType(type) {
ComputeChecksumBench(ChecksumType type) : fType(type) {
SkRandom rand;
for (int i = 0; i < U32COUNT; ++i) {
fData[i] = rand.nextU();
......@@ -52,13 +51,13 @@ protected:
virtual void onDraw(SkCanvas*) {
switch (fType) {
case kChecksum_ChecksumType: {
for (int i = 0; i < N; i++) {
for (int i = 0; i < this->getLoops(); i++) {
volatile uint32_t result = SkChecksum::Compute(fData, sizeof(fData));
sk_ignore_unused_variable(result);
}
} break;
case kMD5_ChecksumType: {
for (int i = 0; i < N; i++) {
for (int i = 0; i < this->getLoops(); i++) {
SkMD5 md5;
md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkMD5::Digest digest;
......@@ -66,7 +65,7 @@ protected:
}
} break;
case kSHA1_ChecksumType: {
for (int i = 0; i < N; i++) {
for (int i = 0; i < this->getLoops(); i++) {
SkSHA1 sha1;
sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkSHA1::Digest digest;
......@@ -74,7 +73,7 @@ protected:
}
} break;
case kMurmur3_ChecksumType: {
for (int i = 0; i < N; i++) {
for (int i = 0; i < this->getLoops(); i++) {
volatile uint32_t result = SkChecksum::Murmur3(fData, sizeof(fData));
sk_ignore_unused_variable(result);
}
......@@ -89,13 +88,7 @@ private:
///////////////////////////////////////////////////////////////////////////////
static SkBenchmark* Fact0(void* p) { return new ComputeChecksumBench(p, kChecksum_ChecksumType); }
static SkBenchmark* Fact1(void* p) { return new ComputeChecksumBench(p, kMD5_ChecksumType); }
static SkBenchmark* Fact2(void* p) { return new ComputeChecksumBench(p, kSHA1_ChecksumType); }
static SkBenchmark* Fact3(void* p) { return new ComputeChecksumBench(p, kMurmur3_ChecksumType); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
static BenchRegistry gReg2(Fact2);
static BenchRegistry gReg3(Fact3);
DEF_BENCH( return new ComputeChecksumBench(kChecksum_ChecksumType); )
DEF_BENCH( return new ComputeChecksumBench(kMD5_ChecksumType); )
DEF_BENCH( return new ComputeChecksumBench(kSHA1_ChecksumType); )
DEF_BENCH( return new ComputeChecksumBench(kMurmur3_ChecksumType); )
......@@ -456,7 +456,7 @@ class ScrollGmailBench : public SkBenchmark {
N = 431
};
public:
ScrollGmailBench(void* param) : INHERITED(param) { }
ScrollGmailBench() { }
protected:
......@@ -468,7 +468,7 @@ protected:
for (int i = 0; i < N; i++) {
SkRect current;
setRectangle(current, i);
for (int j = 0; j < SkBENCHLOOP(gmailScrollingRectSpec[i*3]); j++) {
for (int j = 0; j < this->getLoops() * gmailScrollingRectSpec[i*3]; j++) {
canvas->drawRect(current, paint);
}
}
......@@ -491,10 +491,6 @@ private:
typedef SkBenchmark INHERITED;
};
static inline SkBenchmark* ScrollGmailFactory(void* p) {
return SkNEW_ARGS(ScrollGmailBench, (p));
}
// Disabled this benchmark: it takes 15x longer than any other benchmark
// and is probably not giving us important information.
//static BenchRegistry gScrollGmailReg(ScrollGmailFactory);
// DEF_BENCH(return SkNEW(ScrollGmailBench));
......@@ -11,7 +11,6 @@
#include "SkTypeface.h"
enum {
LOOP = SkBENCHLOOP(1000),
NGLYPHS = 100
};
......@@ -21,44 +20,44 @@ static SkTypeface::Encoding paint2Encoding(const SkPaint& paint) {
return (SkTypeface::Encoding)enc;
}
typedef void (*TypefaceProc)(const SkPaint&, const void* text, size_t len,
typedef void (*TypefaceProc)(int loops, const SkPaint&, const void* text, size_t len,
int glyphCount);
static void containsText_proc(const SkPaint& paint, const void* text, size_t len,
static void containsText_proc(int loops, const SkPaint& paint, const void* text, size_t len,
int glyphCount) {
for (int i = 0; i < LOOP; ++i) {
for (int i = 0; i < loops; ++i) {
paint.containsText(text, len);
}
}
static void textToGlyphs_proc(const SkPaint& paint, const void* text, size_t len,
static void textToGlyphs_proc(int loops, const SkPaint& paint, const void* text, size_t len,
int glyphCount) {
uint16_t glyphs[NGLYPHS];
SkASSERT(glyphCount <= NGLYPHS);
for (int i = 0; i < LOOP; ++i) {
for (int i = 0; i < loops; ++i) {
paint.textToGlyphs(text, len, glyphs);
}
}
static void charsToGlyphs_proc(const SkPaint& paint, const void* text,
static void charsToGlyphs_proc(int loops, const SkPaint& paint, const void* text,
size_t len, int glyphCount) {
SkTypeface::Encoding encoding = paint2Encoding(paint);
uint16_t glyphs[NGLYPHS];
SkASSERT(glyphCount <= NGLYPHS);
SkTypeface* face = paint.getTypeface();
for (int i = 0; i < LOOP; ++i) {
for (int i = 0; i < loops; ++i) {
face->charsToGlyphs(text, encoding, glyphs, glyphCount);
}
}
static void charsToGlyphsNull_proc(const SkPaint& paint, const void* text,
static void charsToGlyphsNull_proc(int loops, const SkPaint& paint, const void* text,
size_t len, int glyphCount) {
SkTypeface::Encoding encoding = paint2Encoding(paint);
SkTypeface* face = paint.getTypeface();
for (int i = 0; i < LOOP; ++i) {
for (int i = 0; i < loops; ++i) {
face->charsToGlyphs(text, encoding, NULL, glyphCount);
}
}
......@@ -70,7 +69,7 @@ class CMAPBench : public SkBenchmark {
SkPaint fPaint;
public:
CMAPBench(void* param, TypefaceProc proc, const char name[]) : SkBenchmark(param) {
CMAPBench(TypefaceProc proc, const char name[]) {
fProc = proc;
fName.printf("cmap_%s", name);
......@@ -87,7 +86,7 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
fProc(fPaint, fText, sizeof(fText), NGLYPHS);
fProc(this->getLoops(), fPaint, fText, sizeof(fText), NGLYPHS);
}
private:
......@@ -97,7 +96,7 @@ private:
//////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new CMAPBench(p, containsText_proc, "paint_containsText"); )
DEF_BENCH( return new CMAPBench(p, textToGlyphs_proc, "paint_textToGlyphs"); )
DEF_BENCH( return new CMAPBench(p, charsToGlyphs_proc, "face_charsToGlyphs"); )
DEF_BENCH( return new CMAPBench(p, charsToGlyphsNull_proc, "face_charsToGlyphs_null"); )
DEF_BENCH( return new CMAPBench(containsText_proc, "paint_containsText"); )
DEF_BENCH( return new CMAPBench(textToGlyphs_proc, "paint_textToGlyphs"); )
DEF_BENCH( return new CMAPBench(charsToGlyphs_proc, "face_charsToGlyphs"); )
DEF_BENCH( return new CMAPBench(charsToGlyphsNull_proc, "face_charsToGlyphs_null"); )
......@@ -8,6 +8,7 @@
#include "SkCanvas.h"
#include "SkColorFilterImageFilter.h"
#include "SkColorMatrixFilter.h"
#include "SkLumaColorFilter.h"
#include "SkTableColorFilter.h"
#define FILTER_WIDTH_SMALL SkIntToScalar(32)
......@@ -18,8 +19,7 @@
class ColorFilterBaseBench : public SkBenchmark {
public:
ColorFilterBaseBench(void* param, bool small) : INHERITED(param), fIsSmall(small) {
}
ColorFilterBaseBench(bool small) : fIsSmall(small) { }
protected:
SkRect getFilterRect() const {
......@@ -64,7 +64,7 @@ private:
class ColorFilterDimBrightBench : public ColorFilterBaseBench {
public:
ColorFilterDimBrightBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterDimBrightBench(bool small) : INHERITED(small) {
}
protected:
......@@ -76,11 +76,14 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
for (float brightness = -1.0f; brightness <= 1.0f; brightness += 0.4f) {
SkAutoTUnref<SkImageFilter> dim(make_brightness(-brightness));
SkAutoTUnref<SkImageFilter> bright(make_brightness(brightness, dim));
paint.setImageFilter(bright);
canvas->drawRect(r, paint);
for (int i = 0; i < this->getLoops(); i++) {
for (float brightness = -1.0f; brightness <= 1.0f; brightness += 0.4f) {
SkAutoTUnref<SkImageFilter> dim(make_brightness(-brightness));
SkAutoTUnref<SkImageFilter> bright(make_brightness(brightness, dim));
paint.setImageFilter(bright);
canvas->drawRect(r, paint);
}
}
}
......@@ -91,7 +94,7 @@ private:
class ColorFilterBrightGrayBench : public ColorFilterBaseBench {
public:
ColorFilterBrightGrayBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterBrightGrayBench(bool small) : INHERITED(small) {
}
protected:
......@@ -103,7 +106,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.9f));
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale(brightness));
paint.setImageFilter(grayscale);
......@@ -118,7 +121,7 @@ private:
class ColorFilterGrayBrightBench : public ColorFilterBaseBench {
public:
ColorFilterGrayBrightBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterGrayBrightBench(bool small) : INHERITED(small) {
}
protected:
......@@ -130,7 +133,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale());
SkAutoTUnref<SkImageFilter> brightness(make_brightness(0.9f, grayscale));
paint.setImageFilter(brightness);
......@@ -145,7 +148,7 @@ private:
class ColorFilterBlueBrightBench : public ColorFilterBaseBench {
public:
ColorFilterBlueBrightBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterBlueBrightBench(bool small) : INHERITED(small) {
}
protected:
......@@ -157,7 +160,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> blue(make_mode_blue());
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f, blue));
paint.setImageFilter(brightness);
......@@ -172,7 +175,7 @@ private:
class ColorFilterBrightBlueBench : public ColorFilterBaseBench {
public:
ColorFilterBrightBlueBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterBrightBlueBench(bool small) : INHERITED(small) {
}
protected:
......@@ -184,7 +187,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f));
SkAutoTUnref<SkImageFilter> blue(make_mode_blue(brightness));
paint.setImageFilter(blue);
......@@ -199,7 +202,7 @@ private:
class ColorFilterBrightBench : public ColorFilterBaseBench {
public:
ColorFilterBrightBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterBrightBench(bool small) : INHERITED(small) {
}
protected:
......@@ -211,7 +214,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> brightness(make_brightness(1.0f));
paint.setImageFilter(brightness);
canvas->drawRect(r, paint);
......@@ -225,7 +228,7 @@ private:
class ColorFilterBlueBench : public ColorFilterBaseBench {
public:
ColorFilterBlueBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterBlueBench(bool small) : INHERITED(small) {
}
protected:
......@@ -237,7 +240,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> blue(make_mode_blue());
paint.setImageFilter(blue);
canvas->drawRect(r, paint);
......@@ -251,7 +254,7 @@ private:
class ColorFilterGrayBench : public ColorFilterBaseBench {
public:
ColorFilterGrayBench(void* param, bool small) : INHERITED(param, small) {
ColorFilterGrayBench(bool small) : INHERITED(small) {
}
protected:
......@@ -263,7 +266,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkImageFilter> grayscale(make_grayscale());
paint.setImageFilter(grayscale);
canvas->drawRect(r, paint);
......@@ -277,7 +280,7 @@ private:
class TableColorFilterBench : public ColorFilterBaseBench {
public:
TableColorFilterBench(void* param, bool small) : INHERITED(param, small) {
TableColorFilterBench(bool small) : INHERITED(small) {
}
protected:
......@@ -289,7 +292,7 @@ protected:
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
{
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkColorFilter> table_filter(make_table_filter());
paint.setColorFilter(table_filter);
canvas->drawRect(r, paint);
......@@ -312,24 +315,53 @@ private:
typedef ColorFilterBaseBench INHERITED;
};
class LumaColorFilterBench : public ColorFilterBaseBench {
public:
LumaColorFilterBench(bool small) : INHERITED(small) {
}
protected:
virtual const char* onGetName() SK_OVERRIDE {
return isSmall() ? "luma_colorfilter_small" : "luma_colorfilter_large";
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkRect r = getFilterRect();
SkPaint paint;
paint.setColor(SK_ColorRED);
for (int i = 0; i < this->getLoops(); i++) {
SkAutoTUnref<SkColorFilter> luma_filter(SkLumaColorFilter::Create());
paint.setColorFilter(luma_filter);
canvas->drawRect(r, paint);
}
}
private:
typedef ColorFilterBaseBench INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
DEF_BENCH( return new ColorFilterDimBrightBench(p, true); )
DEF_BENCH( return new ColorFilterBrightGrayBench(p, true); )
DEF_BENCH( return new ColorFilterGrayBrightBench(p, true); )
DEF_BENCH( return new ColorFilterBlueBrightBench(p, true); )
DEF_BENCH( return new ColorFilterBrightBlueBench(p, true); )
DEF_BENCH( return new ColorFilterBrightBench(p, true); )
DEF_BENCH( return new ColorFilterBlueBench(p, true); )
DEF_BENCH( return new ColorFilterGrayBench(p, true); )
DEF_BENCH( return new TableColorFilterBench(p, true); )
DEF_BENCH( return new ColorFilterDimBrightBench(p, false); )
DEF_BENCH( return new ColorFilterBrightGrayBench(p, false); )
DEF_BENCH( return new ColorFilterGrayBrightBench(p, false); )
DEF_BENCH( return new ColorFilterBlueBrightBench(p, false); )
DEF_BENCH( return new ColorFilterBrightBlueBench(p, false); )
DEF_BENCH( return new ColorFilterBrightBench(p, false); )
DEF_BENCH( return new ColorFilterBlueBench(p, false); )
DEF_BENCH( return new ColorFilterGrayBench(p, false); )
DEF_BENCH( return new TableColorFilterBench(p, false); )
DEF_BENCH( return new ColorFilterDimBrightBench(true); )
DEF_BENCH( return new ColorFilterBrightGrayBench(true); )
DEF_BENCH( return new ColorFilterGrayBrightBench(true); )
DEF_BENCH( return new ColorFilterBlueBrightBench(true); )
DEF_BENCH( return new ColorFilterBrightBlueBench(true); )
DEF_BENCH( return new ColorFilterBrightBench(true); )
DEF_BENCH( return new ColorFilterBlueBench(true); )
DEF_BENCH( return new ColorFilterGrayBench(true); )
DEF_BENCH( return new TableColorFilterBench(true); )
DEF_BENCH( return new LumaColorFilterBench(true); )
DEF_BENCH( return new ColorFilterDimBrightBench(false); )
DEF_BENCH( return new ColorFilterBrightGrayBench(false); )
DEF_BENCH( return new ColorFilterGrayBrightBench(false); )
DEF_BENCH( return new ColorFilterBlueBrightBench(false); )
DEF_BENCH( return new ColorFilterBrightBlueBench(false); )
DEF_BENCH( return new ColorFilterBrightBench(false); )
DEF_BENCH( return new ColorFilterBlueBench(false); )
DEF_BENCH( return new ColorFilterGrayBench(false); )
DEF_BENCH( return new TableColorFilterBench(false); )
DEF_BENCH( return new LumaColorFilterBench(false); )
......@@ -37,12 +37,9 @@ protected:
SkPoint fPts[2];
bool fDoClip;
enum {
N = SkBENCHLOOP(100)
};
public:
DashBench(void* param, const SkScalar intervals[], int count, int width,
bool doClip = false) : INHERITED(param) {
DashBench(const SkScalar intervals[], int count, int width,
bool doClip = false) {
fIntervals.append(count, intervals);
for (int i = 0; i < count; ++i) {
fIntervals[i] *= width;
......@@ -85,7 +82,7 @@ protected:
canvas->clipRect(r);
}
this->handlePath(canvas, path, paint, N);
this->handlePath(canvas, path, paint, this->getLoops());
}
virtual void handlePath(SkCanvas* canvas, const SkPath& path,
......@@ -102,8 +99,8 @@ private:
class RectDashBench : public DashBench {
public:
RectDashBench(void* param, const SkScalar intervals[], int count, int width)
: INHERITED(param, intervals, count, width) {
RectDashBench(const SkScalar intervals[], int count, int width)
: INHERITED(intervals, count, width) {
fName.append("_rect");
}
......@@ -183,12 +180,8 @@ class MakeDashBench : public SkBenchmark {
SkPath fPath;
SkAutoTUnref<SkPathEffect> fPE;
enum {
N = SkBENCHLOOP(400)
};
public:
MakeDashBench(void* param, void (*proc)(SkPath*), const char name[]) : INHERITED(param) {
MakeDashBench(void (*proc)(SkPath*), const char name[]) {
fName.printf("makedash_%s", name);
proc(&fPath);
......@@ -203,7 +196,7 @@ protected:
virtual void onDraw(SkCanvas*) SK_OVERRIDE {
SkPath dst;
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
SkStrokeRec rec(SkStrokeRec::kHairline_InitStyle);
fPE->filterPath(&dst, fPath, &rec, NULL);
......@@ -224,12 +217,8 @@ class DashLineBench : public SkBenchmark {
bool fIsRound;
SkAutoTUnref<SkPathEffect> fPE;
enum {
N = SkBENCHLOOP(200)
};
public:
DashLineBench(void* param, SkScalar width, bool isRound) : INHERITED(param) {
DashLineBench(SkScalar width, bool isRound) {
fName.printf("dashline_%g_%s", SkScalarToFloat(width), isRound ? "circle" : "square");
fStrokeWidth = width;
fIsRound = isRound;
......@@ -249,7 +238,7 @@ protected:
paint.setStrokeWidth(fStrokeWidth);
paint.setStrokeCap(fIsRound ? SkPaint::kRound_Cap : SkPaint::kSquare_Cap);
paint.setPathEffect(fPE);
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
canvas->drawLine(10 * SK_Scalar1, 10 * SK_Scalar1,
640 * SK_Scalar1, 10 * SK_Scalar1, paint);
}
......@@ -266,13 +255,9 @@ class DrawPointsDashingBench : public SkBenchmark {
SkAutoTUnref<SkPathEffect> fPathEffect;
enum {
N = SkBENCHLOOP(480)
};
public:
DrawPointsDashingBench(void* param, int dashLength, int strokeWidth, bool doAA)
: INHERITED(param) {
DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA)
{
fName.printf("drawpointsdash_%d_%d%s", dashLength, strokeWidth, doAA ? "_aa" : "_bw");
fStrokeWidth = strokeWidth;
fDoAA = doAA;
......@@ -287,7 +272,6 @@ protected:
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint p;
this->setupPaint(&p);
p.setColor(SK_ColorBLACK);
......@@ -301,8 +285,7 @@ protected:
{ SkIntToScalar(640), 0 }
};
for (int i = 0; i < N; ++i) {
for (int i = 0; i < this->getLoops(); ++i) {
pts[0].fY = pts[1].fY = SkIntToScalar(i % 480);
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
}
......@@ -333,7 +316,7 @@ public:
return gNames[lt];
}
GiantDashBench(void* param, LineType lt, SkScalar width) : INHERITED(param) {
GiantDashBench(LineType lt, SkScalar width) {
fName.printf("giantdashline_%s_%g", LineTypeName(lt), width);
fStrokeWidth = width;
......@@ -381,7 +364,9 @@ protected:
p.setStrokeWidth(fStrokeWidth);
p.setPathEffect(fPathEffect);
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p);
for (int i = 0; i < this->getLoops(); i++) {
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, fPts, p);
}
}
private:
......@@ -395,39 +380,39 @@ static const SkScalar gDots[] = { SK_Scalar1, SK_Scalar1 };
#define PARAM(array) array, SK_ARRAY_COUNT(array)
DEF_BENCH( return new DashBench(p, PARAM(gDots), 0); )
DEF_BENCH( return new DashBench(p, PARAM(gDots), 1); )
DEF_BENCH( return new DashBench(p, PARAM(gDots), 1, true); )
DEF_BENCH( return new DashBench(p, PARAM(gDots), 4); )
DEF_BENCH( return new MakeDashBench(p, make_poly, "poly"); )
DEF_BENCH( return new MakeDashBench(p, make_quad, "quad"); )
DEF_BENCH( return new MakeDashBench(p, make_cubic, "cubic"); )
DEF_BENCH( return new DashLineBench(p, 0, false); )
DEF_BENCH( return new DashLineBench(p, SK_Scalar1, false); )
DEF_BENCH( return new DashLineBench(p, 2 * SK_Scalar1, false); )
DEF_BENCH( return new DashLineBench(p, 0, true); )
DEF_BENCH( return new DashLineBench(p, SK_Scalar1, true); )
DEF_BENCH( return new DashLineBench(p, 2 * SK_Scalar1, true); )
DEF_BENCH( return new DrawPointsDashingBench(p, 1, 1, false); )
DEF_BENCH( return new DrawPointsDashingBench(p, 1, 1, true); )
DEF_BENCH( return new DrawPointsDashingBench(p, 3, 1, false); )
DEF_BENCH( return new DrawPointsDashingBench(p, 3, 1, true); )
DEF_BENCH( return new DrawPointsDashingBench(p, 5, 5, false); )
DEF_BENCH( return new DrawPointsDashingBench(p, 5, 5, true); )
DEF_BENCH( return new DashBench(PARAM(gDots), 0); )
DEF_BENCH( return new DashBench(PARAM(gDots), 1); )
DEF_BENCH( return new DashBench(PARAM(gDots), 1, true); )
DEF_BENCH( return new DashBench(PARAM(gDots), 4); )
DEF_BENCH( return new MakeDashBench(make_poly, "poly"); )
DEF_BENCH( return new MakeDashBench(make_quad, "quad"); )
DEF_BENCH( return new MakeDashBench(make_cubic, "cubic"); )
DEF_BENCH( return new DashLineBench(0, false); )
DEF_BENCH( return new DashLineBench(SK_Scalar1, false); )
DEF_BENCH( return new DashLineBench(2 * SK_Scalar1, false); )
DEF_BENCH( return new DashLineBench(0, true); )
DEF_BENCH( return new DashLineBench(SK_Scalar1, true); )
DEF_BENCH( return new DashLineBench(2 * SK_Scalar1, true); )
DEF_BENCH( return new DrawPointsDashingBench(1, 1, false); )
DEF_BENCH( return new DrawPointsDashingBench(1, 1, true); )
DEF_BENCH( return new DrawPointsDashingBench(3, 1, false); )
DEF_BENCH( return new DrawPointsDashingBench(3, 1, true); )
DEF_BENCH( return new DrawPointsDashingBench(5, 5, false); )
DEF_BENCH( return new DrawPointsDashingBench(5, 5, true); )
/* Disable the GiantDashBench for Android devices until we can better control
* the memory usage. (https://code.google.com/p/skia/issues/detail?id=1430)
*/
#ifndef SK_BUILD_FOR_ANDROID
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kHori_LineType, 0); )
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kVert_LineType, 0); )
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kDiag_LineType, 0); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 0); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 0); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 0); )
// pass 2 to explicitly avoid any 1-is-the-same-as-hairline special casing
// hori_2 is just too slow to enable at the moment
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kHori_LineType, 2); )
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kVert_LineType, 2); )
DEF_BENCH( return new GiantDashBench(p, GiantDashBench::kDiag_LineType, 2); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kHori_LineType, 2); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kVert_LineType, 2); )
DEF_BENCH( return new GiantDashBench(GiantDashBench::kDiag_LineType, 2); )
#endif
......@@ -7,29 +7,26 @@
*/
#include "SkBenchmark.h"
#include "SkBitmap.h"
#include "SkCommandLineFlags.h"
#include "SkImageDecoder.h"
#include "SkString.h"
DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for DecodeBench.");
static const char* gConfigName[] = {
"ERROR", "a1", "a8", "index8", "565", "4444", "8888"
};
class DecodeBench : public SkBenchmark {
const char* fFilename;
SkBitmap::Config fPrefConfig;
SkString fName;
enum { N = SkBENCHLOOP(10) };
public:
DecodeBench(void* param, SkBitmap::Config c) : SkBenchmark(param) {
fFilename = this->findDefine("decode-filename");
DecodeBench(SkBitmap::Config c) {
fPrefConfig = c;
const char* fname = NULL;
if (fFilename) {
fname = strrchr(fFilename, '/');
if (fname) {
fname += 1; // skip the slash
}
const char* fname = strrchr(FLAGS_decodeBenchFilename[0], '/');
if (fname) {
fname++; // skip the slash
}
fName.printf("decode_%s_%s", gConfigName[c], fname);
fIsRendering = false;
......@@ -41,12 +38,12 @@ protected:
}
virtual void onDraw(SkCanvas*) {
if (fFilename) {
for (int i = 0; i < N; i++) {
SkBitmap bm;
SkImageDecoder::DecodeFile(fFilename, &bm, fPrefConfig,
SkImageDecoder::kDecodePixels_Mode);
}
for (int i = 0; i < this->getLoops(); i++) {
SkBitmap bm;
SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0],
&bm,
fPrefConfig,
SkImageDecoder::kDecodePixels_Mode);
}
}
......@@ -54,10 +51,6 @@ private:
typedef SkBenchmark INHERITED;
};
static SkBenchmark* Fact0(void* p) { return new DecodeBench(p, SkBitmap::kARGB_8888_Config); }
static SkBenchmark* Fact1(void* p) { return new DecodeBench(p, SkBitmap::kRGB_565_Config); }
static SkBenchmark* Fact2(void* p) { return new DecodeBench(p, SkBitmap::kARGB_4444_Config); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
static BenchRegistry gReg2(Fact2);
DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_8888_Config); )
DEF_BENCH( return new DecodeBench(SkBitmap::kRGB_565_Config); )
DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_4444_Config); )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment