Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: bench/GradientBench.cpp

Issue 321253002: Simple GPU based dithering (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Erroneous flag updated Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | src/gpu/SkGr.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/GradientBench.cpp
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp
index fa07bce4fd1f1404f686b9ee44584765782b226e..671134062c0225ae5bcd8595e0588e1d6b41e337 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -34,12 +34,15 @@ static const SkColor gColors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE, SK_ColorBLACK, // 10 lines, 50 colors
};
+static const SkColor gShallowColors[] = { 0xFF555555, 0xFF444444 };
+
// We have several special-cases depending on the number (and spacing) of colors, so
// try to exercise those here.
static const GradData gGradData[] = {
{ 2, gColors, NULL, "" },
{ 50, gColors, NULL, "_hicolor" }, // many color gradient
{ 3, gColors, NULL, "_3color" },
+ { 2, gShallowColors, NULL, "_shallow" },
};
/// Ignores scale
@@ -200,12 +203,22 @@ static const char* geomtypename(GeomType gt) {
class GradientBench : public SkBenchmark {
SkString fName;
SkShader* fShader;
+ bool fDither;
enum {
W = 400,
H = 400,
kRepeat = 15,
};
public:
+ SkShader* makeShader(GradType gradType, GradData data, SkShader::TileMode tm, float scale) {
+ const SkPoint pts[2] = {
+ { 0, 0 },
+ { SkIntToScalar(W), SkIntToScalar(H) }
+ };
+
+ return gGrads[gradType].fMaker(pts, data, tm, scale);
+ }
+
GradientBench(GradType gradType,
GradData data = gGradData[0],
SkShader::TileMode tm = SkShader::kClamp_TileMode,
@@ -224,15 +237,27 @@ public:
fName.append(data.fName);
- const SkPoint pts[2] = {
- { 0, 0 },
- { SkIntToScalar(W), SkIntToScalar(H) }
- };
-
- fShader = gGrads[gradType].fMaker(pts, data, tm, scale);
+ fDither = false;
+ fShader = this->makeShader(gradType, data, tm, scale);
fGeomType = geomType;
}
+ GradientBench(GradType gradType, GradData data, bool dither) {
+ const char *tmname = tilemodename(SkShader::kClamp_TileMode);
+ fName.printf("gradient_%s_%s", gGrads[gradType].fName, tmname);
+ fName.append(data.fName);
+
+ if (dither) {
+ fDither = true;
egdaniel 2014/06/19 13:41:28 can we just do fDither = dither? Then no need for
krajcevski 2014/06/19 13:51:43 Done.
+ fName.appendf("_dither");
+ } else {
+ fDither = false;
+ }
+
+ fShader = this->makeShader(gradType, data, SkShader::kClamp_TileMode, 1.0f);
+ fGeomType = kRect_GeomType;
+ }
+
virtual ~GradientBench() {
fShader->unref();
}
@@ -247,6 +272,9 @@ protected:
this->setupPaint(&paint);
paint.setShader(fShader);
+ if (fDither) {
+ paint.setDither(true);
+ }
SkRect r = { 0, 0, SkIntToScalar(W), SkIntToScalar(H) };
for (int i = 0; i < loops * kRepeat; i++) {
@@ -304,6 +332,16 @@ DEF_BENCH( return new GradientBench(kConicalOutZero_GradType); )
DEF_BENCH( return new GradientBench(kConicalOutZero_GradType, gGradData[1]); )
DEF_BENCH( return new GradientBench(kConicalOutZero_GradType, gGradData[2]); )
+// Dithering
+DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[3], true); )
+DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[3], false); )
+DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[3], true); )
+DEF_BENCH( return new GradientBench(kRadial_GradType, gGradData[3], false); )
+DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[3], true); )
+DEF_BENCH( return new GradientBench(kSweep_GradType, gGradData[3], false); )
+DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[3], true); )
+DEF_BENCH( return new GradientBench(kConical_GradType, gGradData[3], false); )
+
///////////////////////////////////////////////////////////////////////////////
class Gradient2Bench : public SkBenchmark {
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | src/gpu/SkGr.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698