aboutsummaryrefslogtreecommitdiffstats
path: root/bench
diff options
context:
space:
mode:
authorMike Reed <reed@google.com>2009-10-19 14:58:09 -0400
committerMike Reed <reed@google.com>2009-10-19 14:58:09 -0400
commit380ef793777fc6af10838821acd61b6b999b62a8 (patch)
treeecbd6ea38bc2550904401d3177ea97f8b67b0030 /bench
parent54e0f955c21365271661cd92a29d06a847a18554 (diff)
downloadexternal_skia-380ef793777fc6af10838821acd61b6b999b62a8.zip
external_skia-380ef793777fc6af10838821acd61b6b999b62a8.tar.gz
external_skia-380ef793777fc6af10838821acd61b6b999b62a8.tar.bz2
add opaque -vs- alpha variation for bitmaps
Diffstat (limited to 'bench')
-rw-r--r--bench/BitmapBench.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/bench/BitmapBench.cpp b/bench/BitmapBench.cpp
index 89dfa74..77e7ade 100644
--- a/bench/BitmapBench.cpp
+++ b/bench/BitmapBench.cpp
@@ -92,12 +92,14 @@ static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) {
class BitmapBench : public SkBenchmark {
SkBitmap fBitmap;
SkPaint fPaint;
+ bool fIsOpaque;
int fTileX, fTileY; // -1 means don't use shader
SkString fName;
enum { N = 300 };
public:
- BitmapBench(void* param, SkBitmap::Config c, int tx = -1, int ty = -1)
- : INHERITED(param), fTileX(tx), fTileY(ty) {
+ BitmapBench(void* param, bool isOpaque, SkBitmap::Config c,
+ int tx = -1, int ty = -1)
+ : INHERITED(param), fIsOpaque(isOpaque), fTileX(tx), fTileY(ty) {
const int w = 128;
const int h = 128;
SkBitmap bm;
@@ -108,7 +110,7 @@ public:
bm.setConfig(c, w, h);
}
bm.allocPixels();
- bm.eraseColor(0);
+ bm.eraseColor(isOpaque ? SK_ColorBLACK : 0);
drawIntoBitmap(bm);
@@ -117,6 +119,11 @@ public:
} else {
fBitmap = bm;
}
+
+ if (fBitmap.getColorTable()) {
+ fBitmap.getColorTable()->setIsOpaque(isOpaque);
+ }
+ fBitmap.setIsOpaque(isOpaque);
}
protected:
@@ -128,7 +135,8 @@ protected:
fName.appendf("_%s", gTileName[fTileY]);
}
}
- fName.appendf("_%s", gConfigName[fBitmap.config()]);
+ fName.appendf("_%s%s", gConfigName[fBitmap.config()],
+ fIsOpaque ? "" : "_A");
return fName.c_str();
}
@@ -154,12 +162,18 @@ private:
typedef SkBenchmark INHERITED;
};
-static SkBenchmark* Fact0(void* p) { return new BitmapBench(p, SkBitmap::kARGB_8888_Config); }
-static SkBenchmark* Fact1(void* p) { return new BitmapBench(p, SkBitmap::kRGB_565_Config); }
-static SkBenchmark* Fact2(void* p) { return new BitmapBench(p, SkBitmap::kARGB_4444_Config); }
-static SkBenchmark* Fact3(void* p) { return new BitmapBench(p, SkBitmap::kIndex8_Config); }
+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); }
+static SkBenchmark* Fact3(void* p) { return new BitmapBench(p, false, SkBitmap::kARGB_4444_Config); }
+static SkBenchmark* Fact4(void* p) { return new BitmapBench(p, true, SkBitmap::kARGB_4444_Config); }
+static SkBenchmark* Fact5(void* p) { return new BitmapBench(p, false, SkBitmap::kIndex8_Config); }
+static SkBenchmark* Fact6(void* p) { return new BitmapBench(p, true, SkBitmap::kIndex8_Config); }
static BenchRegistry gReg0(Fact0);
static BenchRegistry gReg1(Fact1);
static BenchRegistry gReg2(Fact2);
static BenchRegistry gReg3(Fact3);
+static BenchRegistry gReg4(Fact4);
+static BenchRegistry gReg5(Fact5);
+static BenchRegistry gReg6(Fact6);