diff options
author | Florin Malita <fmalita@chromium.org> | 2017-06-07 15:03:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-07 20:24:51 +0000 |
commit | d1aeddeb8aa2d678a24511542935f1f33c2eebcd (patch) | |
tree | 356021eff018fce6c9071331ba8dff565f9e17ae | |
parent | db6365a9e267192c02d2745a654b07888f76b32e (diff) |
Remove SkLinearGradient::kForce4fContext_PrivateFlag
... and related tests/gms.
We now exercise the 4f impl with raster-pipeline/burst, no need for a
special test flag.
Change-Id: If67684d2d8840b3c413db9eeebb051f59cbc5a34
Reviewed-on: https://skia-review.googlesource.com/19025
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
-rw-r--r-- | bench/GradientBench.cpp | 60 | ||||
-rw-r--r-- | gm/gradients.cpp | 22 | ||||
-rw-r--r-- | src/shaders/gradients/SkLinearGradient.cpp | 3 | ||||
-rw-r--r-- | src/shaders/gradients/SkLinearGradient.h | 5 | ||||
-rw-r--r-- | tests/GradientTest.cpp | 20 |
5 files changed, 36 insertions, 74 deletions
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp index 2d6f5d1a65..e6c02d3335 100644 --- a/bench/GradientBench.cpp +++ b/bench/GradientBench.cpp @@ -9,7 +9,6 @@ #include "SkCanvas.h" #include "SkColorPriv.h" #include "SkGradientShader.h" -#include "SkLinearGradient.h" #include "SkPaint.h" #include "SkShader.h" #include "SkString.h" @@ -49,14 +48,12 @@ static const GradData gGradData[] = { /// Ignores scale static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { - const uint32_t flags = force4f ? SkLinearGradient::kForce4fContext_PrivateFlag : 0; - return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, - data.fCount, tm, flags, nullptr); + SkShader::TileMode tm, float scale) { + return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm); } static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center; center.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); @@ -66,7 +63,7 @@ static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, /// Ignores scale static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center; center.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); @@ -75,7 +72,7 @@ static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, /// Ignores scale static sk_sp<SkShader> MakeConical(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center0, center1; center0.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); @@ -88,7 +85,7 @@ static sk_sp<SkShader> MakeConical(const SkPoint pts[2], const GradData& data, /// Ignores scale static sk_sp<SkShader> MakeConicalZeroRad(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center0, center1; center0.set(SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY)); @@ -101,7 +98,7 @@ static sk_sp<SkShader> MakeConicalZeroRad(const SkPoint pts[2], const GradData& /// Ignores scale static sk_sp<SkShader> MakeConicalOutside(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center0, center1; SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; @@ -115,7 +112,7 @@ static sk_sp<SkShader> MakeConicalOutside(const SkPoint pts[2], const GradData& /// Ignores scale static sk_sp<SkShader> MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { SkPoint center0, center1; SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10; SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3; @@ -128,7 +125,7 @@ static sk_sp<SkShader> MakeConicalOutsideZeroRad(const SkPoint pts[2], const Gra } typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, - SkShader::TileMode tm, float scale, bool force4f); + SkShader::TileMode tm, float scale); static const struct { GradMaker fMaker; @@ -192,8 +189,7 @@ public: GradData data = gGradData[0], SkShader::TileMode tm = SkShader::kClamp_TileMode, GeomType geomType = kRect_GeomType, - float scale = 1.0f, - bool force4f = false) + float scale = 1.0f) : fGeomType(geomType) { fName.printf("gradient_%s_%s", gGrads[gradType].fName, @@ -208,15 +204,11 @@ public: fName.append(data.fName); - if (force4f) { - fName.append("_4f"); - } - this->setupPaint(&fPaint); - fPaint.setShader(MakeShader(gradType, data, tm, scale, force4f)); + fPaint.setShader(MakeShader(gradType, data, tm, scale)); } - GradientBench(GradType gradType, GradData data, bool dither, bool force4f = false) + GradientBench(GradType gradType, GradData data, bool dither) : fGeomType(kRect_GeomType) { const char *tmname = tilemodename(SkShader::kClamp_TileMode); @@ -228,7 +220,7 @@ public: } this->setupPaint(&fPaint); - fPaint.setShader(MakeShader(gradType, data, SkShader::kClamp_TileMode, 1.0f, force4f)); + fPaint.setShader(MakeShader(gradType, data, SkShader::kClamp_TileMode, 1.0f)); fPaint.setDither(dither); } @@ -260,13 +252,13 @@ private: typedef Benchmark INHERITED; sk_sp<SkShader> MakeShader(GradType gradType, GradData data, - SkShader::TileMode tm, float scale, bool force4f) { + SkShader::TileMode tm, float scale) { const SkPoint pts[2] = { { 0, 0 }, { SkIntToScalar(kSize), SkIntToScalar(kSize) } }; - return gGrads[gradType].fMaker(pts, data, tm, scale, force4f); + return gGrads[gradType].fMaker(pts, data, tm, scale); } static const int kSize = 400; @@ -276,28 +268,6 @@ private: const GeomType fGeomType; }; -// 4f -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kClamp_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1], SkShader::kClamp_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2], SkShader::kClamp_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[4], SkShader::kClamp_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kRepeat_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1], SkShader::kRepeat_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2], SkShader::kRepeat_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0], SkShader::kMirror_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1], SkShader::kMirror_TileMode, - kRect_GeomType, 1, true); ) -DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2], SkShader::kMirror_TileMode, - kRect_GeomType, 1, true); ) - DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[0]); ) DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[1]); ) DEF_BENCH( return new GradientBench(kLinear_GradType, gGradData[2]); ) diff --git a/gm/gradients.cpp b/gm/gradients.cpp index 27fd0f3462..9abd6f0e9a 100644 --- a/gm/gradients.cpp +++ b/gm/gradients.cpp @@ -8,7 +8,6 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkGradientShader.h" -#include "SkLinearGradient.h" namespace skiagm { @@ -798,7 +797,6 @@ private: uint32_t fFlags; }; DEF_GM( return new LinearGradientTinyGM(0); ) -DEF_GM( return new LinearGradientTinyGM(SkLinearGradient::kForce4fContext_PrivateFlag, "_4f"); ) } /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -891,7 +889,7 @@ DEF_SIMPLE_GM(gradients_dup_color_stops, canvas, 704, 564) { } } -static void draw_many_stops(SkCanvas* canvas, uint32_t flags) { +static void draw_many_stops(SkCanvas* canvas) { const unsigned kStopCount = 200; const SkPoint pts[] = { {50, 50}, {450, 465}}; @@ -908,34 +906,26 @@ static void draw_many_stops(SkCanvas* canvas, uint32_t flags) { SkPaint p; p.setShader(SkGradientShader::MakeLinear( - pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, flags, nullptr)); + pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode)); canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); } DEF_SIMPLE_GM(gradient_many_stops, canvas, 500, 500) { - draw_many_stops(canvas, 0); + draw_many_stops(canvas); } -DEF_SIMPLE_GM(gradient_many_stops_4f, canvas, 500, 500) { - draw_many_stops(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); -} - -static void draw_subpixel_gradient(SkCanvas* canvas, uint32_t flags) { +static void draw_subpixel_gradient(SkCanvas* canvas) { const SkPoint pts[] = { {50, 50}, {50.1f, 50.1f}}; SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE }; SkPaint p; p.setShader(SkGradientShader::MakeLinear( - pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kRepeat_TileMode, flags, nullptr)); + pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kRepeat_TileMode)); canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p); } DEF_SIMPLE_GM(gradient_subpixel, canvas, 500, 500) { - draw_subpixel_gradient(canvas, 0); -} - -DEF_SIMPLE_GM(gradient_subpixel_4f, canvas, 500, 500) { - draw_subpixel_gradient(canvas, SkLinearGradient::kForce4fContext_PrivateFlag); + draw_subpixel_gradient(canvas); } #include "SkPictureRecorder.h" diff --git a/src/shaders/gradients/SkLinearGradient.cpp b/src/shaders/gradients/SkLinearGradient.cpp index 2bce02e782..f803d5e650 100644 --- a/src/shaders/gradients/SkLinearGradient.cpp +++ b/src/shaders/gradients/SkLinearGradient.cpp @@ -43,8 +43,7 @@ static bool use_4f_context(const SkShaderBase::ContextRec& rec, uint32_t flags) #ifdef FORCE_4F_CONTEXT return true; #else - return rec.fPreferredDstType == SkShaderBase::ContextRec::kPM4f_DstType - || SkToBool(flags & SkLinearGradient::kForce4fContext_PrivateFlag); + return rec.fPreferredDstType == SkShaderBase::ContextRec::kPM4f_DstType; #endif } diff --git a/src/shaders/gradients/SkLinearGradient.h b/src/shaders/gradients/SkLinearGradient.h index 300807c1f4..caa8100c86 100644 --- a/src/shaders/gradients/SkLinearGradient.h +++ b/src/shaders/gradients/SkLinearGradient.h @@ -26,11 +26,6 @@ struct Sk4fStorage { class SkLinearGradient : public SkGradientShaderBase { public: - enum { - // Temp flag for testing the 4f impl. - kForce4fContext_PrivateFlag = 1 << 7, - }; - SkLinearGradient(const SkPoint pts[2], const Descriptor&); class LinearGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp index 732bfbc22b..3c62cb9d62 100644 --- a/tests/GradientTest.cpp +++ b/tests/GradientTest.cpp @@ -9,7 +9,6 @@ #include "SkColorPriv.h" #include "SkColorShader.h" #include "SkGradientShader.h" -#include "SkLinearGradient.h" #include "SkShader.h" #include "SkSurface.h" #include "SkTemplates.h" @@ -446,13 +445,22 @@ static void test_linear_fuzzer(skiatest::Reporter*) { }, }; - static const uint32_t gForceFlags[] = { 0, SkLinearGradient::kForce4fContext_PrivateFlag }; + sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); + SkColorSpace* colorSpaces[] = { + nullptr, // hits the legacy gradient impl + srgb.get(), // triggers 4f/raster-pipeline + }; - sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100); - SkCanvas* canvas = surface->getCanvas(); SkPaint paint; - for (auto forceFlags : gForceFlags) { + for (auto colorSpace : colorSpaces) { + + sk_sp<SkSurface> surface = SkSurface::MakeRaster(SkImageInfo::Make(100, 100, + kN32_SkColorType, + kPremul_SkAlphaType, + sk_ref_sp(colorSpace))); + SkCanvas* canvas = surface->getCanvas(); + for (const auto& config : gConfigs) { SkAutoCanvasRestore acr(canvas, false); SkTLazy<SkMatrix> localMatrix; @@ -466,7 +474,7 @@ static void test_linear_fuzzer(skiatest::Reporter*) { config.fPos, config.fCount, config.fTileMode, - config.fFlags | forceFlags, + config.fFlags, localMatrix.getMaybeNull())); if (config.fGlobalMatrix) { SkMatrix m; |