Remove SK_SUPPORT_LEGACY_GRADIENT_DITHERING from Skia proper
Migrating the flag to embedder defines (Chromium already guarded). Also augment gradient-focused GMs to generate both dithered/undithered results. BUG=skia:4436 R=reed@google.com,robertphillips@google.com Review URL: https://codereview.chromium.org/1400813006
This commit is contained in:
parent
afa95e270c
commit
063675ba37
111
gm/gradients.cpp
111
gm/gradients.cpp
@ -100,14 +100,14 @@ static const GradMaker gGradMakers[] = {
|
|||||||
|
|
||||||
class GradientsGM : public GM {
|
class GradientsGM : public GM {
|
||||||
public:
|
public:
|
||||||
GradientsGM() {
|
GradientsGM(bool dither) : fDither(dither) {
|
||||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SkString onShortName() {
|
SkString onShortName() {
|
||||||
return SkString("gradients");
|
return SkString(fDither ? "gradients" : "gradients_nodither");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() { return SkISize::Make(840, 815); }
|
virtual SkISize onISize() { return SkISize::Make(840, 815); }
|
||||||
@ -122,6 +122,7 @@ protected:
|
|||||||
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
|
|
||||||
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
|
||||||
@ -146,23 +147,28 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new GradientsGM; )
|
DEF_GM( return new GradientsGM(true); )
|
||||||
|
DEF_GM( return new GradientsGM(false); )
|
||||||
|
|
||||||
// Based on the original gradient slide, but with perspective applied to the
|
// Based on the original gradient slide, but with perspective applied to the
|
||||||
// gradient shaders' local matrices
|
// gradient shaders' local matrices
|
||||||
class GradientsLocalPerspectiveGM : public GM {
|
class GradientsLocalPerspectiveGM : public GM {
|
||||||
public:
|
public:
|
||||||
GradientsLocalPerspectiveGM() {
|
GradientsLocalPerspectiveGM(bool dither) : fDither(dither) {
|
||||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SkString onShortName() {
|
SkString onShortName() {
|
||||||
return SkString("gradients_local_perspective");
|
return SkString(fDither ? "gradients_local_perspective" :
|
||||||
|
"gradients_local_perspective_nodither");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() { return SkISize::Make(840, 815); }
|
virtual SkISize onISize() { return SkISize::Make(840, 815); }
|
||||||
@ -177,6 +183,7 @@ protected:
|
|||||||
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
|
|
||||||
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
|
||||||
@ -201,16 +208,23 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new GradientsLocalPerspectiveGM; )
|
DEF_GM( return new GradientsLocalPerspectiveGM(true); )
|
||||||
|
DEF_GM( return new GradientsLocalPerspectiveGM(false); )
|
||||||
|
|
||||||
// Based on the original gradient slide, but with perspective applied to
|
// Based on the original gradient slide, but with perspective applied to
|
||||||
// the view matrix
|
// the view matrix
|
||||||
class GradientsViewPerspectiveGM : public GradientsGM {
|
class GradientsViewPerspectiveGM : public GradientsGM {
|
||||||
|
public:
|
||||||
|
GradientsViewPerspectiveGM(bool dither) : INHERITED(dither) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() {
|
SkString onShortName() {
|
||||||
return SkString("gradients_view_perspective");
|
return SkString(fDither ? "gradients_view_perspective" :
|
||||||
|
"gradients_view_perspective_nodither");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() { return SkISize::Make(840, 500); }
|
virtual SkISize onISize() { return SkISize::Make(840, 500); }
|
||||||
@ -227,7 +241,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
typedef GradientsGM INHERITED;
|
typedef GradientsGM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new GradientsViewPerspectiveGM; )
|
DEF_GM( return new GradientsViewPerspectiveGM(true); )
|
||||||
|
DEF_GM( return new GradientsViewPerspectiveGM(false); )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Inspired by this <canvas> javascript, where we need to detect that we are not
|
Inspired by this <canvas> javascript, where we need to detect that we are not
|
||||||
@ -247,11 +262,11 @@ DEF_GM( return new GradientsViewPerspectiveGM; )
|
|||||||
*/
|
*/
|
||||||
class GradientsDegenrate2PointGM : public GM {
|
class GradientsDegenrate2PointGM : public GM {
|
||||||
public:
|
public:
|
||||||
GradientsDegenrate2PointGM() {}
|
GradientsDegenrate2PointGM(bool dither) : fDither(dither) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() {
|
SkString onShortName() {
|
||||||
return SkString("gradients_degenerate_2pt");
|
return SkString(fDither ? "gradients_degenerate_2pt" : "gradients_degenerate_2pt_nodither");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() { return SkISize::Make(320, 320); }
|
virtual SkISize onISize() { return SkISize::Make(320, 320); }
|
||||||
@ -275,23 +290,29 @@ protected:
|
|||||||
pos, SK_ARRAY_COUNT(pos),
|
pos, SK_ARRAY_COUNT(pos),
|
||||||
SkShader::kClamp_TileMode);
|
SkShader::kClamp_TileMode);
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
paint.setDither(fDither);
|
||||||
paint.setShader(s)->unref();
|
paint.setShader(s)->unref();
|
||||||
canvas->drawPaint(paint);
|
canvas->drawPaint(paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new GradientsDegenrate2PointGM; )
|
DEF_GM( return new GradientsDegenrate2PointGM(true); )
|
||||||
|
DEF_GM( return new GradientsDegenrate2PointGM(false); )
|
||||||
|
|
||||||
/// Tests correctness of *optimized* codepaths in gradients.
|
/// Tests correctness of *optimized* codepaths in gradients.
|
||||||
|
|
||||||
class ClampedGradientsGM : public GM {
|
class ClampedGradientsGM : public GM {
|
||||||
public:
|
public:
|
||||||
ClampedGradientsGM() {}
|
ClampedGradientsGM(bool dither) : fDither(dither) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() { return SkString("clamped_gradients"); }
|
SkString onShortName() {
|
||||||
|
return SkString(fDither ? "clamped_gradients" : "clamped_gradients_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
virtual SkISize onISize() { return SkISize::Make(640, 510); }
|
virtual SkISize onISize() { return SkISize::Make(640, 510); }
|
||||||
|
|
||||||
@ -304,6 +325,7 @@ protected:
|
|||||||
|
|
||||||
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(300) };
|
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(300) };
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
paint.setDither(fDither);
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
|
||||||
SkPoint center;
|
SkPoint center;
|
||||||
@ -319,9 +341,12 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new ClampedGradientsGM; )
|
DEF_GM( return new ClampedGradientsGM(true); )
|
||||||
|
DEF_GM( return new ClampedGradientsGM(false); )
|
||||||
|
|
||||||
/// Checks quality of large radial gradients, which may display
|
/// Checks quality of large radial gradients, which may display
|
||||||
/// some banding.
|
/// some banding.
|
||||||
@ -368,11 +393,14 @@ DEF_GM( return new RadialGradientGM; )
|
|||||||
|
|
||||||
class RadialGradient2GM : public GM {
|
class RadialGradient2GM : public GM {
|
||||||
public:
|
public:
|
||||||
RadialGradient2GM() {}
|
RadialGradient2GM(bool dither) : fDither(dither) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SkString onShortName() override { return SkString("radial_gradient2"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "radial_gradient2" : "radial_gradient2_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
SkISize onISize() override { return SkISize::Make(800, 400); }
|
SkISize onISize() override { return SkISize::Make(800, 400); }
|
||||||
void drawBG(SkCanvas* canvas) {
|
void drawBG(SkCanvas* canvas) {
|
||||||
canvas->drawColor(0xFF000000);
|
canvas->drawColor(0xFF000000);
|
||||||
@ -414,8 +442,11 @@ protected:
|
|||||||
SkShader::kClamp_TileMode,
|
SkShader::kClamp_TileMode,
|
||||||
flags[i], nullptr));
|
flags[i], nullptr));
|
||||||
paint1.setShader(sweep);
|
paint1.setShader(sweep);
|
||||||
|
paint1.setDither(fDither);
|
||||||
paint2.setShader(radial1);
|
paint2.setShader(radial1);
|
||||||
|
paint2.setDither(fDither);
|
||||||
paint3.setShader(radial2);
|
paint3.setShader(radial2);
|
||||||
|
paint3.setDither(fDither);
|
||||||
|
|
||||||
canvas->drawCircle(cx, cy, radius, paint1);
|
canvas->drawCircle(cx, cy, radius, paint1);
|
||||||
canvas->drawCircle(cx, cy, radius, paint3);
|
canvas->drawCircle(cx, cy, radius, paint3);
|
||||||
@ -426,16 +457,22 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new RadialGradient2GM; )
|
DEF_GM( return new RadialGradient2GM(true); )
|
||||||
|
DEF_GM( return new RadialGradient2GM(false); )
|
||||||
|
|
||||||
// Shallow radial (shows banding on raster)
|
// Shallow radial (shows banding on raster)
|
||||||
class RadialGradient3GM : public GM {
|
class RadialGradient3GM : public GM {
|
||||||
SkAutoTUnref<SkShader> fShader;
|
public:
|
||||||
|
RadialGradient3GM(bool dither) : fDither(dither) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() override { return SkString("radial_gradient3"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "radial_gradient3" : "radial_gradient3_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
SkISize onISize() override { return SkISize::Make(500, 500); }
|
SkISize onISize() override { return SkISize::Make(500, 500); }
|
||||||
|
|
||||||
@ -452,19 +489,27 @@ protected:
|
|||||||
void onDraw(SkCanvas* canvas) override {
|
void onDraw(SkCanvas* canvas) override {
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setShader(fShader);
|
paint.setShader(fShader);
|
||||||
|
paint.setDither(fDither);
|
||||||
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
|
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SkAutoTUnref<SkShader> fShader;
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new RadialGradient3GM; )
|
DEF_GM( return new RadialGradient3GM(true); )
|
||||||
|
DEF_GM( return new RadialGradient3GM(false); )
|
||||||
|
|
||||||
class RadialGradient4GM : public GM {
|
class RadialGradient4GM : public GM {
|
||||||
SkAutoTUnref<SkShader> fShader;
|
public:
|
||||||
|
RadialGradient4GM(bool dither) : fDither(dither) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() override { return SkString("radial_gradient4"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "radial_gradient4" : "radial_gradient4_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
SkISize onISize() override { return SkISize::Make(500, 500); }
|
SkISize onISize() override { return SkISize::Make(500, 500); }
|
||||||
|
|
||||||
@ -481,20 +526,29 @@ protected:
|
|||||||
void onDraw(SkCanvas* canvas) override {
|
void onDraw(SkCanvas* canvas) override {
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
paint.setShader(fShader);
|
paint.setShader(fShader);
|
||||||
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
|
canvas->drawRect(SkRect::MakeWH(500, 500), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SkAutoTUnref<SkShader> fShader;
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new RadialGradient4GM; )
|
DEF_GM( return new RadialGradient4GM(true); )
|
||||||
|
DEF_GM( return new RadialGradient4GM(false); )
|
||||||
|
|
||||||
class LinearGradientGM : public GM {
|
class LinearGradientGM : public GM {
|
||||||
SkAutoTUnref<SkShader> fShader[100];
|
public:
|
||||||
|
LinearGradientGM(bool dither) : fDither(dither) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkString onShortName() override { return SkString("linear_gradient"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "linear_gradient" : "linear_gradient_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
const SkScalar kWidthBump = 30.f;
|
const SkScalar kWidthBump = 30.f;
|
||||||
const SkScalar kHeight = 5.f;
|
const SkScalar kHeight = 5.f;
|
||||||
const SkScalar kMinWidth = 540.f;
|
const SkScalar kMinWidth = 540.f;
|
||||||
@ -521,6 +575,7 @@ protected:
|
|||||||
void onDraw(SkCanvas* canvas) override {
|
void onDraw(SkCanvas* canvas) override {
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
for (int index = 0; index < (int) SK_ARRAY_COUNT(fShader); ++index) {
|
for (int index = 0; index < (int) SK_ARRAY_COUNT(fShader); ++index) {
|
||||||
paint.setShader(fShader[index]);
|
paint.setShader(fShader[index]);
|
||||||
canvas->drawRect(SkRect::MakeLTRB(0, index * kHeight, kMinWidth + index * kWidthBump,
|
canvas->drawRect(SkRect::MakeLTRB(0, index * kHeight, kMinWidth + index * kWidthBump,
|
||||||
@ -529,8 +584,12 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SkAutoTUnref<SkShader> fShader[100];
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
DEF_GM( return new LinearGradientGM; )
|
DEF_GM( return new LinearGradientGM(true); )
|
||||||
|
DEF_GM( return new LinearGradientGM(false); )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -305,10 +305,12 @@ enum GradCaseType { // these must match the order in gGradCases
|
|||||||
|
|
||||||
class ConicalGradientsGM : public GM {
|
class ConicalGradientsGM : public GM {
|
||||||
public:
|
public:
|
||||||
ConicalGradientsGM(GradCaseType gradCaseType) {
|
ConicalGradientsGM(GradCaseType gradCaseType, bool dither)
|
||||||
|
: fGradCaseType(gradCaseType)
|
||||||
|
, fDither(dither) {
|
||||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||||
fName.printf("gradients_2pt_conical_%s", gGradCases[gradCaseType].fName);
|
fName.printf("gradients_2pt_conical_%s%s", gGradCases[gradCaseType].fName,
|
||||||
fGradCaseType = gradCaseType;
|
fDither ? "" : "_nodither");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -328,6 +330,7 @@ protected:
|
|||||||
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
|
|
||||||
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
||||||
|
|
||||||
@ -360,15 +363,16 @@ private:
|
|||||||
|
|
||||||
GradCaseType fGradCaseType;
|
GradCaseType fGradCaseType;
|
||||||
SkString fName;
|
SkString fName;
|
||||||
|
bool fDither;
|
||||||
};
|
};
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static GM* MyFactory1(void*) { return new ConicalGradientsGM(kInside_GradCaseType); }
|
DEF_GM( return new ConicalGradientsGM(kInside_GradCaseType, true); )
|
||||||
static GMRegistry reg1(MyFactory1);
|
DEF_GM( return new ConicalGradientsGM(kOutside_GradCaseType, true); )
|
||||||
|
DEF_GM( return new ConicalGradientsGM(kEdge_GradCaseType, true); )
|
||||||
|
|
||||||
static GM* MyFactory2(void*) { return new ConicalGradientsGM(kOutside_GradCaseType); }
|
DEF_GM( return new ConicalGradientsGM(kInside_GradCaseType, false); )
|
||||||
static GMRegistry reg2(MyFactory2);
|
DEF_GM( return new ConicalGradientsGM(kOutside_GradCaseType, false); )
|
||||||
|
DEF_GM( return new ConicalGradientsGM(kEdge_GradCaseType, false); )
|
||||||
|
|
||||||
static GM* MyFactory3(void*) { return new ConicalGradientsGM(kEdge_GradCaseType); }
|
|
||||||
static GMRegistry reg3(MyFactory3);
|
|
||||||
}
|
}
|
||||||
|
@ -80,13 +80,16 @@ static const GradMaker gGradMakers[] = {
|
|||||||
|
|
||||||
class GradientsNoTextureGM : public GM {
|
class GradientsNoTextureGM : public GM {
|
||||||
public:
|
public:
|
||||||
GradientsNoTextureGM() {
|
GradientsNoTextureGM(bool dither) : fDither(dither) {
|
||||||
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SkString onShortName() override { return SkString("gradients_no_texture"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "gradients_no_texture" : "gradients_no_texture_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
SkISize onISize() override { return SkISize::Make(640, 615); }
|
SkISize onISize() override { return SkISize::Make(640, 615); }
|
||||||
|
|
||||||
void onDraw(SkCanvas* canvas) override {
|
void onDraw(SkCanvas* canvas) override {
|
||||||
@ -96,6 +99,7 @@ protected:
|
|||||||
SkRect kRect = { 0, 0, SkIntToScalar(50), SkIntToScalar(50) };
|
SkRect kRect = { 0, 0, SkIntToScalar(50), SkIntToScalar(50) };
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(fDither);
|
||||||
|
|
||||||
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
|
||||||
static const uint8_t kAlphas[] = { 0xff, 0x40 };
|
static const uint8_t kAlphas[] = { 0xff, 0x40 };
|
||||||
@ -116,6 +120,8 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -205,11 +211,14 @@ class GradientsManyColorsGM : public GM {
|
|||||||
|
|
||||||
typedef void (*Proc)(ColorPos*);
|
typedef void (*Proc)(ColorPos*);
|
||||||
public:
|
public:
|
||||||
GradientsManyColorsGM() {}
|
GradientsManyColorsGM(bool dither) : fDither(dither) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
SkString onShortName() override { return SkString("gradients_many"); }
|
SkString onShortName() override {
|
||||||
|
return SkString(fDither ? "gradients_many" : "gradients_many_nodither");
|
||||||
|
}
|
||||||
|
|
||||||
SkISize onISize() override { return SkISize::Make(850, 100); }
|
SkISize onISize() override { return SkISize::Make(850, 100); }
|
||||||
|
|
||||||
void onDraw(SkCanvas* canvas) override {
|
void onDraw(SkCanvas* canvas) override {
|
||||||
@ -223,6 +232,7 @@ protected:
|
|||||||
const SkRect r = SkRect::MakeWH(SkIntToScalar(W), 30);
|
const SkRect r = SkRect::MakeWH(SkIntToScalar(W), 30);
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
paint.setDither(fDither);
|
||||||
|
|
||||||
canvas->translate(20, 20);
|
canvas->translate(20, 20);
|
||||||
|
|
||||||
@ -243,10 +253,14 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef GM INHERITED;
|
typedef GM INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DEF_GM(return new GradientsNoTextureGM);
|
DEF_GM(return new GradientsNoTextureGM(true);)
|
||||||
DEF_GM(return new GradientsManyColorsGM);
|
DEF_GM(return new GradientsNoTextureGM(false);)
|
||||||
|
DEF_GM(return new GradientsManyColorsGM(true);)
|
||||||
|
DEF_GM(return new GradientsManyColorsGM(false);)
|
||||||
|
@ -37,7 +37,9 @@ static SkShader* shader_sweep(const SkColor colors[], int count, const SkSize& s
|
|||||||
|
|
||||||
class ShallowGradientGM : public skiagm::GM {
|
class ShallowGradientGM : public skiagm::GM {
|
||||||
public:
|
public:
|
||||||
ShallowGradientGM(MakeShaderProc proc, const char name[]) : fProc(proc) {
|
ShallowGradientGM(MakeShaderProc proc, const char name[], bool dither)
|
||||||
|
: fProc(proc)
|
||||||
|
, fDither(dither) {
|
||||||
fName.printf("shallow_gradient_%s", name);
|
fName.printf("shallow_gradient_%s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,19 +63,26 @@ protected:
|
|||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setShader(fProc(colors, colorCount, size))->unref();
|
paint.setShader(fProc(colors, colorCount, size))->unref();
|
||||||
|
paint.setDither(fDither);
|
||||||
canvas->drawRect(r, paint);
|
canvas->drawRect(r, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MakeShaderProc fProc;
|
MakeShaderProc fProc;
|
||||||
SkString fName;
|
SkString fName;
|
||||||
|
bool fDither;
|
||||||
|
|
||||||
typedef skiagm::GM INHERITED;
|
typedef skiagm::GM INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DEF_GM( return new ShallowGradientGM(shader_linear, "linear"); )
|
DEF_GM( return new ShallowGradientGM(shader_linear, "linear", true); )
|
||||||
DEF_GM( return new ShallowGradientGM(shader_radial, "radial"); )
|
DEF_GM( return new ShallowGradientGM(shader_radial, "radial", true); )
|
||||||
DEF_GM( return new ShallowGradientGM(shader_conical, "conical"); )
|
DEF_GM( return new ShallowGradientGM(shader_conical, "conical", true); )
|
||||||
DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep"); )
|
DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep", true); )
|
||||||
|
|
||||||
|
DEF_GM( return new ShallowGradientGM(shader_linear, "linear_nodither", false); )
|
||||||
|
DEF_GM( return new ShallowGradientGM(shader_radial, "radial_nodither", false); )
|
||||||
|
DEF_GM( return new ShallowGradientGM(shader_conical, "conical_nodither", false); )
|
||||||
|
DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep_nodither", false); )
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
# Needed until we fix skbug.com/2440.
|
# Needed until we fix skbug.com/2440.
|
||||||
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
|
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
|
||||||
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
|
'SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS',
|
||||||
|
'SK_SUPPORT_LEGACY_GRADIENT_DITHERING',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,6 @@ bool SkGradientShaderBase::onAsLuminanceColor(SkColor* lum) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SK_SUPPORT_LEGACY_GRADIENT_DITHERING
|
|
||||||
|
|
||||||
SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext(
|
SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext(
|
||||||
const SkGradientShaderBase& shader, const ContextRec& rec)
|
const SkGradientShaderBase& shader, const ContextRec& rec)
|
||||||
: INHERITED(shader, rec)
|
: INHERITED(shader, rec)
|
||||||
|
Loading…
Reference in New Issue
Block a user