From b78765e63b5de5a7dfe5f9f6813f6df81cae14ae Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Tue, 4 Sep 2012 12:48:01 +0000 Subject: Reverting r5364 (Update ARM and NEON optimizations for S32A_Opaque_BlitRow32) git-svn-id: http://skia.googlecode.com/svn/trunk@5378 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/BitmapBench.cpp | 205 ++++++++++++-------------------------------------- 1 file changed, 47 insertions(+), 158 deletions(-) (limited to 'bench/BitmapBench.cpp') diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp index 59ea16dde9..5f06f884a8 100644 --- a/bench/BitmapBench.cpp +++ b/bench/BitmapBench.cpp @@ -21,6 +21,25 @@ static const char* gConfigName[] = { "ERROR", "a1", "a8", "index8", "565", "4444", "8888" }; +static void drawIntoBitmap(const SkBitmap& bm) { + const int w = bm.width(); + const int h = bm.height(); + + SkCanvas canvas(bm); + SkPaint p; + p.setAntiAlias(true); + p.setColor(SK_ColorRED); + canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2, + SkIntToScalar(SkMin32(w, h))*3/8, p); + + SkRect r; + r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); + p.setStyle(SkPaint::kStroke_Style); + p.setStrokeWidth(SkIntToScalar(4)); + p.setColor(SK_ColorBLUE); + canvas.drawRect(r, p); +} + static int conv6ToByte(int x) { return x * 0xFF / 5; } @@ -83,23 +102,38 @@ class BitmapBench : public SkBenchmark { bool fIsOpaque; bool fForceUpdate; //bitmap marked as dirty before each draw. forces bitmap to be updated on device cache int fTileX, fTileY; // -1 means don't use shader - bool fIsVolatile; - SkBitmap::Config fConfig; SkString fName; enum { N = SkBENCHLOOP(300) }; - enum { W = 128 }; - enum { H = 128 }; public: BitmapBench(void* param, bool isOpaque, SkBitmap::Config c, bool forceUpdate = false, bool bitmapVolatile = false, int tx = -1, int ty = -1) - : INHERITED(param) - , fIsOpaque(isOpaque) - , fForceUpdate(forceUpdate) - , fIsVolatile(bitmapVolatile) - , fTileX(tx) - , fTileY(ty) - , fConfig(c) { + : INHERITED(param), fIsOpaque(isOpaque), fForceUpdate(forceUpdate), fTileX(tx), fTileY(ty) { + const int w = 128; + const int h = 128; + SkBitmap bm; + + if (SkBitmap::kIndex8_Config == c) { + bm.setConfig(SkBitmap::kARGB_8888_Config, w, h); + } else { + bm.setConfig(c, w, h); + } + bm.allocPixels(); + bm.eraseColor(isOpaque ? SK_ColorBLACK : 0); + + drawIntoBitmap(bm); + + if (SkBitmap::kIndex8_Config == c) { + convertToIndex666(bm, &fBitmap); + } else { + fBitmap = bm; + } + + if (fBitmap.getColorTable()) { + fBitmap.getColorTable()->setIsOpaque(isOpaque); + } + fBitmap.setIsOpaque(isOpaque); + fBitmap.setIsVolatile(bitmapVolatile); } protected: @@ -111,43 +145,16 @@ protected: fName.appendf("_%s", gTileName[fTileY]); } } - fName.appendf("_%s%s", gConfigName[fConfig], + fName.appendf("_%s%s", gConfigName[fBitmap.config()], fIsOpaque ? "" : "_A"); if (fForceUpdate) fName.append("_update"); - if (fIsVolatile) + if (fBitmap.isVolatile()) fName.append("_volatile"); return fName.c_str(); } - virtual void onPreDraw() { - SkBitmap bm; - - if (SkBitmap::kIndex8_Config == fConfig) { - bm.setConfig(SkBitmap::kARGB_8888_Config, W, H); - } else { - bm.setConfig(fConfig, W, H); - } - - bm.allocPixels(); - bm.eraseColor(fIsOpaque ? SK_ColorBLACK : 0); - - onDrawIntoBitmap(bm); - - if (SkBitmap::kIndex8_Config == fConfig) { - convertToIndex666(bm, &fBitmap); - } else { - fBitmap = bm; - } - - if (fBitmap.getColorTable()) { - fBitmap.getColorTable()->setIsOpaque(fIsOpaque); - } - fBitmap.setIsOpaque(fIsOpaque); - fBitmap.setIsVolatile(fIsVolatile); - } - virtual void onDraw(SkCanvas* canvas) { SkIPoint dim = this->getSize(); SkRandom rand; @@ -170,25 +177,6 @@ protected: } } - virtual void onDrawIntoBitmap(const SkBitmap& bm) { - const int w = bm.width(); - const int h = bm.height(); - - SkCanvas canvas(bm); - SkPaint p; - p.setAntiAlias(true); - p.setColor(SK_ColorRED); - canvas.drawCircle(SkIntToScalar(w)/2, SkIntToScalar(h)/2, - SkIntToScalar(SkMin32(w, h))*3/8, p); - - SkRect r; - r.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); - p.setStyle(SkPaint::kStroke_Style); - p.setStrokeWidth(SkIntToScalar(4)); - p.setColor(SK_ColorBLUE); - canvas.drawRect(r, p); - } - private: typedef SkBenchmark INHERITED; }; @@ -253,95 +241,6 @@ private: typedef BitmapBench INHERITED; }; -/** Verify optimizations that test source alpha values. */ - -class SourceAlphaBitmapBench : public BitmapBench { -public: - enum SourceAlpha { kOpaque_SourceAlpha, kTransparent_SourceAlpha, - kTwoStripes_SourceAlpha, kThreeStripes_SourceAlpha}; -private: - SkString fFullName; - SourceAlpha fSourceAlpha; -public: - SourceAlphaBitmapBench(void* param, SourceAlpha alpha, SkBitmap::Config c, - bool forceUpdate = false, bool bitmapVolatile = false, - int tx = -1, int ty = -1) - : INHERITED(param, false, c, forceUpdate, bitmapVolatile, tx, ty) - , fSourceAlpha(alpha) { - } - -protected: - virtual const char* onGetName() { - fFullName.set(INHERITED::onGetName()); - - if (fSourceAlpha == kOpaque_SourceAlpha) { - fFullName.append("_source_opaque"); - } else if (fSourceAlpha == kTransparent_SourceAlpha) { - fFullName.append("_source_transparent"); - } else if (fSourceAlpha == kTwoStripes_SourceAlpha) { - fFullName.append("_source_stripes_two"); - } else if (fSourceAlpha == kThreeStripes_SourceAlpha) { - fFullName.append("_source_stripes_three"); - } - - return fFullName.c_str(); - } - - virtual void onDrawIntoBitmap(const SkBitmap& bm) SK_OVERRIDE { - const int w = bm.width(); - const int h = bm.height(); - - if (kOpaque_SourceAlpha == fSourceAlpha) { - bm.eraseColor(SK_ColorBLACK); - } else if (kTransparent_SourceAlpha == fSourceAlpha) { - bm.eraseColor(0); - } else if (kTwoStripes_SourceAlpha == fSourceAlpha) { - bm.eraseColor(0); - - SkCanvas canvas(bm); - SkPaint p; - p.setAntiAlias(false); - p.setStyle(SkPaint::kFill_Style); - p.setColor(SK_ColorRED); - - // Draw red vertical stripes on transparent background - SkRect r; - for (int x = 0; x < w; x+=2) - { - r.set(SkIntToScalar(x), 0, SkIntToScalar(x+1), SkIntToScalar(h)); - canvas.drawRect(r, p); - } - - } else if (kThreeStripes_SourceAlpha == fSourceAlpha) { - bm.eraseColor(0); - - SkCanvas canvas(bm); - SkPaint p; - p.setAntiAlias(false); - p.setStyle(SkPaint::kFill_Style); - - // Draw vertical stripes on transparent background with a pattern - // where the first pixel is fully transparent, the next is semi-transparent - // and the third is fully opaque. - SkRect r; - for (int x = 0; x < w; x++) - { - if (x % 3 == 0) { - continue; // Keep transparent - } else if (x % 3 == 1) { - p.setColor(SkColorSetARGB(127, 127, 127, 127)); // Semi-transparent - } else if (x % 3 == 2) { - p.setColor(SK_ColorRED); // Opaque - } - r.set(SkIntToScalar(x), 0, SkIntToScalar(x+1), SkIntToScalar(h)); - canvas.drawRect(r, p); - } - } - } - -private: - typedef BitmapBench INHERITED; -}; static SkBenchmark* Fact0(void* p) { return new BitmapBench(p, false, SkBitmap::kARGB_8888_Config); } static SkBenchmark* Fact1(void* p) { return new BitmapBench(p, true, SkBitmap::kARGB_8888_Config); } static SkBenchmark* Fact2(void* p) { return new BitmapBench(p, true, SkBitmap::kRGB_565_Config); } @@ -364,12 +263,6 @@ static SkBenchmark* Fact14(void* p) { return new FilterBitmapBench(p, true, SkBi static SkBenchmark* Fact15(void* p) { return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, true, -1, -1, true, true, true); } static SkBenchmark* Fact16(void* p) { return new FilterBitmapBench(p, true, SkBitmap::kARGB_8888_Config, true, false, -1, -1, true, true, true); } -// source alpha tests -> S32A_Opaque_BlitRow32_{arm,neon} -static SkBenchmark* Fact17(void* p) { return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kOpaque_SourceAlpha, SkBitmap::kARGB_8888_Config); } -static SkBenchmark* Fact18(void* p) { return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTransparent_SourceAlpha, SkBitmap::kARGB_8888_Config); } -static SkBenchmark* Fact19(void* p) { return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kTwoStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); } -static SkBenchmark* Fact20(void* p) { return new SourceAlphaBitmapBench(p, SourceAlphaBitmapBench::kThreeStripes_SourceAlpha, SkBitmap::kARGB_8888_Config); } - static BenchRegistry gReg0(Fact0); static BenchRegistry gReg1(Fact1); static BenchRegistry gReg2(Fact2); @@ -390,7 +283,3 @@ static BenchRegistry gReg14(Fact14); static BenchRegistry gReg15(Fact15); static BenchRegistry gReg16(Fact16); -static BenchRegistry gReg17(Fact17); -static BenchRegistry gReg18(Fact18); -static BenchRegistry gReg19(Fact19); -static BenchRegistry gReg20(Fact20); -- cgit v1.2.3