Revert of more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium.org/1789633002/ )
Reason for revert:
seems to have changed pictureshadertile
Original issue's description:
> more shader-->sp conversions
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1789633002
>
> Committed: https://skia.googlesource.com/skia/+/ce563cdd48ec7ce4e0420dd88760df9be9dba50c
TBR=fmalita@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1790353002
diff --git a/gm/gradientDirtyLaundry.cpp b/gm/gradientDirtyLaundry.cpp
index 3fca7f2..8ef5fc9 100644
--- a/gm/gradientDirtyLaundry.cpp
+++ b/gm/gradientDirtyLaundry.cpp
@@ -35,22 +35,27 @@
// { 2, gCol2, nullptr },
};
-static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
+static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
- return SkGradientShader::MakeRadial(pt, pt.fX, data.fColors, data.fPos, data.fCount, tm);
+static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ SkPoint center;
+ center.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
+ data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
- const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) };
- return SkGradientShader::MakeSweep(pt.fX, pt.fY, data.fColors, data.fPos, data.fCount);
+static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
+ SkPoint center;
+ center.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkShader::TileMode);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep,
@@ -81,7 +86,8 @@
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
- paint.setShader(gGradMakers[j](pts, gGradData[i], tm));
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
+ paint.setShader(shader)->unref();
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
}
diff --git a/gm/gradient_matrix.cpp b/gm/gradient_matrix.cpp
index 8168918..8f665a1 100644
--- a/gm/gradient_matrix.cpp
+++ b/gm/gradient_matrix.cpp
@@ -61,22 +61,22 @@
static const int IMAGES_X = 4; // number of images per row
-static sk_sp<SkShader> make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
- return SkGradientShader::MakeLinear(pts, gColors, nullptr, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, 0, &localMatrix);
+static SkShader* make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
+ return SkGradientShader::CreateLinear(pts, gColors, nullptr, SK_ARRAY_COUNT(gColors),
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
-static sk_sp<SkShader> make_radial_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
+static SkShader* make_radial_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
float radius = (center - pts[0]).length();
- return SkGradientShader::MakeRadial(center, radius, gColors, nullptr, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, 0, &localMatrix);
+ return SkGradientShader::CreateRadial(center, radius, gColors, nullptr, SK_ARRAY_COUNT(gColors),
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
static void draw_gradients(SkCanvas* canvas,
- sk_sp<SkShader> (*makeShader)(const SkPoint[2], const SkMatrix&),
+ SkShader* (*makeShader)(const SkPoint[2], const SkMatrix&),
const SkPoint ptsArray[][2], int numImages) {
// Use some nice prime numbers for the rectangle and matrix with
// different scaling along the x and y axes (which is the bug this
@@ -97,8 +97,11 @@
canvas->save();
}
+ // Setup shader and draw.
+ SkAutoTUnref<SkShader> shader(makeShader(*ptsArray, shaderMat));
+
SkPaint paint;
- paint.setShader(makeShader(*ptsArray, shaderMat));
+ paint.setShader(shader);
canvas->drawRect(rectGrad, paint);
// Advance to next position.
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index 29d0f31..eeb5bcb 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -40,57 +40,59 @@
{ 4, gColorClamp, gPosClamp }
};
-static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
- return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm, 0,
- &localMatrix);
+static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
+ return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeRadial(center, center.fX, data.fColors, data.fPos, data.fCount,
- tm, 0, &localMatrix);
+ return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
+ data.fPos, data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode, const SkMatrix& localMatrix) {
+static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode, const SkMatrix& localMatrix) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount,
- 0, &localMatrix);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors,
+ data.fPos, data.fCount, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(
+ center1, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
}
-static sk_sp<SkShader> Make2Conical(const SkPoint pts[2], const GradData& data,
+static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0,
- data.fColors, data.fPos,
- data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center1, radius1,
+ center0, radius0,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical
};
@@ -134,8 +136,11 @@
scale.postTranslate(25.f, 25.f);
}
- paint.setShader(gGradMakers[j](pts, gGradData[i], tm, scale));
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, scale);
+
+ paint.setShader(shader);
canvas->drawRect(r, paint);
+ shader->unref();
canvas->translate(0, SkIntToScalar(120));
}
canvas->restore();
@@ -191,8 +196,11 @@
perspective.setPerspY(SkIntToScalar(i+1) / 500);
perspective.setSkewX(SkIntToScalar(i+1) / 10);
- paint.setShader(gGradMakers[j](pts, gGradData[i], tm, perspective));
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, perspective);
+
+ paint.setShader(shader);
canvas->drawRect(r, paint);
+ shader->unref();
canvas->translate(0, SkIntToScalar(120));
}
canvas->restore();
@@ -279,11 +287,12 @@
SkPoint c1;
c1.iset(0, 25);
SkScalar r1 = SkIntToScalar(150);
- SkPaint paint;
- paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors,
+ SkShader* s = SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1, colors,
pos, SK_ARRAY_COUNT(pos),
- SkShader::kClamp_TileMode));
+ SkShader::kClamp_TileMode);
+ SkPaint paint;
paint.setDither(fDither);
+ paint.setShader(s)->unref();
canvas->drawPaint(paint);
}
@@ -320,13 +329,13 @@
SkScalar r0 = 20;
SkPoint c1 = { 200, 25 };
SkScalar r1 = 10;
-
+ SkShader* s = SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1, colors,
+ pos, SK_ARRAY_COUNT(pos),
+ SkShader::kClamp_TileMode);
SkPaint paint;
paint.setColor(SK_ColorYELLOW);
canvas->drawRect(SkRect::MakeWH(100, 150), paint);
- paint.setShader(SkGradientShader::MakeTwoPointConical(c0, r0, c1, r1, colors, pos,
- SK_ARRAY_COUNT(pos),
- SkShader::kClamp_TileMode));
+ paint.setShader(s)->unref();
canvas->drawRect(SkRect::MakeWH(100, 150), paint);
}
@@ -359,11 +368,13 @@
SkPoint center;
center.iset(0, 300);
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
- paint.setShader(SkGradientShader::MakeRadial(
+ SkShader* shader = SkGradientShader::CreateRadial(
SkPoint(center),
SkIntToScalar(200), gColors, nullptr, 5,
- SkShader::kClamp_TileMode));
+ SkShader::kClamp_TileMode);
+ paint.setShader(shader);
canvas->drawRect(r, paint);
+ shader->unref();
}
private:
@@ -402,9 +413,11 @@
const SkScalar pos[] = { 0.0f,
0.35f,
1.0f };
- paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, pos,
- SK_ARRAY_COUNT(pos),
- SkShader::kClamp_TileMode));
+ SkShader* shader =
+ SkGradientShader::CreateRadial(center, radius, colors,
+ pos, SK_ARRAY_COUNT(pos),
+ SkShader::kClamp_TileMode);
+ paint.setShader(shader)->unref();
SkRect r = {
0, 0, SkIntToScalar(dim.width()), SkIntToScalar(dim.height())
};
@@ -451,19 +464,25 @@
const uint32_t flags[] = { 0, SkGradientShader::kInterpolateColorsInPremul_Flag };
for (size_t i = 0; i < SK_ARRAY_COUNT(flags); i++) {
- paint1.setShader(SkGradientShader::MakeSweep(cx, cy, sweep_colors,
- nullptr, SK_ARRAY_COUNT(sweep_colors),
- flags[i], nullptr));
- paint2.setShader(SkGradientShader::MakeRadial(center, radius, colors1,
- nullptr, SK_ARRAY_COUNT(colors1),
- SkShader::kClamp_TileMode,
- flags[i], nullptr));
- paint3.setShader(SkGradientShader::MakeRadial(center, radius, colors2,
- nullptr, SK_ARRAY_COUNT(colors2),
- SkShader::kClamp_TileMode,
- flags[i], nullptr));
+ SkAutoTUnref<SkShader> sweep(
+ SkGradientShader::CreateSweep(cx, cy, sweep_colors,
+ nullptr, SK_ARRAY_COUNT(sweep_colors),
+ flags[i], nullptr));
+ SkAutoTUnref<SkShader> radial1(
+ SkGradientShader::CreateRadial(center, radius, colors1,
+ nullptr, SK_ARRAY_COUNT(colors1),
+ SkShader::kClamp_TileMode,
+ flags[i], nullptr));
+ SkAutoTUnref<SkShader> radial2(
+ SkGradientShader::CreateRadial(center, radius, colors2,
+ nullptr, SK_ARRAY_COUNT(colors2),
+ SkShader::kClamp_TileMode,
+ flags[i], nullptr));
+ paint1.setShader(sweep);
paint1.setDither(fDither);
+ paint2.setShader(radial1);
paint2.setDither(fDither);
+ paint3.setShader(radial2);
paint3.setDither(fDither);
canvas->drawCircle(cx, cy, radius, paint1);
@@ -500,8 +519,8 @@
const SkPoint center = { 0, 0 };
const SkScalar kRadius = 3000;
const SkColor gColors[] = { 0xFFFFFFFF, 0xFF000000 };
- fShader = SkGradientShader::MakeRadial(center, kRadius, gColors, nullptr, 2,
- SkShader::kClamp_TileMode);
+ fShader.reset(SkGradientShader::CreateRadial(center, kRadius, gColors, nullptr, 2,
+ SkShader::kClamp_TileMode));
}
void onDraw(SkCanvas* canvas) override {
@@ -512,7 +531,7 @@
}
private:
- sk_sp<SkShader> fShader;
+ SkAutoTUnref<SkShader> fShader;
bool fDither;
typedef GM INHERITED;
@@ -537,8 +556,8 @@
const SkColor colors[] = { SK_ColorRED, SK_ColorRED, SK_ColorWHITE, SK_ColorWHITE,
SK_ColorRED };
const SkScalar pos[] = { 0, .4f, .4f, .8f, .8f, 1 };
- fShader = SkGradientShader::MakeRadial(center, kRadius, colors, pos,
- SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode);
+ fShader.reset(SkGradientShader::CreateRadial(center, kRadius, colors, pos,
+ SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode));
}
void onDraw(SkCanvas* canvas) override {
@@ -550,7 +569,7 @@
}
private:
- sk_sp<SkShader> fShader;
+ SkAutoTUnref<SkShader> fShader;
bool fDither;
typedef GM INHERITED;
@@ -585,8 +604,8 @@
for (int inner = 0; inner < (int) SK_ARRAY_COUNT(unitPos); ++inner) {
pos[inner] = unitPos[inner] / (kMinWidth + index * kWidthBump);
}
- fShader[index] = SkGradientShader::MakeLinear(pts, colors, pos,
- SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode);
+ fShader[index].reset(SkGradientShader::CreateLinear(pts, colors, pos,
+ SK_ARRAY_COUNT(gColors), SkShader::kClamp_TileMode));
}
}
@@ -602,7 +621,7 @@
}
private:
- sk_sp<SkShader> fShader[100];
+ SkAutoTUnref<SkShader> fShader[100];
bool fDither;
typedef GM INHERITED;
@@ -654,12 +673,13 @@
SkPaint paint;
for (unsigned i = 0; i < SK_ARRAY_COUNT(configs); ++i) {
SkAutoCanvasRestore acr(canvas, true);
- paint.setShader(SkGradientShader::MakeLinear(configs[i].pts, colors, configs[i].pos,
- kStopCount, SkShader::kClamp_TileMode,
- fFlags, nullptr));
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(configs[i].pts, colors, configs[i].pos, kStopCount,
+ SkShader::kClamp_TileMode, fFlags, nullptr));
canvas->translate(kRectSize * ((i % 4) * 1.5f + 0.25f),
kRectSize * ((i / 4) * 1.5f + 0.25f));
+ paint.setShader(gradient);
canvas->drawRect(SkRect::MakeWH(kRectSize, kRectSize), paint);
}
}
@@ -684,27 +704,27 @@
#define SIZE 121
-static sk_sp<SkShader> make_linear(const GradRun& run, SkShader::TileMode mode) {
+static SkShader* make_linear(const GradRun& run, SkShader::TileMode mode) {
const SkPoint pts[] { { 30, 30 }, { SIZE - 30, SIZE - 30 } };
- return SkGradientShader::MakeLinear(pts, run.fColors, run.fPos, run.fCount, mode);
+ return SkGradientShader::CreateLinear(pts, run.fColors, run.fPos, run.fCount, mode);
}
-static sk_sp<SkShader> make_radial(const GradRun& run, SkShader::TileMode mode) {
+static SkShader* make_radial(const GradRun& run, SkShader::TileMode mode) {
const SkScalar half = SIZE * 0.5f;
- return SkGradientShader::MakeRadial({half,half}, half - 10, run.fColors, run.fPos,
- run.fCount, mode);
+ return SkGradientShader::CreateRadial({half,half}, half - 10,
+ run.fColors, run.fPos, run.fCount, mode);
}
-static sk_sp<SkShader> make_conical(const GradRun& run, SkShader::TileMode mode) {
+static SkShader* make_conical(const GradRun& run, SkShader::TileMode mode) {
const SkScalar half = SIZE * 0.5f;
const SkPoint center { half, half };
- return SkGradientShader::MakeTwoPointConical(center, 20, center, half - 10,
- run.fColors, run.fPos, run.fCount, mode);
+ return SkGradientShader::CreateTwoPointConical(center, 20, center, half - 10,
+ run.fColors, run.fPos, run.fCount, mode);
}
-static sk_sp<SkShader> make_sweep(const GradRun& run, SkShader::TileMode) {
+static SkShader* make_sweep(const GradRun& run, SkShader::TileMode) {
const SkScalar half = SIZE * 0.5f;
- return SkGradientShader::MakeSweep(half, half, run.fColors, run.fPos, run.fCount);
+ return SkGradientShader::CreateSweep(half, half, run.fColors, run.fPos, run.fCount);
}
/*
@@ -742,7 +762,7 @@
4,
},
};
- sk_sp<SkShader> (*factories[])(const GradRun&, SkShader::TileMode) {
+ SkShader* (*factories[])(const GradRun&, SkShader::TileMode) {
make_linear, make_radial, make_conical, make_sweep
};
@@ -757,7 +777,7 @@
canvas->translate(0, dy);
SkAutoCanvasRestore acr(canvas, true);
for (const auto& run : runs) {
- paint.setShader(factory(run, mode));
+ paint.setShader(factory(run, mode))->unref();
canvas->drawRect(rect, paint);
canvas->translate(dx, 0);
}
@@ -779,10 +799,12 @@
}
}
- SkPaint p;
- p.setShader(SkGradientShader::MakeLinear(
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(
pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, flags, nullptr));
+ SkPaint p;
+ p.setShader(shader);
+
canvas->drawRect(SkRect::MakeXYWH(0, 0, 500, 500), p);
}
diff --git a/gm/gradients_2pt_conical.cpp b/gm/gradients_2pt_conical.cpp
index 28ed8bb..39ebb4a 100644
--- a/gm/gradients_2pt_conical.cpp
+++ b/gm/gradients_2pt_conical.cpp
@@ -37,218 +37,235 @@
{ 4, gColorClamp, gPosClamp }
};
-static sk_sp<SkShader> Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
+static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center1, radius1,
+ center0, radius0,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalInside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
- SkPoint center0, center1;
- center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
- SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
-}
-
-static sk_sp<SkShader> Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
- SkPoint center0, center1;
- center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
- SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 2,
- center1, (pts[1].fX - pts[0].fX) / 7,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
-}
-
-static sk_sp<SkShader> Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data,
+static SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 7,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
- SkPoint center0, center1;
- center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
- SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center1, 0.f,
- center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
-}
-
-static sk_sp<SkShader> Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
- SkPoint center0, center1;
- center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
- SkScalarAve(pts[0].fY, pts[1].fY));
- center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
- SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2,
- center0, 0.f,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
-}
-
-static sk_sp<SkShader> Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data,
+static SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center0, 0.f, center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm,
- 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 2,
+ center1, (pts[1].fX - pts[0].fX) / 7,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm,
- const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointConical(center0, (pts[1].fX - pts[0].fX) / 7,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
+}
+
+static SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointConical(center1, 0.f,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
+}
+
+static SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0].fX) / 2,
+ center0, 0.f,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
+}
+
+static SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
+ SkPoint center0, center1;
+ center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
+ SkScalarAve(pts[0].fY, pts[1].fY));
+ center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
+ SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
+ return SkGradientShader::CreateTwoPointConical(center0, 0.f,
+ center0, (pts[1].fX - pts[0].fX) / 2,
+ data.fColors, data.fPos, data.fCount, tm,
+ 0, &localMatrix);
+}
+
+static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1,
- data.fColors, data.fPos,
- data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm,
- const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center1, radius1, center0, radius0, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center1, radius1,
+ center0, radius0,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX + radius1, center1.fY);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm,
- const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX + radius1, center1.fY);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX - radius1 + radius0, center1.fY);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix) {
+static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 7;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center1.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center0.set(center1.fX, center1.fY + radius1 - radius0);
- return SkGradientShader::MakeTwoPointConical(center0, radius0, center1, radius1, data.fColors,
- data.fPos, data.fCount, tm, 0, &localMatrix);
+ return SkGradientShader::CreateTwoPointConical(center0, radius0,
+ center1, radius1,
+ data.fColors, data.fPos,
+ data.fCount, tm, 0, &localMatrix);
}
-static sk_sp<SkShader> Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data,
+static SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data,
SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(center0, 0.0000000000000000001f,
+ return SkGradientShader::CreateTwoPointConical(center0, 0.0000000000000000001f,
center0, (pts[1].fX - pts[0].fX) / 2,
data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
-typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, const SkMatrix& localMatrix);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
+ SkShader::TileMode tm, const SkMatrix& localMatrix);
static const GradMaker gGradMakersOutside[] = {
Make2ConicalOutside, Make2ConicalOutsideFlip,
@@ -330,8 +347,10 @@
scale.postTranslate(25.f, 25.f);
}
- paint.setShader(gradMaker[j](pts, gGradData[i], tm, scale));
+ SkShader* shader = gradMaker[j](pts, gGradData[i], tm, scale);
+ paint.setShader(shader);
canvas->drawRect(r, paint);
+ shader->unref();
canvas->translate(0, SkIntToScalar(120));
}
canvas->restore();
diff --git a/gm/gradients_no_texture.cpp b/gm/gradients_no_texture.cpp
index b688aab..00c865c 100644
--- a/gm/gradients_no_texture.cpp
+++ b/gm/gradients_no_texture.cpp
@@ -26,50 +26,51 @@
{ 4, gColors, nullptr },
};
-static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
+static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeRadial(center, center.fX, data.fColors, data.fPos, data.fCount, tm);
+ return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
+ data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
+static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static sk_sp<SkShader> Make2Radial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(
+ return SkGradientShader::CreateTwoPointConical(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
data.fColors, data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center0, center1;
SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
- return SkGradientShader::MakeTwoPointConical(center1, radius1,
+ return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
data.fCount, tm);
}
-typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical,
@@ -106,7 +107,8 @@
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); ++i) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); ++j) {
- paint.setShader(gGradMakers[j](kPts, gGradData[i], kTM));
+ SkShader* shader = gGradMakers[j](kPts, gGradData[i], kTM);
+ paint.setShader(shader)->unref();
paint.setAlpha(kAlphas[a]);
canvas->drawRect(kRect, paint);
canvas->translate(0, SkIntToScalar(kRect.height() + 20));
@@ -254,8 +256,9 @@
for (size_t i = 0; i < SK_ARRAY_COUNT(procs); ++i) {
ColorPos rec;
procs[i](&rec);
- paint.setShader(SkGradientShader::MakeLinear(pts, rec.fColors, rec.fPos, rec.fCount,
- SkShader::kClamp_TileMode));
+ SkShader* s = SkGradientShader::CreateLinear(pts, rec.fColors, rec.fPos, rec.fCount,
+ SkShader::kClamp_TileMode);
+ paint.setShader(s)->unref();
canvas->drawRect(drawR, paint);
canvas->save();
diff --git a/gm/gradtext.cpp b/gm/gradtext.cpp
index d664547..acb88d6 100644
--- a/gm/gradtext.cpp
+++ b/gm/gradtext.cpp
@@ -11,25 +11,28 @@
#include "SkTypeface.h"
// test shader w/ transparency
-static sk_sp<SkShader> make_grad(SkScalar width) {
+static SkShader* make_grad(SkScalar width) {
SkColor colors[] = { SK_ColorRED, 0x0000FF00, SK_ColorBLUE };
SkPoint pts[] = { { 0, 0 }, { width, 0 } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kMirror_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kMirror_TileMode);
}
// test opaque shader
-static sk_sp<SkShader> make_grad2(SkScalar width) {
+static SkShader* make_grad2(SkScalar width) {
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
SkPoint pts[] = { { 0, 0 }, { width, 0 } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kMirror_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kMirror_TileMode);
}
-static sk_sp<SkShader> make_chrome_solid() {
+static SkShader* make_chrome_solid() {
SkColor colors[] = { SK_ColorGREEN, SK_ColorGREEN };
SkPoint pts[] = { { 0, 0 }, { 1, 0 } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
+ SkShader::kClamp_TileMode);
}
namespace skiagm {
@@ -53,7 +56,7 @@
canvas->drawRect(r, paint);
// Minimal repro doesn't require AA, LCD, or a nondefault typeface
- paint.setShader(make_chrome_solid());
+ paint.setShader(make_chrome_solid())->unref();
paint.setTextSize(SkIntToScalar(500));
canvas->drawText("I", 1, 0, 100, paint);
@@ -81,7 +84,7 @@
canvas->drawText("Normal Stroke Text", 18, 0, 100, paint);
// Minimal repro doesn't require AA, LCD, or a nondefault typeface
- paint.setShader(make_chrome_solid());
+ paint.setShader(make_chrome_solid())->unref();
paint.setStyle(SkPaint::kFill_Style);
canvas->drawText("Gradient Fill Text", 18, 0, 150, paint);
@@ -137,12 +140,12 @@
canvas->translate(SkIntToScalar(20), paint.getTextSize());
for (int i = 0; i < 2; ++i) {
- paint.setShader(make_grad(SkIntToScalar(80)));
+ paint.setShader(make_grad(SkIntToScalar(80)))->unref();
draw_text3(canvas, paint);
canvas->translate(0, paint.getTextSize() * 2);
- paint.setShader(make_grad2(SkIntToScalar(80)));
+ paint.setShader(make_grad2(SkIntToScalar(80)))->unref();
draw_text3(canvas, paint);
canvas->translate(0, paint.getTextSize() * 2);
diff --git a/gm/hairmodes.cpp b/gm/hairmodes.cpp
index 15e75fe..4f85c19 100644
--- a/gm/hairmodes.cpp
+++ b/gm/hairmodes.cpp
@@ -58,7 +58,7 @@
return H;
}
-static sk_sp<SkShader> make_bg_shader() {
+static SkShader* make_bg_shader() {
SkBitmap bm;
bm.allocN32Pixels(2, 2);
*bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF;
@@ -66,8 +66,10 @@
SkMatrix m;
m.setScale(SkIntToScalar(6), SkIntToScalar(6));
- return SkShader::MakeBitmapShader(bm,
- SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &m);
+ return SkShader::CreateBitmapShader(bm,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode,
+ &m);
}
namespace skiagm {
@@ -83,7 +85,7 @@
virtual SkISize onISize() override { return SkISize::Make(640, 480); }
void onOnceBeforeDraw() override {
- fBGPaint.setShader(make_bg_shader());
+ fBGPaint.setShader(make_bg_shader())->unref();
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 033b806..f5c9cef 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -53,9 +53,12 @@
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
+ SkAutoTUnref<SkShader> shader(
+ SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
+ SkShader::kClamp_TileMode)
+ );
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr,
- 2, SkShader::kClamp_TileMode));
+ paint.setShader(shader);
canvas->drawCircle(x, y, radius, paint);
fGradientCircle.reset(surface->newImageSnapshot());
}
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index 185bbde..9ceab20 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -151,9 +151,12 @@
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
+ SkAutoTUnref<SkShader> shader(
+ SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
+ SkShader::kClamp_TileMode)
+ );
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr,
- 2, SkShader::kClamp_TileMode));
+ paint.setShader(shader);
canvas->drawCircle(x, y, radius, paint);
return surface->newImageSnapshot();
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index da44678..7576ee1 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -145,9 +145,12 @@
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
+ SkAutoTUnref<SkShader> shader(
+ SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
+ SkShader::kClamp_TileMode)
+ );
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr,
- 2, SkShader::kClamp_TileMode));
+ paint.setShader(shader);
canvas->drawCircle(x, y, radius, paint);
return surface->newImageSnapshot();
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index 5b9d702..8e59b92 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -36,9 +36,12 @@
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
+ SkAutoTUnref<SkShader> shader(
+ SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
+ SkShader::kClamp_TileMode)
+ );
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
- SkShader::kClamp_TileMode));
+ paint.setShader(shader);
canvas->drawCircle(x, y, radius, paint);
return surface->newImageSnapshot();
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index 6280ae7..c53df29 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -40,9 +40,9 @@
SkPaint paint;
static const SkColor kColors[] =
{ SK_ColorBLUE, SK_ColorYELLOW, SK_ColorGREEN, SK_ColorWHITE };
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(0,0), kBmpSize / 2.f, kColors,
- nullptr, SK_ARRAY_COUNT(kColors),
- SkShader::kMirror_TileMode));
+ paint.setShader(SkGradientShader::CreateRadial(SkPoint::Make(0,0), kBmpSize / 2.f, kColors,
+ nullptr, SK_ARRAY_COUNT(kColors),
+ SkShader::kMirror_TileMode))->unref();
SkBitmap rgbBmp;
rgbBmp.allocN32Pixels(kBmpSize, kBmpSize, true);
SkCanvas canvas(rgbBmp);
diff --git a/gm/imagetoyuvplanes.cpp b/gm/imagetoyuvplanes.cpp
index 87bff8e..09b3dbb 100644
--- a/gm/imagetoyuvplanes.cpp
+++ b/gm/imagetoyuvplanes.cpp
@@ -28,9 +28,9 @@
static const SkColor kColors[] =
{ SK_ColorBLUE, SK_ColorYELLOW, SK_ColorGREEN, SK_ColorWHITE };
SkScalar r = (width + height) / 4.f;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(0,0), r, kColors,
- nullptr, SK_ARRAY_COUNT(kColors),
- SkShader::kMirror_TileMode));
+ paint.setShader(SkGradientShader::CreateRadial(SkPoint::Make(0,0), r, kColors,
+ nullptr, SK_ARRAY_COUNT(kColors),
+ SkShader::kMirror_TileMode))->unref();
surface->getCanvas()->drawPaint(paint);
return surface->newImageSnapshot();
diff --git a/gm/lcdblendmodes.cpp b/gm/lcdblendmodes.cpp
index c3fe9ff..d7a9024 100644
--- a/gm/lcdblendmodes.cpp
+++ b/gm/lcdblendmodes.cpp
@@ -22,7 +22,7 @@
static const int kWidth = kColWidth * kNumCols;
static const int kHeight = 750;
-static sk_sp<SkShader> make_shader(const SkRect& bounds) {
+static SkShader* make_shader(const SkRect& bounds) {
const SkPoint pts[] = {
{ bounds.left(), bounds.top() },
{ bounds.right(), bounds.bottom() },
@@ -30,8 +30,9 @@
const SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN,
};
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kRepeat_TileMode);
+ return SkGradientShader::CreateLinear(pts,
+ colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kRepeat_TileMode);
}
class LcdBlendGM : public skiagm::GM {
@@ -135,7 +136,7 @@
if (useGrad) {
SkRect r;
r.setXYWH(0, y - fTextHeight, SkIntToScalar(kColWidth), fTextHeight);
- paint.setShader(make_shader(r));
+ paint.setShader(make_shader(r))->unref();
}
SkString string(gModes[m].fLabel);
canvas->drawText(gModes[m].fLabel, string.size(), 0, y, paint);
diff --git a/gm/lumafilter.cpp b/gm/lumafilter.cpp
index adffd00..3244b2b 100644
--- a/gm/lumafilter.cpp
+++ b/gm/lumafilter.cpp
@@ -26,8 +26,9 @@
paint);
}
-static void draw_scene(SkCanvas* canvas, SkColorFilter* filter, SkXfermode::Mode mode,
- const sk_sp<SkShader>& s1, const sk_sp<SkShader>& s2) {
+static void draw_scene(SkCanvas* canvas, SkColorFilter* filter,
+ SkXfermode::Mode mode, SkShader* s1,
+ SkShader* s2) {
SkPaint paint;
paint.setAntiAlias(true);
SkRect r, c, bounds = SkRect::MakeWH(kSize, kSize);
@@ -84,10 +85,16 @@
SkScalar pos[] = { 0.2f, 1.0f };
fFilter.reset(SkLumaColorFilter::Create());
- fGr1 = SkGradientShader::MakeLinear(g1Points, g1Colors, pos, SK_ARRAY_COUNT(g1Colors),
- SkShader::kClamp_TileMode);
- fGr2 = SkGradientShader::MakeLinear(g2Points, g2Colors, pos, SK_ARRAY_COUNT(g2Colors),
- SkShader::kClamp_TileMode);
+ fGr1.reset(SkGradientShader::CreateLinear(g1Points,
+ g1Colors,
+ pos,
+ SK_ARRAY_COUNT(g1Colors),
+ SkShader::kClamp_TileMode));
+ fGr2.reset(SkGradientShader::CreateLinear(g2Points,
+ g2Colors,
+ pos,
+ SK_ARRAY_COUNT(g2Colors),
+ SkShader::kClamp_TileMode));
}
protected:
@@ -109,8 +116,8 @@
SkXfermode::kDstIn_Mode,
};
struct {
- const sk_sp<SkShader>& fShader1;
- const sk_sp<SkShader>& fShader2;
+ SkShader* fShader1;
+ SkShader* fShader2;
} shaders[] = {
{ nullptr, nullptr },
{ nullptr, fGr2 },
@@ -138,7 +145,7 @@
private:
SkAutoTUnref<SkColorFilter> fFilter;
- sk_sp<SkShader> fGr1, fGr2;
+ SkAutoTUnref<SkShader> fGr1, fGr2;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index b02f743..3b159f4 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -37,8 +37,8 @@
SkPoint::Make(0, SkIntToScalar(80)) };
SkColor colors[2] = { 0xFFFFFFFF, 0x40404040 };
SkScalar pos[2] = { 0, SkIntToScalar(80) };
- paint.setShader(SkGradientShader::MakeLinear(
- pts, colors, pos, 2, SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(
+ pts, colors, pos, 2, SkShader::kClamp_TileMode))->unref();
const char* str = "e";
canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80), paint);
}
diff --git a/gm/modecolorfilters.cpp b/gm/modecolorfilters.cpp
index de6a18a..b5ede71 100644
--- a/gm/modecolorfilters.cpp
+++ b/gm/modecolorfilters.cpp
@@ -6,6 +6,7 @@
*/
#include "gm.h"
+#include "SkBitmapProcShader.h"
#include "SkColorFilter.h"
#include "SkGradientShader.h"
@@ -15,27 +16,27 @@
namespace skiagm {
// Using gradients because GPU doesn't currently have an implementation of SkColorShader (duh!)
-static sk_sp<SkShader> make_color_shader(SkColor color) {
+static SkShader* make_color_shader(SkColor color) {
static const SkPoint kPts[] = {{0, 0}, {1, 1}};
SkColor colors[] = {color, color};
- return SkGradientShader::MakeLinear(kPts, colors, nullptr, 2, SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(kPts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
-static sk_sp<SkShader> make_solid_shader() {
+static SkShader* make_solid_shader() {
return make_color_shader(SkColorSetARGB(0xFF, 0x42, 0x82, 0x21));
}
-static sk_sp<SkShader> make_transparent_shader() {
+static SkShader* make_transparent_shader() {
return make_color_shader(SkColorSetARGB(0x80, 0x10, 0x70, 0x20));
}
-static sk_sp<SkShader> make_trans_black_shader() {
+static SkShader* make_trans_black_shader() {
return make_color_shader(0x0);
}
// draws a background behind each test rect to see transparency
-static sk_sp<SkShader> make_bg_shader(int checkSize) {
+static SkShader* make_bg_shader(int checkSize) {
SkBitmap bmp;
bmp.allocN32Pixels(2 * checkSize, 2 * checkSize);
SkCanvas canvas(bmp);
@@ -48,7 +49,7 @@
SkIntToScalar(checkSize), SkIntToScalar(checkSize));
canvas.drawRect(rect1, paint);
canvas.drawRect(rect0, paint);
- return SkShader::MakeBitmapShader(bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+ return new SkBitmapProcShader(bmp, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
}
class ModeColorFilterGM : public GM {
@@ -58,15 +59,15 @@
}
protected:
- SkString onShortName() override {
+ virtual SkString onShortName() {
return SkString("modecolorfilters");
}
- SkISize onISize() override {
+ virtual SkISize onISize() {
return SkISize::Make(WIDTH, HEIGHT);
}
- void onDraw(SkCanvas* canvas) override {
+ virtual void onDraw(SkCanvas* canvas) {
// size of rect for each test case
static const int kRectWidth = 20;
static const int kRectHeight = 20;
@@ -74,13 +75,13 @@
static const int kCheckSize = 10;
if (!fBmpShader) {
- fBmpShader = make_bg_shader(kCheckSize);
+ fBmpShader.reset(make_bg_shader(kCheckSize));
}
SkPaint bgPaint;
bgPaint.setShader(fBmpShader);
bgPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
- sk_sp<SkShader> shaders[] = {
+ SkShader* shaders[] = {
nullptr, // use a paint color instead of a shader
make_solid_shader(),
make_transparent_shader(),
@@ -145,10 +146,14 @@
}
}
}
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(shaders); ++i) {
+ SkSafeUnref(shaders[i]);
+ }
}
private:
- sk_sp<SkShader> fBmpShader;
+ SkAutoTUnref<SkShader> fBmpShader;
typedef GM INHERITED;
};
diff --git a/gm/ovals.cpp b/gm/ovals.cpp
index 580426b..e4cc46e 100755
--- a/gm/ovals.cpp
+++ b/gm/ovals.cpp
@@ -246,8 +246,12 @@
SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0));
SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN };
SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 };
- auto shader = SkGradientShader::MakeRadial(center, 20, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center,
+ SkIntToScalar(20),
+ colors,
+ pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
for (int i = 0; i < fPaints.count(); ++i) {
canvas->save();
diff --git a/gm/patch.cpp b/gm/patch.cpp
index 5b661f4..d9f6d57 100644
--- a/gm/patch.cpp
+++ b/gm/patch.cpp
@@ -10,15 +10,15 @@
#include "SkGradientShader.h"
#include "SkPatchUtils.h"
-static sk_sp<SkShader> make_shader() {
+static SkShader* make_shader() {
const SkColor colors[] = {
SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE, SK_ColorMAGENTA, SK_ColorBLUE,
SK_ColorYELLOW,
};
const SkPoint pts[] = { { 100.f / 4.f, 0.f }, { 3.f * 100.f / 4.f, 100.f } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kMirror_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kMirror_TileMode);
}
static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) {
@@ -92,7 +92,7 @@
SkXfermode::kModulate_Mode,
};
- sk_sp<SkShader> shader(make_shader());
+ SkAutoTUnref<SkShader> shader(make_shader());
canvas->save();
for (int y = 0; y < 3; y++) {
diff --git a/gm/perspshaders.cpp b/gm/perspshaders.cpp
index a29ef52..59fab47 100644
--- a/gm/perspshaders.cpp
+++ b/gm/perspshaders.cpp
@@ -46,8 +46,9 @@
SK_ColorBLUE, SK_ColorYELLOW,
kCellSize/10);
- fBitmapShader = SkShader::MakeBitmapShader(fBitmap, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
+ fBitmapShader.reset(SkShader::CreateBitmapShader(fBitmap,
+ SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
SkPoint pts1[] = {
{ 0, 0 },
{ SkIntToScalar(kCellSize), SkIntToScalar(kCellSize) }
@@ -61,10 +62,12 @@
};
static const SkScalar pos[] = { 0, 0.25f, 0.5f, 0.75f, SK_Scalar1 };
- fLinearGrad1 = SkGradientShader::MakeLinear(pts1, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
- fLinearGrad2 = SkGradientShader::MakeLinear(pts2, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
+ fLinearGrad1.reset(SkGradientShader::CreateLinear(pts1, colors, pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
+ fLinearGrad2.reset(SkGradientShader::CreateLinear(pts2, colors, pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
fPerspMatrix.reset();
fPerspMatrix.setPerspY(SK_Scalar1 / 50);
@@ -157,9 +160,9 @@
bool fDoAA;
SkPath fPath;
- sk_sp<SkShader> fBitmapShader;
- sk_sp<SkShader> fLinearGrad1;
- sk_sp<SkShader> fLinearGrad2;
+ SkAutoTUnref<SkShader> fBitmapShader;
+ SkAutoTUnref<SkShader> fLinearGrad1;
+ SkAutoTUnref<SkShader> fLinearGrad2;
SkMatrix fPerspMatrix;
SkAutoTUnref<SkImage> fImage;
SkBitmap fBitmap;
diff --git a/gm/pictureimagegenerator.cpp b/gm/pictureimagegenerator.cpp
index 2d50f3a..829006d 100644
--- a/gm/pictureimagegenerator.cpp
+++ b/gm/pictureimagegenerator.cpp
@@ -68,8 +68,10 @@
const SkScalar pos1[] = { 0, 0.75f };
const SkColor colors1[] = { SK_ColorTRANSPARENT, SK_ColorBLACK };
SkASSERT(SK_ARRAY_COUNT(pos1) == SK_ARRAY_COUNT(colors1));
- paint.setShader(SkGradientShader::MakeLinear(pts1, colors1, pos1, SK_ARRAY_COUNT(pos1),
- SkShader::kClamp_TileMode));
+ SkAutoTUnref<SkShader> gradient1(SkGradientShader::CreateLinear(pts1, colors1, pos1,
+ SK_ARRAY_COUNT(pos1),
+ SkShader::kClamp_TileMode));
+ paint.setShader(gradient1.get());
canvas->drawRect(underlineRect, paint);
const SkPoint pts2[] = { SkPoint::Make(iBox.x() - iBox.width() * kGradientPad, 0),
@@ -86,8 +88,10 @@
SK_ColorBLACK
};
SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2));
- paint.setShader(SkGradientShader::MakeLinear(pts2, colors2, pos2, SK_ARRAY_COUNT(pos2),
- SkShader::kClamp_TileMode));
+ SkAutoTUnref<SkShader> gradient2(SkGradientShader::CreateLinear(pts2, colors2, pos2,
+ SK_ARRAY_COUNT(pos2),
+ SkShader::kClamp_TileMode));
+ paint.setShader(gradient2.get());
canvas->drawText(kSkiaStr, textLen, 0, 0, paint);
}
diff --git a/gm/pictureshader.cpp b/gm/pictureshader.cpp
index f27c4ed..c35c5c9 100644
--- a/gm/pictureshader.cpp
+++ b/gm/pictureshader.cpp
@@ -150,17 +150,20 @@
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->drawRect(SkRect::MakeXYWH(fSceneSize * 1.1f, 0, fSceneSize, fSceneSize), paint);
- paint.setShader(SkShader::MakePictureShader(fPicture, kTileConfigs[tileMode].tmx,
- kTileConfigs[tileMode].tmy, &localMatrix,
- nullptr));
+ SkAutoTUnref<SkShader> pictureShader(
+ SkShader::CreatePictureShader(fPicture, kTileConfigs[tileMode].tmx,
+ kTileConfigs[tileMode].tmy, &localMatrix, nullptr));
+ paint.setShader(pictureShader.get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->translate(fSceneSize * 1.1f, 0);
- paint.setShader(SkShader::MakeBitmapShader(fBitmap,
- kTileConfigs[tileMode].tmx,
- kTileConfigs[tileMode].tmy,
- &localMatrix));
+ SkAutoTUnref<SkShader> bitmapShader(SkShader::CreateBitmapShader(
+ fBitmap,
+ kTileConfigs[tileMode].tmx,
+ kTileConfigs[tileMode].tmy,
+ &localMatrix));
+ paint.setShader(bitmapShader.get());
canvas->drawRect(SkRect::MakeWH(fSceneSize, fSceneSize), paint);
canvas->restore();
@@ -169,7 +172,7 @@
SkScalar fTileSize;
SkScalar fSceneSize;
- sk_sp<SkPicture> fPicture;
+ SkAutoTUnref<SkPicture> fPicture;
SkBitmap fBitmap;
typedef GM INHERITED;
@@ -193,10 +196,10 @@
p.setStrokeWidth(10);
c->drawLine(20, 20, 80, 80, p);
- sk_sp<SkPicture> picture(recorder.endRecording());
- sk_sp<SkShader> shader(SkShader::MakePictureShader(picture, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode,
- nullptr, nullptr));
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ SkAutoTUnref<SkShader> shader(
+ SkShader::CreatePictureShader(picture.get(), SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode, nullptr, nullptr));
p.setColor(sk_tool_utils::color_to_565(0xFF8BC34A)); // green
canvas->drawPaint(p);
diff --git a/gm/pictureshadertile.cpp b/gm/pictureshadertile.cpp
index 68e65f8..30776c3 100644
--- a/gm/pictureshadertile.cpp
+++ b/gm/pictureshadertile.cpp
@@ -95,14 +95,14 @@
SkPictureRecorder recorder;
SkCanvas* pictureCanvas = recorder.beginRecording(kPictureSize, kPictureSize);
draw_scene(pictureCanvas, kPictureSize);
- sk_sp<SkPicture> picture(recorder.endRecording());
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkPoint offset = SkPoint::Make(100, 100);
pictureCanvas = recorder.beginRecording(SkRect::MakeXYWH(offset.x(), offset.y(),
kPictureSize, kPictureSize));
pictureCanvas->translate(offset.x(), offset.y());
draw_scene(pictureCanvas, kPictureSize);
- sk_sp<SkPicture> offsetPicture(recorder.endRecording());
+ SkAutoTUnref<SkPicture> offsetPicture(recorder.endRecording());
for (unsigned i = 0; i < SK_ARRAY_COUNT(tiles); ++i) {
SkRect tile = SkRect::MakeXYWH(tiles[i].x * kPictureSize,
@@ -115,18 +115,20 @@
localMatrix.postScale(kFillSize / (2 * kPictureSize),
kFillSize / (2 * kPictureSize));
- sk_sp<SkPicture>& pictureRef = picture;
+ SkPicture* picturePtr = picture.get();
SkRect* tilePtr = &tile;
if (tile == SkRect::MakeWH(kPictureSize, kPictureSize)) {
// When the tile == picture bounds, exercise the picture + offset path.
- pictureRef = offsetPicture;
+ picturePtr = offsetPicture.get();
tilePtr = nullptr;
}
- fShaders[i] = SkShader::MakePictureShader(pictureRef, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &localMatrix,
- tilePtr);
+ fShaders[i].reset(SkShader::CreatePictureShader(picturePtr,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode,
+ &localMatrix,
+ tilePtr));
}
}
@@ -148,7 +150,7 @@
}
private:
- sk_sp<SkShader> fShaders[SK_ARRAY_COUNT(tiles)];
+ SkAutoTUnref<SkShader> fShaders[SK_ARRAY_COUNT(tiles)];
typedef GM INHERITED;
};
diff --git a/gm/rectangletexture.cpp b/gm/rectangletexture.cpp
index 4bdb4c9..20f2ead 100644
--- a/gm/rectangletexture.cpp
+++ b/gm/rectangletexture.cpp
@@ -42,14 +42,14 @@
SkCanvas canvas(bmp);
SkPoint pts[] = { {0, 0}, {0, SkIntToScalar(height)} };
SkColor colors0[] = { 0xFF1060B0 , 0xFF102030 };
- paint.setShader(SkGradientShader::MakeLinear(pts, colors0, nullptr, 2,
- SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(pts, colors0, nullptr, 2,
+ SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
SkColor colors1[] = { 0xFFA07010 , 0xFFA02080 };
paint.setAntiAlias(true);
- paint.setShader(SkGradientShader::MakeLinear(pts, colors1, nullptr, 2,
- SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(pts, colors1, nullptr, 2,
+ SkShader::kClamp_TileMode))->unref();
canvas.drawCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2,
SkIntToScalar(width + height) / 5, paint);
}
diff --git a/gm/rects.cpp b/gm/rects.cpp
index 6f4c75e..38108fe 100644
--- a/gm/rects.cpp
+++ b/gm/rects.cpp
@@ -80,9 +80,13 @@
SkPoint center = SkPoint::Make(SkIntToScalar(-5), SkIntToScalar(30));
SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN };
SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 };
- p.setShader(SkGradientShader::MakeRadial(center, 20, colors, pos,
- SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode));
+ SkShader* s = SkGradientShader::CreateRadial(center,
+ SkIntToScalar(20),
+ colors,
+ pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode);
+ p.setShader(s)->unref();
fPaints.push_back(p);
}
diff --git a/gm/roundrects.cpp b/gm/roundrects.cpp
index d0401f0..b616e4d 100644
--- a/gm/roundrects.cpp
+++ b/gm/roundrects.cpp
@@ -261,8 +261,12 @@
SkPoint center = SkPoint::Make(SkIntToScalar(0), SkIntToScalar(0));
SkColor colors[] = { SK_ColorBLUE, SK_ColorRED, SK_ColorGREEN };
SkScalar pos[] = { 0, SK_ScalarHalf, SK_Scalar1 };
- auto shader = SkGradientShader::MakeRadial(center, 20, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center,
+ SkIntToScalar(20),
+ colors,
+ pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode));
for (int i = 0; i < fPaints.count(); ++i) {
canvas->save();
diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp
index f317cf9..4bec678 100644
--- a/gm/samplerstress.cpp
+++ b/gm/samplerstress.cpp
@@ -21,9 +21,13 @@
public:
SamplerStressGM()
: fTextureCreated(false)
+ , fShader(nullptr)
, fMaskFilter(nullptr) {
}
+ virtual ~SamplerStressGM() {
+ }
+
protected:
SkString onShortName() override {
@@ -65,14 +69,15 @@
}
void createShader() {
- if (fShader) {
+ if (fShader.get()) {
return;
}
createTexture();
- fShader = SkShader::MakeBitmapShader(fTexture, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
+ fShader.reset(SkShader::CreateBitmapShader(fTexture,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode));
}
void createMaskFilter() {
@@ -135,9 +140,9 @@
}
private:
- SkBitmap fTexture;
- bool fTextureCreated;
- sk_sp<SkShader> fShader;
+ SkBitmap fTexture;
+ bool fTextureCreated;
+ SkAutoTUnref<SkShader> fShader;
SkAutoTUnref<SkMaskFilter> fMaskFilter;
typedef GM INHERITED;
diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp
index 503f8f5..fd42973 100644
--- a/gm/shaderbounds.cpp
+++ b/gm/shaderbounds.cpp
@@ -4,31 +4,30 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
#include "gm.h"
#include "SkGradientShader.h"
namespace skiagm {
-static sk_sp<SkShader> MakeLinear(SkScalar width, SkScalar height, bool alternate,
+static SkShader* MakeLinear(SkScalar width, SkScalar height, bool alternate,
const SkMatrix& localMatrix) {
- SkPoint pts[2] = { {0, 0}, {width, height}};
- SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN};
- if (alternate) {
- pts[1].fY = 0;
- colors[0] = SK_ColorBLUE;
- colors[1] = SK_ColorYELLOW;
- }
- return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode,
- 0, &localMatrix);
+ SkPoint pts[2] = { {0, 0}, {width, height}};
+ SkColor colors[2] = {SK_ColorRED, SK_ColorGREEN};
+ if (alternate) {
+ pts[1].fY = 0;
+ colors[0] = SK_ColorBLUE;
+ colors[1] = SK_ColorYELLOW;
+ }
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, 2,
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
///////////////////////////////////////////////////////////////////////////////
class ShaderBoundsGM : public GM {
public:
- typedef sk_sp<SkShader> (*ShaderGenFunc)(SkScalar width, SkScalar height,
- bool alternate, const SkMatrix& localMatrix);
+ typedef SkShader* (*ShaderGenFunc)(SkScalar width, SkScalar height,
+ bool alternate, const SkMatrix& localMatrix);
ShaderBoundsGM(ShaderGenFunc maker, const SkString& name)
: fShaderMaker(maker),
fName(name) {
@@ -63,20 +62,20 @@
// Background shader.
SkPaint paint;
- paint.setShader(MakeShader(559, 387, false));
+ paint.setShader(MakeShader(559, 387, false))->unref();
SkRect r = SkRect::MakeXYWH(SkIntToScalar(-12), SkIntToScalar(-41),
SkIntToScalar(571), SkIntToScalar(428));
canvas->drawRect(r, paint);
// Constrained shader.
- paint.setShader(MakeShader(101, 151, true));
+ paint.setShader(MakeShader(101, 151, true))->unref();
r = SkRect::MakeXYWH(SkIntToScalar(43), SkIntToScalar(71),
SkIntToScalar(101), SkIntToScalar(151));
canvas->clipRect(r);
canvas->drawRect(r, paint);
}
- sk_sp<SkShader> MakeShader(int width, int height, bool background) {
+ SkShader* MakeShader(int width, int height, bool background) {
SkScalar scale = 0.5f;
if (background) {
scale = 0.6f;
@@ -84,7 +83,8 @@
SkScalar shaderWidth = width / scale;
SkScalar shaderHeight = height / scale;
SkMatrix shaderScale = SkMatrix::MakeScale(scale);
- return fShaderMaker(shaderWidth, shaderHeight, background, shaderScale);
+ SkShader* shader = fShaderMaker(shaderWidth, shaderHeight, background, shaderScale);
+ return shader;
}
private:
@@ -93,7 +93,7 @@
ShaderGenFunc fShaderMaker;
SkString fName;
- sk_sp<SkShader> MakeShader(bool background);
+ SkShader* MakeShader(bool background);
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index 13fa283..e68ee98 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -24,8 +24,8 @@
SkPaint paint;
paint.setDither(true);
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
@@ -46,38 +46,38 @@
{ 5, gColors, nullptr },
};
-static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
- return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
+static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+ return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeRadial(center, center.fX, data.fColors, data.fPos, data.fCount,
- tm);
+ return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
+ data.fPos, data.fCount, tm);
}
-static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
+static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader::TileMode) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
- return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static sk_sp<SkShader> Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
+static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
- return SkGradientShader::MakeTwoPointConical(
+ return SkGradientShader::CreateTwoPointConical(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
data.fColors, data.fPos, data.fCount, tm);
}
-typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Conical
@@ -123,7 +123,7 @@
SK_ARRAY_COUNT(gGradMakers);
static const int bmpCount = SK_ARRAY_COUNT(tileModes) *
SK_ARRAY_COUNT(tileModes);
- sk_sp<SkShader> shaders[gradCount + bmpCount];
+ SkShader* shaders[gradCount + bmpCount];
int shdIdx = 0;
for (size_t d = 0; d < SK_ARRAY_COUNT(gGradData); ++d) {
@@ -138,7 +138,7 @@
makebm(&bm, w/16, h/4);
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
for (size_t ty = 0; ty < SK_ARRAY_COUNT(tileModes); ++ty) {
- shaders[shdIdx++] = SkShader::MakeBitmapShader(bm, tileModes[tx], tileModes[ty]);
+ shaders[shdIdx++] = SkShader::CreateBitmapShader(bm, tileModes[tx], tileModes[ty]);
}
}
@@ -167,7 +167,7 @@
int i = 2*s;
canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth),
SkIntToScalar((i % testsPerCol) * rowHeight));
- paint.setShader(shaders[s]);
+ paint.setShader(shaders[s])->unref();
canvas->drawText(text, textLen, 0, textBase, paint);
canvas->restore();
canvas->save();
diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp
index 2ec1952..74f01a0 100644
--- a/gm/shadertext2.cpp
+++ b/gm/shadertext2.cpp
@@ -24,11 +24,11 @@
SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(kPts0, kColors0, kPos,
- SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(kPts0, kColors0, kPos,
+ SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
- paint.setShader(SkGradientShader::MakeLinear(kPts1, kColors1, kPos,
- SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(kPts1, kColors1, kPos,
+ SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
@@ -136,9 +136,11 @@
canvas->translate(0, kPadY / 2 + kPointSize);
columnH += kPadY / 2 + kPointSize;
for (int lm = 0; lm < localMatrices.count(); ++lm) {
- paint.setShader(SkShader::MakeBitmapShader(bmp, SkShader::kMirror_TileMode,
- SkShader::kRepeat_TileMode,
- &localMatrices[lm].fMatrix));
+ paint.setShader(
+ SkShader::CreateBitmapShader(bmp,
+ SkShader::kMirror_TileMode,
+ SkShader::kRepeat_TileMode,
+ &localMatrices[lm].fMatrix))->unref();
canvas->save();
canvas->concat(matrices[m].fMatrix);
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp
index 0d1c03e..07ecd71 100644
--- a/gm/shadertext3.cpp
+++ b/gm/shadertext3.cpp
@@ -26,11 +26,11 @@
SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(kPts0, kColors0, kPos,
- SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(kPts0, kColors0, kPos,
+ SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
- paint.setShader(SkGradientShader::MakeLinear(kPts1, kColors1, kPos,
- SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(kPts1, kColors1, kPos,
+ SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
@@ -100,13 +100,17 @@
localM.postRotate(20);
localM.postScale(1.15f, .85f);
+ SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(fBmp,
+ kTileModes[tm0],
+ kTileModes[tm1],
+ &localM));
+
SkPaint fillPaint;
fillPaint.setAntiAlias(true);
sk_tool_utils::set_portable_typeface(&fillPaint);
fillPaint.setTextSize(SkIntToScalar(kPointSize));
fillPaint.setFilterQuality(kLow_SkFilterQuality);
- fillPaint.setShader(SkShader::MakeBitmapShader(fBmp, kTileModes[tm0],
- kTileModes[tm1], &localM));
+ fillPaint.setShader(shader);
canvas->drawText(kText, kTextLen, 0, 0, fillPaint);
canvas->drawText(kText, kTextLen, 0, 0, outlinePaint);
diff --git a/gm/shadows.cpp b/gm/shadows.cpp
index 5696240..bb2bf3c 100644
--- a/gm/shadows.cpp
+++ b/gm/shadows.cpp
@@ -128,11 +128,12 @@
canvas->drawBitmap(fBitmap, 10, 10, &paint);
canvas->translate(0, 40);
- paint.setShader(SkShader::MakeBitmapShader(
+ SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(
fBitmap, SkShader::kRepeat_TileMode,
SkShader::kRepeat_TileMode));
// see bug.skia.org/562 (shows bug as reported)
+ paint.setShader(shader);
paint.setStyle(SkPaint::kFill_Style);
canvas->drawRect(SkRect::MakeXYWH(10, 10, 20, 20), paint);
paint.setShader(nullptr);
diff --git a/gm/shallowgradient.cpp b/gm/shallowgradient.cpp
index 6990ba7..764b1a5 100644
--- a/gm/shallowgradient.cpp
+++ b/gm/shallowgradient.cpp
@@ -8,27 +8,31 @@
#include "gm.h"
#include "SkGradientShader.h"
-typedef sk_sp<SkShader> (*MakeShaderProc)(const SkColor[], int count, const SkSize&);
+typedef SkShader* (*MakeShaderProc)(const SkColor[], int count, const SkSize&);
-static sk_sp<SkShader> shader_linear(const SkColor colors[], int count, const SkSize& size) {
+static SkShader* shader_linear(const SkColor colors[], int count, const SkSize& size) {
SkPoint pts[] = { { 0, 0 }, { size.width(), size.height() } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, count, SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, count,
+ SkShader::kClamp_TileMode);
}
-static sk_sp<SkShader> shader_radial(const SkColor colors[], int count, const SkSize& size) {
+static SkShader* shader_radial(const SkColor colors[], int count, const SkSize& size) {
SkPoint center = { size.width()/2, size.height()/2 };
- return SkGradientShader::MakeRadial(center, size.width()/2, colors, nullptr, count,
- SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateRadial(center, size.width()/2, colors, nullptr, count,
+ SkShader::kClamp_TileMode);
}
-static sk_sp<SkShader> shader_conical(const SkColor colors[], int count, const SkSize& size) {
+static SkShader* shader_conical(const SkColor colors[], int count, const SkSize& size) {
SkPoint center = { size.width()/2, size.height()/2 };
- return SkGradientShader::MakeTwoPointConical(center, size.width()/64, center, size.width()/2,
- colors, nullptr, count, SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateTwoPointConical(center, size.width()/64,
+ center, size.width()/2,
+ colors, nullptr, count,
+ SkShader::kClamp_TileMode);
}
-static sk_sp<SkShader> shader_sweep(const SkColor colors[], int count, const SkSize& size) {
- return SkGradientShader::MakeSweep(size.width()/2, size.height()/2, colors, nullptr, count);
+static SkShader* shader_sweep(const SkColor colors[], int count, const SkSize& size) {
+ return SkGradientShader::CreateSweep(size.width()/2, size.height()/2,
+ colors, nullptr, count);
}
class ShallowGradientGM : public skiagm::GM {
@@ -58,7 +62,7 @@
SkSize size = SkSize::Make(r.width(), r.height());
SkPaint paint;
- paint.setShader(fProc(colors, colorCount, size));
+ paint.setShader(fProc(colors, colorCount, size))->unref();
paint.setDither(fDither);
canvas->drawRect(r, paint);
}
diff --git a/gm/skbug_257.cpp b/gm/skbug_257.cpp
index b11487d..0528842 100644
--- a/gm/skbug_257.cpp
+++ b/gm/skbug_257.cpp
@@ -21,9 +21,10 @@
SkMatrix matrix;
matrix.setScale(0.75f, 0.75f);
matrix.preRotate(30.0f);
- paint->setShader(
- SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode,
- &matrix));
+ SkAutoTUnref<SkShader> shader(
+ SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode, &matrix));
+ paint->setShader(shader);
}
static void exercise_draw_pos_text(SkCanvas* canvas,
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index 28bb04b..86fe89b 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -27,8 +27,10 @@
static void gradient_paintproc(SkPaint* paint) {
const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
const SkPoint pts[] = { { 0, 0 }, { W, H } };
- paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode));
+ SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode);
+ paint->setShader(s)->unref();
}
typedef void (*Proc)(SkCanvas*, const SkPaint&);
diff --git a/gm/surface.cpp b/gm/surface.cpp
index 6874b5b..c3eaf9e 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -13,12 +13,12 @@
#define W 200
#define H 100
-static sk_sp<SkShader> make_shader() {
+static SkShader* make_shader() {
int a = 0x99;
int b = 0xBB;
SkPoint pts[] = { { 0, 0 }, { W, H } };
SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
}
static SkSurface* make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
@@ -46,7 +46,7 @@
paint.setLCDRenderText(true);
paint.setDither(true);
- paint.setShader(make_shader());
+ paint.setShader(make_shader())->unref();
canvas->drawRect(SkRect::MakeWH(W, H), paint);
paint.setShader(nullptr);
diff --git a/gm/tablecolorfilter.cpp b/gm/tablecolorfilter.cpp
index dcc29f3..1053bb2 100644
--- a/gm/tablecolorfilter.cpp
+++ b/gm/tablecolorfilter.cpp
@@ -11,14 +11,14 @@
#include "SkGradientShader.h"
#include "SkTableColorFilter.h"
-static sk_sp<SkShader> make_shader0(int w, int h) {
+static SkShader* make_shader0(int w, int h) {
SkPoint pts[] = { {0, 0}, {SkIntToScalar(w), SkIntToScalar(h)} };
SkColor colors[] = {
SK_ColorBLACK, SK_ColorGREEN, SK_ColorCYAN,
SK_ColorRED, 0, SK_ColorBLUE, SK_ColorWHITE
};
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode);
}
static void make_bm0(SkBitmap* bm) {
int W = 120;
@@ -28,17 +28,17 @@
SkCanvas canvas(*bm);
SkPaint paint;
- paint.setShader(make_shader0(W, H));
+ paint.setShader(make_shader0(W, H))->unref();
canvas.drawPaint(paint);
}
-static sk_sp<SkShader> make_shader1(int w, int h) {
+static SkShader* make_shader1(int w, int h) {
SkScalar cx = SkIntToScalar(w)/2;
SkScalar cy = SkIntToScalar(h)/2;
SkColor colors[] = {
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
};
- return SkGradientShader::MakeRadial(SkPoint::Make(cx, cy), cx, colors, nullptr,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateRadial(SkPoint::Make(cx, cy), cx, colors, nullptr,
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
}
static void make_bm1(SkBitmap* bm) {
int W = 120;
@@ -50,7 +50,7 @@
SkCanvas canvas(*bm);
SkPaint paint;
- paint.setShader(make_shader1(W, H));
+ paint.setShader(make_shader1(W, H))->unref();
paint.setAntiAlias(true);
canvas.drawCircle(cx, cy, cx, paint);
}
@@ -234,7 +234,7 @@
}
SkPaint paint;
- paint.setShader(make_shader1(50, 50));
+ paint.setShader(make_shader1(50, 50))->unref();
SkRect r = SkRect::MakeWH(50, 50);
const SkScalar spacer = 10;
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index 8d462c9..fef3e24 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -80,7 +80,7 @@
paint->setPathEffect(make_tile_effect())->unref();
}
-static sk_sp<SkShader> make_shader(const SkRect& bounds) {
+static SkShader* make_shader(const SkRect& bounds) {
const SkPoint pts[] = {
{ bounds.left(), bounds.top() },
{ bounds.right(), bounds.bottom() },
@@ -89,14 +89,15 @@
SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorBLACK,
SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW,
};
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode);
+ return SkGradientShader::CreateLinear(pts,
+ colors, nullptr, SK_ARRAY_COUNT(colors),
+ SkShader::kClamp_TileMode);
}
static void color_filter(SkPaint* paint) {
SkRect r;
r.setWH(SkIntToScalar(kWidth), 50);
- paint->setShader(make_shader(r));
+ paint->setShader(make_shader(r))->unref();
paint->setColorFilter(SkColorMatrixFilter::CreateLightingFilter(0xF0F0F0, 0))->unref();
}
diff --git a/gm/textblobshader.cpp b/gm/textblobshader.cpp
index 6a8fa49..30674e1 100644
--- a/gm/textblobshader.cpp
+++ b/gm/textblobshader.cpp
@@ -68,11 +68,11 @@
}
SkISize sz = this->onISize();
- fShader = SkGradientShader::MakeRadial(SkPoint::Make(SkIntToScalar(sz.width() / 2),
- SkIntToScalar(sz.height() / 2)),
- sz.width() * .66f, colors, pos,
- SK_ARRAY_COUNT(colors),
- SkShader::kRepeat_TileMode);
+ fShader.reset(SkGradientShader::CreateRadial(SkPoint::Make(SkIntToScalar(sz.width() / 2),
+ SkIntToScalar(sz.height() / 2)),
+ sz.width() * .66f, colors, pos,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kRepeat_TileMode));
}
SkString onShortName() override {
@@ -104,7 +104,7 @@
private:
SkTDArray<uint16_t> fGlyphs;
SkAutoTUnref<const SkTextBlob> fBlob;
- sk_sp<SkShader> fShader;
+ SkAutoTUnref<SkShader> fShader;
typedef skiagm::GM INHERITED;
};
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 6bd6490..72e40fe 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -50,24 +50,24 @@
SkPaint paint;
SkColor colors1[] = { SK_ColorCYAN, SK_ColorLTGRAY, SK_ColorGRAY };
- paint.setShader(SkGradientShader::MakeSweep(65.f, 75.f, colors1, nullptr,
- SK_ARRAY_COUNT(colors1)));
- canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.height() + 10.f),
- paint);
+ paint.setShader(SkGradientShader::CreateSweep(65.f, 75.f, colors1,
+ nullptr, SK_ARRAY_COUNT(colors1)))->unref();
+ canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f,
+ fBmp.width() + 10.f, fBmp.height() + 10.f), paint);
SkColor colors2[] = { SK_ColorMAGENTA, SK_ColorLTGRAY, SK_ColorYELLOW };
- paint.setShader(SkGradientShader::MakeSweep(45.f, 55.f, colors2, nullptr,
- SK_ARRAY_COUNT(colors2)));
+ paint.setShader(SkGradientShader::CreateSweep(45.f, 55.f, colors2, nullptr,
+ SK_ARRAY_COUNT(colors2)))->unref();
paint.setXfermodeMode(SkXfermode::kDarken_Mode);
- canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.height() + 10.f),
- paint);
+ canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f,
+ fBmp.width() + 10.f, fBmp.height() + 10.f), paint);
SkColor colors3[] = { SK_ColorBLUE, SK_ColorLTGRAY, SK_ColorGREEN };
- paint.setShader(SkGradientShader::MakeSweep(25.f, 35.f, colors3, nullptr,
- SK_ARRAY_COUNT(colors3)));
+ paint.setShader(SkGradientShader::CreateSweep(25.f, 35.f, colors3, nullptr,
+ SK_ARRAY_COUNT(colors3)))->unref();
paint.setXfermodeMode(SkXfermode::kLighten_Mode);
- canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f, fBmp.width() + 10.f, fBmp.height() + 10.f),
- paint);
+ canvas.drawOval(SkRect::MakeXYWH(-5.f, -5.f,
+ fBmp.width() + 10.f, fBmp.height() + 10.f), paint);
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/tiledscaledbitmap.cpp b/gm/tiledscaledbitmap.cpp
index d74d40b..daecbb0 100644
--- a/gm/tiledscaledbitmap.cpp
+++ b/gm/tiledscaledbitmap.cpp
@@ -1,10 +1,10 @@
+
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
#include "gm.h"
#include "Resources.h"
@@ -14,6 +14,7 @@
#include "SkShader.h"
#include "SkStream.h"
+
/***
*
* This GM reproduces Skia bug 2904, in which a tiled bitmap shader was failing to draw correctly
@@ -63,8 +64,10 @@
mat.setScale(121.f/360.f, 93.f/288.f);
mat.postTranslate(-72, -72);
- paint.setShader(SkShader::MakeBitmapShader(fBitmap, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &mat));
+ SkShader *shader = SkShader::CreateBitmapShader(fBitmap, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &mat);
+ paint.setShader(shader);
+
+ SkSafeUnref(shader);
canvas->drawRectCoords(8,8,1008, 608, paint);
}
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index d774939..26b8348 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -27,14 +27,15 @@
SkPaint paint;
paint.setDither(true);
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, SK_ARRAY_COUNT(colors),
- SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
static void setup(SkPaint* paint, const SkBitmap& bm, bool filter,
SkShader::TileMode tmx, SkShader::TileMode tmy) {
- paint->setShader(SkShader::MakeBitmapShader(bm, tmx, tmy));
+ SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
+ paint->setShader(shader)->unref();
paint->setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
}
@@ -155,13 +156,13 @@
static const int gWidth = 32;
static const int gHeight = 32;
-static sk_sp<SkShader> make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
+static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm;
makebm(&bm, kN32_SkColorType, gWidth, gHeight);
- return SkShader::MakeBitmapShader(bm, tx, ty);
+ return SkShader::CreateBitmapShader(bm, tx, ty);
}
-static sk_sp<SkShader> make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
+static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
SkScalar rad = SkIntToScalar(gWidth)/2;
@@ -170,16 +171,17 @@
int index = (int)ty;
switch (index % 3) {
case 0:
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 1:
- return SkGradientShader::MakeRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::CreateRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 2:
- return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
+ return SkGradientShader::CreateSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
}
+
return nullptr;
}
-typedef sk_sp<SkShader> (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
+typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
class Tiling2GM : public skiagm::GM {
ShaderProc fProc;
@@ -237,7 +239,7 @@
x += SkIntToScalar(50);
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkPaint paint;
- paint.setShader(fProc(gModes[kx], gModes[ky]));
+ paint.setShader(fProc(gModes[kx], gModes[ky]))->unref();
canvas->save();
canvas->translate(x, y);
diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp
index 21224b4..0d46fb6 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -27,14 +27,15 @@
SkPaint paint;
paint.setDither(true);
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
+ paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
static void setup(SkPaint* paint, const SkBitmap& bm, SkFilterQuality filter_level,
SkShader::TileMode tmx, SkShader::TileMode tmy) {
- paint->setShader(SkShader::MakeBitmapShader(bm, tmx, tmy));
+ SkShader* shader = SkShader::CreateBitmapShader(bm, tmx, tmy);
+ paint->setShader(shader)->unref();
paint->setFilterQuality(filter_level);
}
@@ -159,13 +160,13 @@
static const int gWidth = 32;
static const int gHeight = 32;
-static sk_sp<SkShader> make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
+static SkShader* make_bm(SkShader::TileMode tx, SkShader::TileMode ty) {
SkBitmap bm;
makebm(&bm, kN32_SkColorType, gWidth, gHeight);
- return SkShader::MakeBitmapShader(bm, tx, ty);
+ return SkShader::CreateBitmapShader(bm, tx, ty);
}
-static sk_sp<SkShader> make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
+static SkShader* make_grad(SkShader::TileMode tx, SkShader::TileMode ty) {
SkPoint pts[] = { { 0, 0 }, { SkIntToScalar(gWidth), SkIntToScalar(gHeight)} };
SkPoint center = { SkIntToScalar(gWidth)/2, SkIntToScalar(gHeight)/2 };
SkScalar rad = SkIntToScalar(gWidth)/2;
@@ -174,17 +175,17 @@
int index = (int)ty;
switch (index % 3) {
case 0:
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 1:
- return SkGradientShader::MakeRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
+ return SkGradientShader::CreateRadial(center, rad, colors, nullptr, SK_ARRAY_COUNT(colors), tx);
case 2:
- return SkGradientShader::MakeSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
+ return SkGradientShader::CreateSweep(center.fX, center.fY, colors, nullptr, SK_ARRAY_COUNT(colors));
}
return nullptr;
}
-typedef sk_sp<SkShader> (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
+typedef SkShader* (*ShaderProc)(SkShader::TileMode, SkShader::TileMode);
class ScaledTiling2GM : public skiagm::GM {
ShaderProc fProc;
@@ -242,7 +243,7 @@
x += SkIntToScalar(50);
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
SkPaint paint;
- paint.setShader(fProc(gModes[kx], gModes[ky]));
+ paint.setShader(fProc(gModes[kx], gModes[ky]))->unref();
canvas->save();
canvas->translate(x, y);
diff --git a/gm/tinybitmap.cpp b/gm/tinybitmap.cpp
index 1162b2d..7942b42 100644
--- a/gm/tinybitmap.cpp
+++ b/gm/tinybitmap.cpp
@@ -44,10 +44,12 @@
virtual void onDraw(SkCanvas* canvas) {
SkBitmap bm = make_bitmap();
+ SkShader* s =
+ SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
+ SkShader::kMirror_TileMode);
SkPaint paint;
paint.setAlpha(0x80);
- paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kMirror_TileMode));
+ paint.setShader(s)->unref();
canvas->drawPaint(paint);
}
diff --git a/gm/transparency.cpp b/gm/transparency.cpp
index 5e05761..73bd8b2 100644
--- a/gm/transparency.cpp
+++ b/gm/transparency.cpp
@@ -9,7 +9,9 @@
#include "SkSurface.h"
#include "gm.h"
-static void make_transparency(SkCanvas* canvas, SkScalar width, SkScalar height) {
+static void make_transparency(SkCanvas* canvas,
+ SkScalar width,
+ SkScalar height) {
SkPoint pts[2];
pts[0] = SkPoint::Make(0, 0);
pts[1] = SkPoint::Make(width, 0);
@@ -29,27 +31,30 @@
SkColor shaderColors[2];
shaderColors[0] = SK_AlphaTRANSPARENT;
shaderColors[1] = kColors[i];
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(
+ pts, shaderColors, nullptr, 2, SkShader::kClamp_TileMode));
+ SkRect r = SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight);
SkPaint p;
- p.setShader(SkGradientShader::MakeLinear(pts, shaderColors, nullptr, 2,
- SkShader::kClamp_TileMode));
- canvas->drawRect(SkRect::MakeXYWH(0, i * kRowHeight, width, kRowHeight), p);
+ p.setShader(shader);
+ canvas->drawRect(r, p);
}
}
// http://crrev.com/834303005
-static sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
+static SkShader* create_checkerboard_shader(SkColor c1, SkColor c2, int size) {
SkBitmap bm;
bm.allocN32Pixels(2 * size, 2 * size);
bm.eraseColor(c1);
bm.eraseArea(SkIRect::MakeLTRB(0, 0, size, size), c2);
bm.eraseArea(SkIRect::MakeLTRB(size, size, 2 * size, 2 * size), c2);
- return SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
+ return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode);
}
// http://crrev.com/834303005
static void checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) {
SkPaint paint;
- paint.setShader(create_checkerboard_shader(c1, c2, size));
+ paint.setShader(create_checkerboard_shader(c1, c2, size))->unref();
canvas->drawPaint(paint);
}
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 177dc43..31fb352 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -11,19 +11,20 @@
#include "SkGradientShader.h"
#include "SkRandom.h"
-static sk_sp<SkShader> make_shader1(SkScalar w, SkScalar h) {
+static SkShader* make_shader1(SkScalar w, SkScalar h) {
const SkColor colors[] = {
SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE,
SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW,
};
const SkPoint pts[] = { { w/4, 0 }, { 3*w/4, h } };
- return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
- SkShader::kMirror_TileMode);
+ return SkGradientShader::CreateLinear(pts, colors, nullptr,
+ SK_ARRAY_COUNT(colors),
+ SkShader::kMirror_TileMode);
}
-static sk_sp<SkShader> make_shader2() {
- return SkShader::MakeColorShader(SK_ColorBLUE);
+static SkShader* make_shader2() {
+ return SkShader::CreateColorShader(SK_ColorBLUE);
}
static SkColorFilter* make_color_filter() {
@@ -34,8 +35,8 @@
SkPoint fPts[9];
SkPoint fTexs[9];
SkColor fColors[9];
- sk_sp<SkShader> fShader1;
- sk_sp<SkShader> fShader2;
+ SkAutoTUnref<SkShader> fShader1;
+ SkAutoTUnref<SkShader> fShader2;
SkAutoTUnref<SkColorFilter> fColorFilter;
public:
@@ -58,8 +59,8 @@
fTexs[3].set(0, h/2); fTexs[4].set(w/2, h/2); fTexs[5].set(w, h/2);
fTexs[6].set(0, h); fTexs[7].set(w/2, h); fTexs[8].set(w, h);
- fShader1 = make_shader1(w, h);
- fShader2 = make_shader2();
+ fShader1.reset(make_shader1(w, h));
+ fShader2.reset(make_shader2());
fColorFilter.reset(make_color_filter());
SkRandom rand;
@@ -85,11 +86,11 @@
};
const struct {
- const SkColor* fColors;
- const SkPoint* fTexs;
- const sk_sp<SkShader>& fShader;
- SkColorFilter* fColorFilter;
- uint8_t fAlpha;
+ const SkColor* fColors;
+ const SkPoint* fTexs;
+ SkShader* fShader;
+ SkColorFilter* fColorFilter;
+ uint8_t fAlpha;
} rec[] = {
{ fColors, nullptr, fShader1, nullptr , 0xFF },
{ nullptr, fTexs , fShader1, nullptr , 0xFF },
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index ab6821d..5c67e77 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -15,9 +15,10 @@
static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) {
const SkPoint center = { SkIntToScalar(width)/2, SkIntToScalar(height)/2 };
const SkScalar radius = 40;
+ SkShader* shader = SkGradientShader::CreateRadial(center, radius, colors, nullptr, 2,
+ SkShader::kMirror_TileMode);
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr, 2,
- SkShader::kMirror_TileMode));
+ paint.setShader(shader)->unref();
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
canvas->drawPaint(paint);
}
diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp
index a1427cf..1a71255 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -261,8 +261,10 @@
const SkScalar h = SkIntToScalar(H);
SkMatrix m;
m.setScale(SkIntToScalar(6), SkIntToScalar(6));
- auto s = SkShader::MakeBitmapShader(fBG, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &m);
+ SkShader* s = SkShader::CreateBitmapShader(fBG,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode,
+ &m);
SkPaint labelP;
labelP.setAntiAlias(true);
@@ -323,6 +325,7 @@
y0 = 0;
}
}
+ s->unref();
}
private:
diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp
index 397f4e1..db48c03 100644
--- a/gm/xfermodes2.cpp
+++ b/gm/xfermodes2.cpp
@@ -99,8 +99,10 @@
SkMatrix lm;
lm.setScale(SkIntToScalar(16), SkIntToScalar(16));
- fBG = SkShader::MakeBitmapShader(bg, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode,
- &lm);
+ fBG.reset(SkShader::CreateBitmapShader(bg,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode,
+ &lm));
SkBitmap srcBmp;
srcBmp.allocN32Pixels(kSize, kSize);
@@ -113,8 +115,9 @@
pixels[kSize * y + x] = rowColor;
}
}
- fSrc = SkShader::MakeBitmapShader(srcBmp, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
+ fSrc.reset(SkShader::CreateBitmapShader(srcBmp,
+ SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
SkBitmap dstBmp;
dstBmp.allocN32Pixels(kSize, kSize);
pixels = reinterpret_cast<SkPMColor*>(dstBmp.getPixels());
@@ -126,8 +129,9 @@
pixels[kSize * y + x] = colColor;
}
}
- fDst = SkShader::MakeBitmapShader(dstBmp, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
+ fDst.reset(SkShader::CreateBitmapShader(dstBmp,
+ SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
}
enum {
@@ -135,9 +139,9 @@
kSize = 256 >> kShift,
};
- sk_sp<SkShader> fBG;
- sk_sp<SkShader> fSrc;
- sk_sp<SkShader> fDst;
+ SkAutoTUnref<SkShader> fBG;
+ SkAutoTUnref<SkShader> fSrc;
+ SkAutoTUnref<SkShader> fDst;
typedef GM INHERITED;
};
diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp
index 4cd05df5..8c24bf7 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -185,17 +185,21 @@
SkMatrix lm;
lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize));
- fBGShader = SkShader::MakeBitmapShader(bg, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &lm);
+ fBGShader.reset(SkShader::CreateBitmapShader(bg,
+ SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode,
+ &lm));
SkPaint bmpPaint;
- const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar(kSize) / 2 };
- const SkColor kColors[] = {
- SK_ColorTRANSPARENT, 0x80800000, 0xF020F060, SK_ColorWHITE
- };
- bmpPaint.setShader(SkGradientShader::MakeRadial(kCenter, 3 * SkIntToScalar(kSize) / 4,
- kColors, nullptr, SK_ARRAY_COUNT(kColors),
- SkShader::kRepeat_TileMode));
+ static const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar(kSize) / 2 };
+ static const SkColor kColors[] = { SK_ColorTRANSPARENT, 0x80800000,
+ 0xF020F060, SK_ColorWHITE };
+ bmpPaint.setShader(SkGradientShader::CreateRadial(kCenter,
+ 3 * SkIntToScalar(kSize) / 4,
+ kColors,
+ nullptr,
+ SK_ARRAY_COUNT(kColors),
+ SkShader::kRepeat_TileMode))->unref();
SkBitmap bmp;
bmp.allocN32Pixels(kSize, kSize);
@@ -206,8 +210,9 @@
7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) / 8};
bmpCanvas.drawRect(rect, bmpPaint);
- fBmpShader = SkShader::MakeBitmapShader(bmp, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode);
+ fBmpShader.reset(SkShader::CreateBitmapShader(bmp,
+ SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode));
}
enum {
@@ -216,8 +221,8 @@
kTestsPerRow = 15,
};
- sk_sp<SkShader> fBGShader;
- sk_sp<SkShader> fBmpShader;
+ SkAutoTUnref<SkShader> fBGShader;
+ SkAutoTUnref<SkShader> fBmpShader;
typedef GM INHERITED;
};
diff --git a/tests/BitmapHeapTest.cpp b/tests/BitmapHeapTest.cpp
index 89e6faf..eb86283 100644
--- a/tests/BitmapHeapTest.cpp
+++ b/tests/BitmapHeapTest.cpp
@@ -50,8 +50,9 @@
uint32_t* pixel = bm.getAddr32(1,0);
*pixel = SK_ColorBLUE;
- auto bitmapShader = SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
+ SkShader* bitmapShader = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode);
+ SkAutoTUnref<SkShader> aur(bitmapShader);
// Flatten, storing it in the bitmap heap.
SkBitmapHeap heap(1, 1);
diff --git a/tests/BlitRowTest.cpp b/tests/BlitRowTest.cpp
index 032acda..b6a24eb 100644
--- a/tests/BlitRowTest.cpp
+++ b/tests/BlitRowTest.cpp
@@ -166,8 +166,10 @@
fPts[1].set(w, 0);
fPts[2].set(w, h);
fPts[3].set(0, h);
- paint->setShader(SkShader::MakeBitmapShader(bm, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode));
+ SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode);
+ paint->setShader(s)->unref();
+
}
void draw(SkCanvas* canvas, SkPaint* paint) {
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 8681ca4..f34430f 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -415,8 +415,9 @@
pts[2].set(SkIntToScalar(d.fWidth), SkIntToScalar(d.fHeight));
pts[3].set(0, SkIntToScalar(d.fHeight));
SkPaint paint;
- paint.setShader(SkShader::MakeBitmapShader(d.fBitmap, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode));
+ SkShader* shader = SkShader::CreateBitmapShader(d.fBitmap,
+ SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
+ paint.setShader(shader)->unref();
canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts,
nullptr, nullptr, nullptr, 0, paint);
}
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index 8928d4c..88b9437 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -195,9 +195,11 @@
0.0078740157f,
SkIntToScalar(239),
0, 0, SK_Scalar1);
+ SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode, &matrix);
+
SkPaint paint;
- paint.setShader(SkShader::MakeBitmapShader(bm, SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &matrix));
+ paint.setShader(s)->unref();
SkRect r = SkRect::MakeXYWH(681, 239, 695, 253);
c.drawRect(r, paint);
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index 6521070..cc94cba 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -20,9 +20,9 @@
static void test_big_grad(skiatest::Reporter* reporter) {
const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
const SkPoint pts[] = {{ 15, 14.7112684f }, { 0.709064007f, 12.6108112f }};
+ SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2,
- SkShader::kClamp_TileMode));
+ paint.setShader(s)->unref();
SkBitmap bm;
bm.allocN32Pixels(2000, 1);
@@ -46,7 +46,7 @@
const SkScalar* fRadius; // 2
SkShader::TileMode fTileMode;
- void gradCheck(skiatest::Reporter* reporter, const sk_sp<SkShader>& shader,
+ void gradCheck(skiatest::Reporter* reporter, SkShader* shader,
SkShader::GradientInfo* info,
SkShader::GradientType gt) const {
SkAutoTMalloc<SkColor> colorStorage(fColorCount);
@@ -68,7 +68,7 @@
static void none_gradproc(skiatest::Reporter* reporter, const GradRec&) {
- sk_sp<SkShader> s(SkShader::MakeEmptyShader());
+ SkAutoTUnref<SkShader> s(SkShader::CreateEmptyShader());
REPORTER_ASSERT(reporter, SkShader::kNone_GradientType == s->asAGradient(nullptr));
}
@@ -84,8 +84,11 @@
}
static void linear_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
- sk_sp<SkShader> s(SkGradientShader::MakeLinear(rec.fPoint, rec.fColors, rec.fPos,
- rec.fColorCount, rec.fTileMode));
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(rec.fPoint,
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount,
+ rec.fTileMode));
SkShader::GradientInfo info;
rec.gradCheck(reporter, s, &info, SkShader::kLinear_GradientType);
@@ -93,8 +96,12 @@
}
static void radial_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
- sk_sp<SkShader> s(SkGradientShader::MakeRadial(rec.fPoint[0], rec.fRadius[0], rec.fColors,
- rec.fPos, rec.fColorCount, rec.fTileMode));
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateRadial(rec.fPoint[0],
+ rec.fRadius[0],
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount,
+ rec.fTileMode));
SkShader::GradientInfo info;
rec.gradCheck(reporter, s, &info, SkShader::kRadial_GradientType);
@@ -103,8 +110,11 @@
}
static void sweep_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
- sk_sp<SkShader> s(SkGradientShader::MakeSweep(rec.fPoint[0].fX, rec.fPoint[0].fY, rec.fColors,
- rec.fPos, rec.fColorCount));
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateSweep(rec.fPoint[0].fX,
+ rec.fPoint[0].fY,
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount));
SkShader::GradientInfo info;
rec.gradCheck(reporter, s, &info, SkShader::kSweep_GradientType);
@@ -112,14 +122,14 @@
}
static void conical_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
- sk_sp<SkShader> s(SkGradientShader::MakeTwoPointConical(rec.fPoint[0],
- rec.fRadius[0],
- rec.fPoint[1],
- rec.fRadius[1],
- rec.fColors,
- rec.fPos,
- rec.fColorCount,
- rec.fTileMode));
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[0],
+ rec.fRadius[0],
+ rec.fPoint[1],
+ rec.fRadius[1],
+ rec.fColors,
+ rec.fPos,
+ rec.fColorCount,
+ rec.fTileMode));
SkShader::GradientInfo info;
rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType);
@@ -135,10 +145,15 @@
};
SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE };
const SkScalar pos[] = { 0, SK_Scalar1 };
- SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 2, SkShader::kClamp_TileMode));
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(pts,
+ colors,
+ pos,
+ 2,
+ SkShader::kClamp_TileMode));
SkBitmap outBitmap;
outBitmap.allocN32Pixels(10, 1);
+ SkPaint paint;
+ paint.setShader(s.get());
SkCanvas canvas(outBitmap);
canvas.drawPaint(paint);
SkAutoLockPixels alp(outBitmap);
@@ -189,8 +204,11 @@
const SkPoint pts[] = {{ 100, 50 }, { 100.0001f, 50000 }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
const SkScalar pos[] = { 0, 1 };
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(pts, colors, pos, 2, SkShader::kClamp_TileMode));
+
SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 2, SkShader::kClamp_TileMode));
+ paint.setShader(gradient);
surface->getCanvas()->drawPaint(paint);
}
@@ -206,9 +224,12 @@
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE };
const SkScalar pos[] = {0, 0.200000003f, 0.800000012f, 1 };
- SkPaint paint;
- paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 4, SkShader::kClamp_TileMode));
+ SkAutoTUnref<SkShader> gradient(
+ SkGradientShader::CreateLinear(pts, colors, pos, 4, SkShader::kClamp_TileMode));
+
+ SkPaint paint;
+ paint.setShader(gradient);
SkRect r = {0, 83, 1254, 620};
surface->getCanvas()->drawRect(r, paint);
}
@@ -220,11 +241,12 @@
surface->getCanvas()->clear(SK_ColorRED);
const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
- SkPaint p;
- p.setShader(SkGradientShader::MakeTwoPointConical(
+ SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(
SkPoint::Make(2.5f, 2.5f), 0,
SkPoint::Make(3.0f, 3.0f), 10,
colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
+ SkPaint p;
+ p.setShader(shader);
surface->getCanvas()->drawPaint(p);
// r == 0 for the center pixel.
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index dfb0d35..3def8f5 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -374,9 +374,12 @@
SkColor colors[2];
colors[0] = SK_ColorWHITE;
colors[1] = SK_ColorBLACK;
+ SkAutoTUnref<SkShader> shader(
+ SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
+ SkShader::kClamp_TileMode)
+ );
SkPaint paint;
- paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius, colors, nullptr, 2,
- SkShader::kClamp_TileMode));
+ paint.setShader(shader);
canvas.drawCircle(x, y, radius, paint);
return bitmap;
}
diff --git a/tests/PaintImageFilterTest.cpp b/tests/PaintImageFilterTest.cpp
index f1c0c2e..b71fe47 100644
--- a/tests/PaintImageFilterTest.cpp
+++ b/tests/PaintImageFilterTest.cpp
@@ -30,9 +30,10 @@
SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
SkScalar radius = SkIntToScalar(5);
- SkPaint gradientPaint;
- gradientPaint.setShader(SkGradientShader::MakeRadial(
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateRadial(
center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
+ SkPaint gradientPaint;
+ gradientPaint.setShader(s);
// Test using the image filter
{
@@ -76,9 +77,10 @@
SkScalar pos[] = {0, SK_ScalarHalf, SK_Scalar1};
SkScalar radius = SkIntToScalar(5);
- SkPaint gradientPaint;
- gradientPaint.setShader(SkGradientShader::MakeRadial(
+ SkAutoTUnref<SkShader> s(SkGradientShader::CreateRadial(
center, radius, colors, pos, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode));
+ SkPaint gradientPaint;
+ gradientPaint.setShader(s);
// Test using the image filter
{
diff --git a/tests/PictureShaderTest.cpp b/tests/PictureShaderTest.cpp
index 4da7aab..14bdcf2 100644
--- a/tests/PictureShaderTest.cpp
+++ b/tests/PictureShaderTest.cpp
@@ -22,8 +22,9 @@
SkCanvas canvas(bitmap);
canvas.clear(SK_ColorGREEN);
- paint.setShader(SkShader::MakePictureShader(
- nullptr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullptr));
+ SkShader* shader = SkShader::CreatePictureShader(
+ nullptr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullptr);
+ paint.setShader(shader)->unref();
canvas.drawRect(SkRect::MakeWH(1,1), paint);
REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN);
@@ -31,9 +32,10 @@
SkPictureRecorder factory;
factory.beginRecording(0, 0, nullptr, 0);
- sk_sp<SkPicture> picture(factory.endRecording());
- paint.setShader(SkShader::MakePictureShader(std::move(picture), SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode, nullptr, nullptr));
+ SkAutoTUnref<SkPicture> picture(factory.endRecording());
+ shader = SkShader::CreatePictureShader(
+ picture.get(), SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullptr);
+ paint.setShader(shader)->unref();
canvas.drawRect(SkRect::MakeWH(1,1), paint);
REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN);
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 3654a77..448e079 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -79,9 +79,10 @@
bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2));
bitmap.eraseColor(SK_ColorBLUE);
*(bitmap.getAddr32(0, 0)) = SK_ColorGREEN;
- paint.setShader(SkShader::MakeBitmapShader(bitmap, SkShader::kClamp_TileMode,
- SkShader::kClamp_TileMode));
- REPORTER_ASSERT(reporter, paint.getShader()->isABitmap());
+ SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp_TileMode,
+ SkShader::kClamp_TileMode);
+ paint.setShader(shader)->unref();
+ REPORTER_ASSERT(reporter, shader->isABitmap());
canvas->drawRect(SkRect::MakeWH(10, 10), paint);
}
@@ -1388,7 +1389,7 @@
DEF_TEST(MiniRecorderLeftHanging, r) {
// Any shader or other ref-counted effect will do just fine here.
SkPaint paint;
- paint.setShader(SkShader::MakeColorShader(SK_ColorRED));
+ paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref();
SkMiniRecorder rec;
REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint));
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 9d7fda5..b4bc58d 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -58,7 +58,7 @@
SkRect bounds = SkRect::MakeWH(320, 240);
SkPaint paint;
- paint.setShader(SkShader::MakeEmptyShader());
+ paint.setShader(SkShader::CreateEmptyShader())->unref();
REPORTER_ASSERT(r, paint.getShader()->unique());
{
diff --git a/tests/ShaderOpacityTest.cpp b/tests/ShaderOpacityTest.cpp
index 698d544..90d25d7 100644
--- a/tests/ShaderOpacityTest.cpp
+++ b/tests/ShaderOpacityTest.cpp
@@ -17,36 +17,42 @@
bmp.setInfo(info);
// test 1: bitmap without pixel data
- auto shader = SkShader::MakeBitmapShader(bmp,
+ SkShader* shader = SkShader::CreateBitmapShader(bmp,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
REPORTER_ASSERT(reporter, shader);
REPORTER_ASSERT(reporter, !shader->isOpaque());
+ shader->unref();
// From this point on, we have pixels
bmp.allocPixels(info);
// test 2: not opaque by default
- shader = SkShader::MakeBitmapShader(bmp,
+ shader = SkShader::CreateBitmapShader(bmp,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
REPORTER_ASSERT(reporter, shader);
REPORTER_ASSERT(reporter, !shader->isOpaque());
+ shader->unref();
// test 3: explicitly opaque
bmp.setAlphaType(kOpaque_SkAlphaType);
- shader = SkShader::MakeBitmapShader(bmp,
+ shader = SkShader::CreateBitmapShader(bmp,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
REPORTER_ASSERT(reporter, shader);
REPORTER_ASSERT(reporter, shader->isOpaque());
+ shader->unref();
// test 4: explicitly not opaque
bmp.setAlphaType(kPremul_SkAlphaType);
- shader = SkShader::MakeBitmapShader(bmp,
+ shader = SkShader::CreateBitmapShader(bmp,
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
REPORTER_ASSERT(reporter, shader);
REPORTER_ASSERT(reporter, !shader->isOpaque());
+ shader->unref();
+
}
-static void test_gradient(skiatest::Reporter* reporter) {
+static void test_gradient(skiatest::Reporter* reporter)
+{
SkPoint pts[2];
pts[0].iset(0, 0);
pts[1].iset(1, 0);
@@ -58,33 +64,39 @@
// test 1: all opaque
colors[0] = SkColorSetARGB(0xFF, 0, 0, 0);
colors[1] = SkColorSetARGB(0xFF, 0, 0, 0);
- auto grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode);
+ SkShader* grad = SkGradientShader::CreateLinear(pts, colors, pos, count,
+ mode);
REPORTER_ASSERT(reporter, grad);
REPORTER_ASSERT(reporter, grad->isOpaque());
+ grad->unref();
// test 2: all 0 alpha
colors[0] = SkColorSetARGB(0, 0, 0, 0);
colors[1] = SkColorSetARGB(0, 0, 0, 0);
- grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode);
+ grad = SkGradientShader::CreateLinear(pts, colors, pos, count, mode);
REPORTER_ASSERT(reporter, grad);
REPORTER_ASSERT(reporter, !grad->isOpaque());
+ grad->unref();
// test 3: one opaque, one transparent
colors[0] = SkColorSetARGB(0xFF, 0, 0, 0);
colors[1] = SkColorSetARGB(0x40, 0, 0, 0);
- grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode);
+ grad = SkGradientShader::CreateLinear(pts, colors, pos, count, mode);
REPORTER_ASSERT(reporter, grad);
REPORTER_ASSERT(reporter, !grad->isOpaque());
+ grad->unref();
// test 4: test 3, swapped
colors[0] = SkColorSetARGB(0x40, 0, 0, 0);
colors[1] = SkColorSetARGB(0xFF, 0, 0, 0);
- grad = SkGradientShader::MakeLinear(pts, colors, pos, count, mode);
+ grad = SkGradientShader::CreateLinear(pts, colors, pos, count, mode);
REPORTER_ASSERT(reporter, grad);
REPORTER_ASSERT(reporter, !grad->isOpaque());
+ grad->unref();
}
-static void test_color(skiatest::Reporter* reporter) {
+static void test_color(skiatest::Reporter* reporter)
+{
SkColorShader colorShader1(SkColorSetARGB(0,0,0,0));
REPORTER_ASSERT(reporter, !colorShader1.isOpaque());
SkColorShader colorShader2(SkColorSetARGB(0xFF,0,0,0));