aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-21 19:56:46 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-21 19:56:46 +0000
commit4b8f8022550daa7458ed3de207d1300917d4a8cb (patch)
treefae718eef5b69f2346b461b580a2b73527f74ef0
parente4ae0bc5caeed52e07c7e5939fa4ac38d9e408ab (diff)
Remove unused (by clients) SkUnitMapper (https://codereview.chromium.org/283273002/)
This reverts commit dd50c83b5b34dab3a077741861b50ed1f2bc6b8f. BUG=skia: R=scroggo@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/288343009 git-svn-id: http://skia.googlecode.com/svn/trunk@14830 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/GradientBench.cpp47
-rw-r--r--expectations/gm/ignored-tests.txt14
-rw-r--r--experimental/SkiaExamples/HelloSkiaExample.cpp6
-rw-r--r--experimental/webtry/templates/template.cpp1
-rw-r--r--gm/alphagradients.cpp3
-rw-r--r--gm/colortype.cpp2
-rw-r--r--gm/convexpolyclip.cpp2
-rw-r--r--gm/drawbitmaprect.cpp2
-rw-r--r--gm/gradientDirtyLaundry.cpp23
-rw-r--r--gm/gradient_matrix.cpp4
-rw-r--r--gm/gradients.cpp41
-rw-r--r--gm/gradients_2pt_conical.cpp102
-rw-r--r--gm/gradients_no_texture.cpp33
-rw-r--r--gm/shaderbounds.cpp2
-rw-r--r--gm/shadertext.cpp40
-rw-r--r--gm/shadertext2.cpp9
-rw-r--r--gm/shadertext3.cpp10
-rw-r--r--gm/tilemodes.cpp10
-rw-r--r--gm/tilemodes_scaled.cpp10
-rw-r--r--gyp/SampleApp.gyp2
-rw-r--r--gyp/core.gypi1
-rw-r--r--gyp/public_headers.gypi2
-rw-r--r--gyp/skia_for_chromium_defines.gypi1
-rw-r--r--gyp/utils.gyp2
-rw-r--r--include/core/SkFlattenable.h2
-rw-r--r--include/core/SkPicture.h3
-rw-r--r--include/core/SkReadBuffer.h8
-rw-r--r--include/core/SkUnitMapper.h37
-rw-r--r--include/effects/SkGradientShader.h97
-rw-r--r--samplecode/SampleAll.cpp9
-rw-r--r--samplecode/SampleGradients.cpp35
-rw-r--r--samplecode/SampleLayers.cpp2
-rw-r--r--samplecode/SamplePatch.cpp2
-rw-r--r--samplecode/SampleShaderText.cpp40
-rw-r--r--samplecode/SampleSlides.cpp29
-rw-r--r--samplecode/SampleTiling.cpp10
-rw-r--r--samplecode/SampleUnitMapper.cpp172
-rw-r--r--samplecode/SampleVertices.cpp2
-rw-r--r--src/animator/SkDrawGradient.cpp52
-rw-r--r--src/animator/SkDrawGradient.h3
-rw-r--r--src/core/SkReadBuffer.cpp22
-rw-r--r--src/core/SkValidatingReadBuffer.cpp12
-rw-r--r--src/core/SkValidatingReadBuffer.h1
-rw-r--r--src/effects/gradients/SkGradientShader.cpp75
-rw-r--r--src/effects/gradients/SkGradientShaderPriv.h3
-rw-r--r--src/utils/SkUnitMappers.cpp61
-rw-r--r--tests/DeferredCanvasTest.cpp2
47 files changed, 268 insertions, 780 deletions
diff --git a/bench/GradientBench.cpp b/bench/GradientBench.cpp
index 55e777d8fb..fa07bce4fd 100644
--- a/bench/GradientBench.cpp
+++ b/bench/GradientBench.cpp
@@ -13,7 +13,6 @@
#include "SkPaint.h"
#include "SkShader.h"
#include "SkString.h"
-#include "SkUnitMapper.h"
struct GradData {
int fCount;
@@ -45,38 +44,33 @@ static const GradData gGradData[] = {
/// Ignores scale
static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ SkShader::TileMode tm, float scale) {
+ return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCount, tm);
}
static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
return SkGradientShader::CreateRadial(center, center.fX * scale,
data.fColors,
- data.fPos, data.fCount, tm, mapper);
+ data.fPos, data.fCount, tm);
}
/// Ignores scale
static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
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, mapper);
+ data.fPos, data.fCount);
}
/// Ignores scale
static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
@@ -85,13 +79,12 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
/// Ignores scale
static SkShader* MakeConical(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
@@ -99,13 +92,12 @@ static SkShader* MakeConical(const SkPoint pts[2], const GradData& data,
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
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, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
/// Ignores scale
static SkShader* MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center0, center1;
center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
@@ -113,13 +105,12 @@ static SkShader* MakeConicalZeroRad(const SkPoint pts[2], const GradData& data,
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
return SkGradientShader::CreateTwoPointConical(center1, 0.0,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
/// Ignores scale
static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -128,13 +119,12 @@ static SkShader* MakeConicalOutside(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm);
}
/// Ignores scale
static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale) {
+ SkShader::TileMode tm, float scale) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -143,12 +133,11 @@ static SkShader* MakeConicalOutsideZeroRad(const SkPoint pts[2], const GradData&
return SkGradientShader::CreateTwoPointConical(center0, 0.0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm);
}
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- float scale);
+ SkShader::TileMode tm, float scale);
static const struct {
GradMaker fMaker;
@@ -240,7 +229,7 @@ public:
{ SkIntToScalar(W), SkIntToScalar(H) }
};
- fShader = gGrads[gradType].fMaker(pts, data, tm, NULL, scale);
+ fShader = gGrads[gradType].fMaker(pts, data, tm, scale);
fGeomType = geomType;
}
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index c134382420..81313f1592 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -51,4 +51,16 @@ simpleblurroundrect
downsamplebitmap_checkerboard_high_512_256
downsamplebitmap_image_high_mandrill_512.png
filterbitmap_checkerboard_192_192
-downsamplebitmap_text_high_72.00pt \ No newline at end of file
+downsamplebitmap_text_high_72.00pt
+
+# These are part of picture-version 27 -- removal of SkUnitMapp
+# just need to be rebaselined
+scaled_tilemode_bitmap
+scaled_tilemodes_npot
+scaled_tilemodes
+tilemode_bitmap
+tilemodes_npot
+tilemodes
+shadertext3
+shadertext
+shadertext2
diff --git a/experimental/SkiaExamples/HelloSkiaExample.cpp b/experimental/SkiaExamples/HelloSkiaExample.cpp
index 0b6c790460..6fd2624c18 100644
--- a/experimental/SkiaExamples/HelloSkiaExample.cpp
+++ b/experimental/SkiaExamples/HelloSkiaExample.cpp
@@ -13,7 +13,6 @@
#include "SkDraw.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
-#include "SkUnitMappers.h"
class HelloSkia : public SkExample {
public:
@@ -50,12 +49,9 @@ protected:
};
SkColor linearColors[] = {SK_ColorGREEN, SK_ColorBLACK};
- SkUnitMapper* linearMapper = new SkDiscreteMapper(100);
- SkAutoUnref lm_deleter(linearMapper);
-
SkShader* shader = SkGradientShader::CreateLinear(
linearPoints, linearColors, NULL, 2,
- SkShader::kMirror_TileMode, linearMapper);
+ SkShader::kMirror_TileMode);
SkAutoUnref shader_deleter(shader);
paint.setShader(shader);
diff --git a/experimental/webtry/templates/template.cpp b/experimental/webtry/templates/template.cpp
index 5b017f0dff..67d2c04dc9 100644
--- a/experimental/webtry/templates/template.cpp
+++ b/experimental/webtry/templates/template.cpp
@@ -150,7 +150,6 @@
#include "SkTSearch.h"
#include "SkTypeface.h"
#include "SkTypes.h"
-#include "SkUnitMapper.h"
#include "SkUnPreMultiply.h"
#include "SkUtils.h"
#include "SkWeakRefCnt.h"
diff --git a/gm/alphagradients.cpp b/gm/alphagradients.cpp
index e63fbc9f47..d10828867d 100644
--- a/gm/alphagradients.cpp
+++ b/gm/alphagradients.cpp
@@ -29,8 +29,7 @@ protected:
SkPaint paint;
uint32_t flags = doPreMul ? SkGradientShader::kInterpolateColorsInPremul_Flag : 0;
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2,
- SkShader::kClamp_TileMode,
- NULL, flags);
+ SkShader::kClamp_TileMode, flags, NULL);
paint.setShader(s)->unref();
canvas->drawRect(r, paint);
diff --git a/gm/colortype.cpp b/gm/colortype.cpp
index 47bc8a9ab7..2774f3a5ff 100644
--- a/gm/colortype.cpp
+++ b/gm/colortype.cpp
@@ -20,7 +20,7 @@ public:
SkMatrix local;
local.setRotate(180);
SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL,
- SK_ARRAY_COUNT(colors), NULL, 0, &local);
+ SK_ARRAY_COUNT(colors), 0, &local);
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp
index b76335c856..edafea2f97 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -46,7 +46,7 @@ static SkBitmap make_bmp(int w, int h) {
colors, pos,
SK_ARRAY_COUNT(colors),
SkShader::kRepeat_TileMode,
- NULL, 0, &mat))->unref();
+ 0, &mat))->unref();
canvas.drawRect(rect, paint);
rect.inset(wScalar / 8, hScalar / 8);
mat.preTranslate(6 * wScalar, 6 * hScalar);
diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp
index d9b1434e57..33a13f0fe9 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -63,7 +63,7 @@ static void makebm(SkBitmap* bm, int w, int h) {
colors, pos,
SK_ARRAY_COUNT(colors),
SkShader::kRepeat_TileMode,
- NULL, 0, &mat))->unref();
+ 0, &mat))->unref();
canvas.drawRect(rect, paint);
rect.inset(wScalar / 8, hScalar / 8);
mat.postScale(SK_Scalar1 / 4, SK_Scalar1 / 4);
diff --git a/gm/gradientDirtyLaundry.cpp b/gm/gradientDirtyLaundry.cpp
index f7797e718f..baa7471ef2 100644
--- a/gm/gradientDirtyLaundry.cpp
+++ b/gm/gradientDirtyLaundry.cpp
@@ -35,33 +35,28 @@ static const GradData gGradData[] = {
// { 2, gCol2, NULL },
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode, SkUnitMapper* mapper) {
+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, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep,
};
@@ -95,7 +90,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
- SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL);
+ 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 4f2915ab4d..275acc8868 100644
--- a/gm/gradient_matrix.cpp
+++ b/gm/gradient_matrix.cpp
@@ -63,7 +63,7 @@ static const int IMAGES_X = 4; // number of images per row
static SkShader* make_linear_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
return SkGradientShader::CreateLinear(pts, gColors, NULL, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, NULL, 0, &localMatrix);
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
static SkShader* make_radial_gradient(const SkPoint pts[2], const SkMatrix& localMatrix) {
@@ -72,7 +72,7 @@ static SkShader* make_radial_gradient(const SkPoint pts[2], const SkMatrix& loca
SkScalarAve(pts[0].fY, pts[1].fY));
float radius = (center - pts[0]).length();
return SkGradientShader::CreateRadial(center, radius, gColors, NULL, SK_ARRAY_COUNT(gColors),
- SkShader::kClamp_TileMode, NULL, 0, &localMatrix);
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
static void draw_gradients(SkCanvas* canvas,
diff --git a/gm/gradients.cpp b/gm/gradients.cpp
index f5abb07efc..277033b5dd 100644
--- a/gm/gradients.cpp
+++ b/gm/gradients.cpp
@@ -40,35 +40,31 @@ static const GradData gGradData[] = {
};
static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper, 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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::CreateRadial(center, center.fX, data.fColors,
- data.fPos, data.fCount, tm, mapper, 0, &localMatrix);
+ data.fPos, data.fCount, tm, 0, &localMatrix);
}
static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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::CreateSweep(center.fX, center.fY, data.fColors,
- data.fPos, data.fCount, mapper, 0, &localMatrix);
+ data.fPos, data.fCount, 0, &localMatrix);
}
static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -77,13 +73,12 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -92,13 +87,11 @@ static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix);
+ SkShader::TileMode tm, const SkMatrix& localMatrix);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical
};
@@ -144,7 +137,7 @@ protected:
scale.postTranslate(25.f, 25.f);
}
- SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL, scale);
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, scale);
paint.setShader(shader);
canvas->drawRect(r, paint);
@@ -202,7 +195,7 @@ protected:
perspective.setSkewX(SkScalarDiv(SkIntToScalar((unsigned) i+1),
SkIntToScalar(10)));
- SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL, perspective);
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, perspective);
paint.setShader(shader);
canvas->drawRect(r, paint);
@@ -327,7 +320,7 @@ protected:
SkShader* shader = SkGradientShader::CreateRadial(
SkPoint(center),
SkIntToScalar(200), gColors, NULL, 5,
- SkShader::kClamp_TileMode, NULL);
+ SkShader::kClamp_TileMode);
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
@@ -422,17 +415,17 @@ protected:
SkAutoTUnref<SkShader> sweep(
SkGradientShader::CreateSweep(cx, cy, sweep_colors,
NULL, SK_ARRAY_COUNT(sweep_colors),
- NULL, flags[i]));
+ flags[i], NULL));
SkAutoTUnref<SkShader> radial1(
SkGradientShader::CreateRadial(center, radius, colors1,
NULL, SK_ARRAY_COUNT(colors1),
SkShader::kClamp_TileMode,
- NULL, flags[i]));
+ flags[i], NULL));
SkAutoTUnref<SkShader> radial2(
SkGradientShader::CreateRadial(center, radius, colors2,
NULL, SK_ARRAY_COUNT(colors2),
SkShader::kClamp_TileMode,
- NULL, flags[i]));
+ flags[i], NULL));
paint1.setShader(sweep);
paint2.setShader(radial1);
paint3.setShader(radial2);
diff --git a/gm/gradients_2pt_conical.cpp b/gm/gradients_2pt_conical.cpp
index dece66ed8b..27f0da186d 100644
--- a/gm/gradients_2pt_conical.cpp
+++ b/gm/gradients_2pt_conical.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 "SkGradientShader.h"
@@ -38,8 +38,7 @@ static const GradData gGradData[] = {
};
static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -48,13 +47,11 @@ static SkShader* Make2ConicalOutside(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -63,13 +60,11 @@ static SkShader* Make2ConicalOutsideFlip(const SkPoint pts[2], const GradData& d
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -77,13 +72,12 @@ static SkShader* Make2ConicalInside(const SkPoint pts[2], const GradData& data,
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -91,13 +85,12 @@ static SkShader* Make2ConicalInsideFlip(const SkPoint pts[2], const GradData& da
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -105,13 +98,12 @@ static SkShader* Make2ConicalInsideCenter(const SkPoint pts[2], const GradData&
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -119,13 +111,12 @@ static SkShader* Make2ConicalZeroRad(const SkPoint pts[2], const GradData& data,
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -133,13 +124,12 @@ static SkShader* Make2ConicalZeroRadFlip(const SkPoint pts[2], const GradData& d
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -147,13 +137,12 @@ static SkShader* Make2ConicalZeroRadCenter(const SkPoint pts[2], const GradData&
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, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -162,13 +151,11 @@ static SkShader* Make2ConicalZeroRadOutside(const SkPoint pts[2], const GradData
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -177,13 +164,11 @@ static SkShader* Make2ConicalZeroRadFlipOutside(const SkPoint pts[2], const Grad
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -193,13 +178,11 @@ static SkShader* Make2ConicalEdgeX(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -209,12 +192,10 @@ static SkShader* Make2ConicalEdgeY(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -224,13 +205,11 @@ static SkShader* Make2ConicalZeroRadEdgeX(const SkPoint pts[2], const GradData&
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = 0.f;
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -240,13 +219,11 @@ static SkShader* Make2ConicalZeroRadEdgeY(const SkPoint pts[2], const GradData&
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -256,13 +233,11 @@ static SkShader* Make2ConicalTouchX(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ SkShader::TileMode tm, const SkMatrix& localMatrix) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 7);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -272,13 +247,11 @@ static SkShader* Make2ConicalTouchY(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center0, radius0,
center1, radius1,
data.fColors, data.fPos,
- data.fCount, tm, mapper,
- 0, &localMatrix);
+ data.fCount, tm, 0, &localMatrix);
}
static SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix) {
+ 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));
@@ -286,13 +259,12 @@ static SkShader* Make2ConicalInsideSmallRad(const SkPoint pts[2], const GradData
SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
return SkGradientShader::CreateTwoPointConical(center0, 0.0000000000000000001f,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper,
+ data.fColors, data.fPos, data.fCount, tm,
0, &localMatrix);
}
typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper,
- const SkMatrix& localMatrix);
+ SkShader::TileMode tm, const SkMatrix& localMatrix);
static const GradMaker gGradMakersOutside[] = {
Make2ConicalOutside, Make2ConicalOutsideFlip,
@@ -378,7 +350,7 @@ protected:
scale.postTranslate(25.f, 25.f);
}
- SkShader* shader = gradMaker[j](pts, gGradData[i], tm, NULL, scale);
+ SkShader* shader = gradMaker[j](pts, gGradData[i], tm, scale);
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
diff --git a/gm/gradients_no_texture.cpp b/gm/gradients_no_texture.cpp
index 2e75c9ed79..fcbba45ae7 100644
--- a/gm/gradients_no_texture.cpp
+++ b/gm/gradients_no_texture.cpp
@@ -26,32 +26,26 @@ static const GradData gGradData[] = {
{ 4, gColors, NULL },
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode, SkUnitMapper* mapper) {
+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, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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));
@@ -60,11 +54,10 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
-static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm) {
SkPoint center0, center1;
SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
@@ -73,12 +66,12 @@ static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointConical(center1, radius1,
center0, radius0,
data.fColors, data.fPos,
- data.fCount, tm, mapper);
+ data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2Conical,
};
@@ -113,7 +106,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); ++i) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); ++j) {
- SkShader* shader = gGradMakers[j](kPts, gGradData[i], kTM, NULL);
+ SkShader* shader = gGradMakers[j](kPts, gGradData[i], kTM);
paint.setShader(shader)->unref();
paint.setAlpha(kAlphas[a]);
canvas->drawRect(kRect, paint);
diff --git a/gm/shaderbounds.cpp b/gm/shaderbounds.cpp
index f0b8b9781d..f82985bf52 100644
--- a/gm/shaderbounds.cpp
+++ b/gm/shaderbounds.cpp
@@ -19,7 +19,7 @@ static SkShader* MakeLinear(SkScalar width, SkScalar height, bool alternate,
colors[1] = SK_ColorYELLOW;
}
return SkGradientShader::CreateLinear(pts, colors, NULL, 2,
- SkShader::kClamp_TileMode, NULL, 0, &localMatrix);
+ SkShader::kClamp_TileMode, 0, &localMatrix);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp
index b9e28be898..292acdd7a6 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -1,14 +1,13 @@
-
/*
* Copyright 2011 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 "SkCanvas.h"
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
namespace skiagm {
@@ -23,15 +22,9 @@ static void makebm(SkBitmap* bm, int w, int h) {
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-
- SkAutoUnref au(um);
-
paint.setDither(true);
paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
@@ -61,32 +54,26 @@ static const GradData gGradData[] = {
{ 5, gColors, NULL },
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode, SkUnitMapper* mapper) {
+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, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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));
@@ -95,11 +82,11 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial
};
@@ -154,8 +141,7 @@ protected:
for (size_t m = 0; m < SK_ARRAY_COUNT(gGradMakers); ++m) {
shaders[shdIdx++] = gGradMakers[m](pts,
gGradData[d],
- SkShader::kClamp_TileMode,
- NULL);
+ SkShader::kClamp_TileMode);
}
}
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp
index d6a9a721cd..27b517517e 100644
--- a/gm/shadertext2.cpp
+++ b/gm/shadertext2.cpp
@@ -7,7 +7,6 @@
#include "gm.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
namespace skiagm {
@@ -26,14 +25,8 @@ static void makebm(SkBitmap* bm, int w, int h) {
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-
- SkAutoUnref au(um);
-
paint.setShader(SkGradientShader::CreateLinear(kPts0, kColors0, kPos,
- SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
paint.setShader(SkGradientShader::CreateLinear(kPts1, kColors1, kPos,
SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode))->unref();
diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp
index 8aa6e6965c..3c6400d8d6 100644
--- a/gm/shadertext3.cpp
+++ b/gm/shadertext3.cpp
@@ -4,10 +4,10 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "gm.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
namespace skiagm {
@@ -26,14 +26,8 @@ static void makebm(SkBitmap* bm, int w, int h) {
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-
- SkAutoUnref au(um);
-
paint.setShader(SkGradientShader::CreateLinear(kPts0, kColors0, kPos,
- SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(kColors0), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
paint.setShader(SkGradientShader::CreateLinear(kPts1, kColors1, kPos,
SK_ARRAY_COUNT(kColors1), SkShader::kClamp_TileMode))->unref();
diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp
index e04c52ae0f..99d3a4708b 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -16,7 +16,6 @@
// effects
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
#include "SkBlurDrawLooper.h"
static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
@@ -29,16 +28,9 @@ static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-// um = new SkDiscreteMapper(12);
-
- SkAutoUnref au(um);
-
paint.setDither(true);
paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp
index a79002b56b..88a070afb5 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -17,7 +17,6 @@
// effects
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
#include "SkBlurDrawLooper.h"
static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
@@ -30,16 +29,9 @@ static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-// um = new SkDiscreteMapper(12);
-
- SkAutoUnref au(um);
-
paint.setDither(true);
paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index edcba1078e..3eb735f74b 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -106,7 +106,6 @@
'../samplecode/SampleTextureDomain.cpp',
'../samplecode/SampleTiling.cpp',
'../samplecode/SampleTinyBitmap.cpp',
- '../samplecode/SampleUnitMapper.cpp',
'../samplecode/SampleUnpremul.cpp',
'../samplecode/SampleVertices.cpp',
'../samplecode/SampleXfermodesBlur.cpp',
@@ -273,7 +272,6 @@
[ 'skia_os == "android"', {
'sources!': [
'../samplecode/SampleAnimator.cpp',
- '../samplecode/SampleUnitMapper.cpp',
],
'dependencies!': [
'animator.gyp:animator',
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 46764328c7..c5d3b0069f 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -307,7 +307,6 @@
'<(skia_include_path)/core/SkTypeface.h',
'<(skia_include_path)/core/SkTypes.h',
'<(skia_include_path)/core/SkUnPreMultiply.h',
- '<(skia_include_path)/core/SkUnitMapper.h',
'<(skia_include_path)/core/SkUtils.h',
'<(skia_include_path)/core/SkWeakRefCnt.h',
'<(skia_include_path)/core/SkWriter32.h',
diff --git a/gyp/public_headers.gypi b/gyp/public_headers.gypi
index bffcf7d23b..7432d4c706 100644
--- a/gyp/public_headers.gypi
+++ b/gyp/public_headers.gypi
@@ -117,7 +117,6 @@
'utils/win/SkIStream.h',
'utils/win/SkTScopedComPtr.h',
'utils/SkBoundaryPatch.h',
- 'utils/SkUnitMappers.h',
'utils/SkPictureUtils.h',
'utils/SkRandom.h',
'utils/SkMeshUtils.h',
@@ -258,7 +257,6 @@
'core/SkWriter32.h',
'core/SkError.h',
'core/SkPath.h',
- 'core/SkUnitMapper.h',
'core/SkFlattenable.h',
'core/SkTSearch.h',
'core/SkRect.h',
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index f2ed5c335e..632c532513 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -16,7 +16,6 @@
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
'SK_SUPPORT_LEGACY_N32_NAME',
'SK_SUPPORT_LEGACY_BUILDMIPMAP',
- 'SK_SUPPORT_LEGACY_SHADER_LOCALMATRIX',
],
},
}
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index 5b3d9ea98c..9009ad9571 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -56,7 +56,6 @@
'../include/utils/SkRandom.h',
'../include/utils/SkRTConf.h',
'../include/utils/SkProxyCanvas.h',
- '../include/utils/SkUnitMappers.h',
'../include/utils/SkWGL.h',
'../src/utils/SkBase64.cpp',
@@ -110,7 +109,6 @@
'../src/utils/SkThreadUtils_win.h',
'../src/utils/SkTFitsIn.h',
'../src/utils/SkTLogic.h',
- '../src/utils/SkUnitMappers.cpp',
#mac
'../include/utils/mac/SkCGUtils.h',
diff --git a/include/core/SkFlattenable.h b/include/core/SkFlattenable.h
index ee7a433710..f6d377a9d7 100644
--- a/include/core/SkFlattenable.h
+++ b/include/core/SkFlattenable.h
@@ -61,7 +61,7 @@ public:
kSkPixelRef_Type,
kSkRasterizer_Type,
kSkShader_Type,
- kSkUnitMapper_Type,
+ kSkUnused_Type, // used to be SkUnitMapper
kSkXfermode_Type,
};
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index e17a0d4bd3..58335ac728 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -327,13 +327,14 @@ protected:
// V24: SkTwoPointConicalGradient now has fFlipped flag for gradient flipping
// V25: SkDashPathEffect now only writes phase and interval array when flattening
// V26: Removed boolean from SkColorShader for inheriting color from SkPaint.
+ // V27: Remove SkUnitMapper from gradients (and skia).
// Note: If the picture version needs to be increased then please follow the
// steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
// Only SKPs within the min/current picture version range (inclusive) can be read.
static const uint32_t MIN_PICTURE_VERSION = 19;
- static const uint32_t CURRENT_PICTURE_VERSION = 26;
+ static const uint32_t CURRENT_PICTURE_VERSION = 27;
mutable uint32_t fUniqueID;
diff --git a/include/core/SkReadBuffer.h b/include/core/SkReadBuffer.h
index 4da27d4fe0..e962234ddb 100644
--- a/include/core/SkReadBuffer.h
+++ b/include/core/SkReadBuffer.h
@@ -23,7 +23,6 @@
#include "SkReader32.h"
#include "SkRefCnt.h"
#include "SkShader.h"
-#include "SkUnitMapper.h"
#include "SkWriteBuffer.h"
#include "SkXfermode.h"
@@ -45,6 +44,7 @@ public:
kGradientFlippedFlag_Version = 24,
kDashWritesPhaseIntervals_Version = 25,
kColorShaderNoBool_Version = 26,
+ kNoUnitMappers_Version = 27,
};
/**
@@ -121,9 +121,13 @@ public:
SkPixelRef* readPixelRef() { return this->readFlattenable<SkPixelRef>(); }
SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
SkShader* readShader() { return this->readFlattenable<SkShader>(); }
- SkUnitMapper* readUnitMapper() { return this->readFlattenable<SkUnitMapper>(); }
SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); }
+ /**
+ * Like readFlattenable() but explicitly just skips the data that was written for the
+ * flattenable (or the sentinel that there wasn't one).
+ */
+ virtual void skipFlattenable();
// binary data and arrays
virtual bool readByteArray(void* value, size_t size);
diff --git a/include/core/SkUnitMapper.h b/include/core/SkUnitMapper.h
deleted file mode 100644
index 46f6eddd70..0000000000
--- a/include/core/SkUnitMapper.h
+++ /dev/null
@@ -1,37 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkUnitMapper_DEFINED
-#define SkUnitMapper_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkScalar.h"
-
-#include "SkFlattenable.h"
-
-class SkUnitMapper : public SkFlattenable {
-public:
- SK_DECLARE_INST_COUNT(SkUnitMapper)
-
- SkUnitMapper() {}
-
- /** Given a value in [0..0xFFFF], return a value in the same range.
- */
- virtual uint16_t mapUnit16(uint16_t x) = 0;
-
- SK_DEFINE_FLATTENABLE_TYPE(SkUnitMapper)
-
-protected:
- SkUnitMapper(SkReadBuffer& rb) : SkFlattenable(rb) {}
-
-private:
- typedef SkFlattenable INHERITED;
-};
-
-#endif
diff --git a/include/effects/SkGradientShader.h b/include/effects/SkGradientShader.h
index d9276c9ad9..a5b4f29b76 100644
--- a/include/effects/SkGradientShader.h
+++ b/include/effects/SkGradientShader.h
@@ -10,8 +10,6 @@
#include "SkShader.h"
-class SkUnitMapper;
-
/** \class SkGradientShader
SkGradientShader hosts factories for creating subclasses of SkShader that
@@ -43,21 +41,16 @@ public:
intermediate values must be strictly increasing.
@param count Must be >=2. The number of colors (and pos if not NULL) entries.
@param mode The tiling mode
- @param mapper May be NULL. Callback to modify the spread of the colors.
*/
static SkShader* CreateLinear(const SkPoint pts[2],
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
- SkUnitMapper* mapper = NULL,
- uint32_t flags = 0,
- const SkMatrix* localMatrix = NULL);
+ uint32_t flags, const SkMatrix* localMatrix);
static SkShader* CreateLinear(const SkPoint pts[2],
const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags,
- const SkMatrix* localMatrix) {
- return CreateLinear(pts, colors, pos, count, mode, NULL, flags, localMatrix);
+ SkShader::TileMode mode) {
+ return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
}
/** Returns a shader that generates a radial gradient given the center and radius.
@@ -75,21 +68,16 @@ public:
intermediate values must be strictly increasing.
@param count Must be >= 2. The number of colors (and pos if not NULL) entries
@param mode The tiling mode
- @param mapper May be NULL. Callback to modify the spread of the colors.
*/
static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
- SkUnitMapper* mapper = NULL,
- uint32_t flags = 0,
- const SkMatrix* localMatrix = NULL);
+ uint32_t flags, const SkMatrix* localMatrix);
static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags,
- const SkMatrix* localMatrix) {
- return CreateRadial(center, radius, colors, pos, count, mode, NULL, flags, localMatrix);
+ SkShader::TileMode mode) {
+ return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
}
/** Returns a shader that generates a radial gradient given the start position, start radius, end position and end radius.
@@ -110,30 +98,19 @@ public:
intermediate values must be strictly increasing.
@param count Must be >= 2. The number of colors (and pos if not NULL) entries
@param mode The tiling mode
- @param mapper May be NULL. Callback to modify the spread of the colors.
*/
- static SkShader* CreateTwoPointRadial(const SkPoint& start,
- SkScalar startRadius,
- const SkPoint& end,
- SkScalar endRadius,
- const SkColor colors[],
- const SkScalar pos[], int count,
+ static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
- SkUnitMapper* mapper = NULL,
- uint32_t flags = 0,
- const SkMatrix* localMatrix = NULL);
-
- static SkShader* CreateTwoPointRadial(const SkPoint& start,
- SkScalar startRadius,
- const SkPoint& end,
- SkScalar endRadius,
- const SkColor colors[],
- const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags,
- const SkMatrix* localMatrix) {
+ uint32_t flags, const SkMatrix* localMatrix);
+
+ static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
- NULL, flags, localMatrix);
+ 0, NULL);
}
/**
@@ -142,28 +119,18 @@ public:
* two circles according to the following HTML spec.
* http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
*/
- static SkShader* CreateTwoPointConical(const SkPoint& start,
- SkScalar startRadius,
- const SkPoint& end,
- SkScalar endRadius,
- const SkColor colors[],
- const SkScalar pos[], int count,
+ static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
- SkUnitMapper* mapper = NULL,
- uint32_t flags = 0,
- const SkMatrix* localMatrix = NULL);
-
- static SkShader* CreateTwoPointConical(const SkPoint& start,
- SkScalar startRadius,
- const SkPoint& end,
- SkScalar endRadius,
- const SkColor colors[],
- const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags,
- const SkMatrix* localMatrix) {
+ uint32_t flags, const SkMatrix* localMatrix);
+
+ static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
- NULL, flags, localMatrix);
+ 0, NULL);
}
/** Returns a shader that generates a sweep gradient given a center.
@@ -180,18 +147,14 @@ public:
If this is not null, the values must begin with 0, end with 1.0, and
intermediate values must be strictly increasing.
@param count Must be >= 2. The number of colors (and pos if not NULL) entries
- @param mapper May be NULL. Callback to modify the spread of the colors.
*/
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
- const SkColor colors[], const SkScalar pos[],
- int count, SkUnitMapper* mapper = NULL,
- uint32_t flags = 0,
- const SkMatrix* localMatrix = NULL);
+ const SkColor colors[], const SkScalar pos[], int count,
+ uint32_t flags, const SkMatrix* localMatrix);
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
- const SkColor colors[], const SkScalar pos[], int count,
- uint32_t flags, const SkMatrix* localMatrix) {
- return CreateSweep(cx, cy, colors, pos, count, NULL, flags, localMatrix);
+ const SkColor colors[], const SkScalar pos[], int count) {
+ return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
}
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index ea1f143288..92fe258dd6 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -36,7 +36,6 @@
#include "SkRandom.h"
#include "SkTransparentShader.h"
#include "SkTypeface.h"
-#include "SkUnitMappers.h"
#include "SkUtils.h"
#include "SkXfermode.h"
@@ -368,10 +367,8 @@ protected:
SkScalar* linearPos = NULL;
int linearCount = 2;
SkShader::TileMode linearMode = SkShader::kMirror_TileMode;
- SkUnitMapper* linearMapper = new SkDiscreteMapper(3);
- SkAutoUnref unmapLinearMapper(linearMapper);
SkShader* linear = SkGradientShader::CreateLinear(linearPoints,
- linearColors, linearPos, linearCount, linearMode, linearMapper);
+ linearColors, linearPos, linearCount, linearMode);
SkPoint radialCenter = { SkIntToScalar(25), SkIntToScalar(25) };
SkScalar radialRadius = SkIntToScalar(25);
@@ -379,11 +376,9 @@ protected:
SkScalar radialPos[] = { 0, SkIntToScalar(3) / 5, SkIntToScalar(1)};
int radialCount = 3;
SkShader::TileMode radialMode = SkShader::kRepeat_TileMode;
- SkUnitMapper* radialMapper = new SkCosineMapper();
- SkAutoUnref unmapRadialMapper(radialMapper);
SkShader* radial = SkGradientShader::CreateRadial(radialCenter,
radialRadius, radialColors, radialPos, radialCount,
- radialMode, radialMapper);
+ radialMode);
SkTransparentShader* transparentShader = new SkTransparentShader();
SkEmbossMaskFilter::Light light;
diff --git a/samplecode/SampleGradients.cpp b/samplecode/SampleGradients.cpp
index fead71473f..f328d761a5 100644
--- a/samplecode/SampleGradients.cpp
+++ b/samplecode/SampleGradients.cpp
@@ -13,8 +13,7 @@
static SkShader* setgrad(const SkRect& r, SkColor c0, SkColor c1) {
SkColor colors[] = { c0, c1 };
SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
- return SkGradientShader::CreateLinear(pts, colors, NULL, 2,
- SkShader::kClamp_TileMode, NULL);
+ return SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
}
static void test_alphagradients(SkCanvas* canvas) {
@@ -64,32 +63,26 @@ static const GradData gGradData[] = {
{ 5, gColors, gPos2 }
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+static SkShader* MakeSweep(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::CreateSweep(center.fX, center.fY, data.fColors,
- data.fPos, data.fCount, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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));
@@ -98,22 +91,22 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
static SkShader* Make2RadialConcentric(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+ SkShader::TileMode tm) {
SkPoint center;
center.set(SkScalarAve(pts[0].fX, pts[1].fX),
SkScalarAve(pts[0].fY, pts[1].fY));
return SkGradientShader::CreateTwoPointRadial(
center, (pts[1].fX - pts[0].fX) / 7,
center, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial, Make2RadialConcentric
};
@@ -154,7 +147,7 @@ protected:
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
SkShader* shader;
- shader = gGradMakers[j](pts, gGradData[i], (SkShader::TileMode)tm, NULL);
+ shader = gGradMakers[j](pts, gGradData[i], (SkShader::TileMode)tm);
paint.setShader(shader)->unref();
canvas->drawRect(r, paint);
canvas->translate(0, SkIntToScalar(120));
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp
index 51f02a1ade..43f5d4236a 100644
--- a/samplecode/SampleLayers.cpp
+++ b/samplecode/SampleLayers.cpp
@@ -31,7 +31,7 @@ static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) {
SkColor colors[] = { 0, SK_ColorWHITE };
SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode,
- NULL, 0, &localMatrix);
+ 0, &localMatrix);
paint->setShader(s)->unref();
paint->setXfermodeMode(SkXfermode::kDstIn_Mode);
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 09eb42f6aa..fe94bbfd52 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -42,7 +42,7 @@ static SkShader* make_shader1(const SkIPoint& size) {
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::CreateLinear(pts, colors, NULL,
- SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
+ SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/samplecode/SampleShaderText.cpp b/samplecode/SampleShaderText.cpp
index c7048ab401..6f23a0b6b3 100644
--- a/samplecode/SampleShaderText.cpp
+++ b/samplecode/SampleShaderText.cpp
@@ -1,15 +1,14 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SampleCode.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
static void makebm(SkBitmap* bm, int w, int h) {
bm->allocN32Pixels(w, h);
@@ -22,15 +21,9 @@ static void makebm(SkBitmap* bm, int w, int h) {
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-
- SkAutoUnref au(um);
-
paint.setDither(true);
paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
@@ -60,32 +53,26 @@ static const GradData gGradData[] = {
{ 5, gColors, NULL },
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+static SkShader* MakeSweep(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::CreateSweep(center.fX, center.fY, data.fColors,
- data.fPos, data.fCount, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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));
@@ -94,11 +81,11 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
+
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial
};
@@ -152,8 +139,7 @@ protected:
for (size_t m = 0; m < SK_ARRAY_COUNT(gGradMakers); ++m) {
shaders[shdIdx++] = gGradMakers[m](pts,
gGradData[d],
- SkShader::kClamp_TileMode,
- NULL);
+ SkShader::kClamp_TileMode);
}
}
for (size_t tx = 0; tx < SK_ARRAY_COUNT(tileModes); ++tx) {
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index d828ae601f..6bc9a28fd3 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -178,32 +178,26 @@ static const GradData gGradData[] = {
{ 5, gColors, gPos2 }
};
-static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
- return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
- data.fCount, tm, mapper);
+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 SkShader* MakeRadial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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, mapper);
+ data.fPos, data.fCount, tm);
}
-static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+static SkShader* MakeSweep(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::CreateSweep(center.fX, center.fY, data.fColors,
- data.fPos, data.fCount, mapper);
+ return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
}
-static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper) {
+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));
@@ -212,11 +206,10 @@ static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
return SkGradientShader::CreateTwoPointRadial(
center1, (pts[1].fX - pts[0].fX) / 7,
center0, (pts[1].fX - pts[0].fX) / 2,
- data.fColors, data.fPos, data.fCount, tm, mapper);
+ data.fColors, data.fPos, data.fCount, tm);
}
-typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data,
- SkShader::TileMode tm, SkUnitMapper* mapper);
+typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkShader::TileMode tm);
static const GradMaker gGradMakers[] = {
MakeLinear, MakeRadial, MakeSweep, Make2Radial
};
@@ -236,7 +229,7 @@ static void gradient_slide(SkCanvas* canvas) {
for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
canvas->save();
for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
- SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL);
+ SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
paint.setShader(shader);
canvas->drawRect(r, paint);
shader->unref();
@@ -335,7 +328,7 @@ static SkShader* make_shader1(const SkIPoint& size) {
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::CreateLinear(pts, colors, NULL,
- SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
+ SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode);
}
class Rec {
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index cc3b52915d..a59a8021b6 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -21,7 +21,6 @@
// effects
#include "SkGradientShader.h"
-#include "SkUnitMappers.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
@@ -35,16 +34,9 @@ static void makebm(SkBitmap* bm, SkColorType ct, int w, int h) {
SkScalar pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
SkPaint paint;
- SkUnitMapper* um = NULL;
-
- um = new SkCosineMapper;
-// um = new SkDiscreteMapper(12);
-
- SkAutoUnref au(um);
-
paint.setDither(true);
paint.setShader(SkGradientShader::CreateLinear(pts, colors, pos,
- SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode, um))->unref();
+ SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode))->unref();
canvas.drawPaint(paint);
}
diff --git a/samplecode/SampleUnitMapper.cpp b/samplecode/SampleUnitMapper.cpp
deleted file mode 100644
index db9af09f38..0000000000
--- a/samplecode/SampleUnitMapper.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SampleCode.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkDevice.h"
-#include "SkPaint.h"
-#include "SkUnitMappers.h"
-#include "SkCubicInterval.h"
-
-#include "SkWidgetViews.h"
-
-static SkStaticTextView* make_textview(SkView* parent,
- const SkRect& bounds,
- const SkPaint& paint) {
- SkStaticTextView* view = new SkStaticTextView;
- view->setMode(SkStaticTextView::kFixedSize_Mode);
- view->setPaint(paint);
- view->setVisibleP(true);
- view->setSize(bounds.width(), bounds.height());
- view->setLoc(bounds.fLeft, bounds.fTop);
- parent->attachChildToFront(view)->unref();
- return view;
-}
-
-static void set_scalar(SkStaticTextView* view, SkScalar value) {
- SkString str;
- str.appendScalar(value);
- view->setText(str);
-}
-
-class UnitMapperView : public SampleView {
- SkPoint fPts[4];
- SkMatrix fMatrix;
- SkStaticTextView* fViews[4];
-
- void setViews() {
- set_scalar(fViews[0], fPts[1].fX);
- set_scalar(fViews[1], fPts[1].fY);
- set_scalar(fViews[2], fPts[2].fX);
- set_scalar(fViews[3], fPts[2].fY);
- }
-
-public:
- UnitMapperView() {
- fPts[0].set(0, 0);
- fPts[1].set(SK_Scalar1 / 3, SK_Scalar1 / 3);
- fPts[2].set(SK_Scalar1 * 2 / 3, SK_Scalar1 * 2 / 3);
- fPts[3].set(SK_Scalar1, SK_Scalar1);
-
- fMatrix.setScale(SK_Scalar1 * 200, -SK_Scalar1 * 200);
- fMatrix.postTranslate(SkIntToScalar(100), SkIntToScalar(300));
-
- SkRect r = {
- SkIntToScalar(350), SkIntToScalar(100),
- SkIntToScalar(500), SkIntToScalar(130)
- };
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setTextSize(SkIntToScalar(25));
- for (int i = 0; i < 4; i++) {
- fViews[i] = make_textview(this, r, paint);
- r.offset(0, r.height());
- }
- this->setViews();
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "UnitMapper");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(0xFF8888FF);
-
- SkRect r = { 0, 0, SK_Scalar1, SK_Scalar1 };
-
- canvas->concat(fMatrix);
- canvas->drawRect(r, paint);
-
- paint.setColor(SK_ColorBLACK);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(0);
- paint.setStrokeCap(SkPaint::kRound_Cap);
-
- SkPath path;
- path.moveTo(fPts[0]);
- path.cubicTo(fPts[1], fPts[2], fPts[3]);
- canvas->drawPath(path, paint);
-
- paint.setColor(SK_ColorRED);
- paint.setStrokeWidth(0);
- canvas->drawLine(0, 0, SK_Scalar1, SK_Scalar1, paint);
-
- paint.setColor(SK_ColorBLUE);
- paint.setStrokeWidth(SK_Scalar1 / 60);
- for (int i = 0; i < 50; i++) {
- SkScalar x = i * SK_Scalar1 / 49;
- canvas->drawPoint(x, SkEvalCubicInterval(&fPts[1], x), paint);
- }
-
- paint.setStrokeWidth(SK_Scalar1 / 20);
- paint.setColor(SK_ColorGREEN);
- canvas->drawPoints(SkCanvas::kPoints_PointMode, 2, &fPts[1], paint);
- }
-
- bool invertPt(SkScalar x, SkScalar y, SkPoint* result) {
- if (NULL == result)
- return true;
-
- SkMatrix m;
- if (!fMatrix.invert(&m)) {
- return false;
- }
-
- m.mapXY(x, y, result);
- return true;
- }
-
- int hittest(SkScalar x, SkScalar y) {
- SkPoint target = { x, y };
- SkPoint pts[2] = { fPts[1], fPts[2] };
- fMatrix.mapPoints(pts, 2);
- for (int i = 0; i < 2; i++) {
- if (SkPoint::Distance(pts[i], target) < SkIntToScalar(4)) {
- return i + 1;
- }
- }
- return -1;
- }
-
- virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) SK_OVERRIDE {
- fDragIndex = hittest(x, y);
- return fDragIndex >= 0 ? new Click(this) : NULL;
- }
-
- virtual bool onClick(Click* click) {
- if (fDragIndex >= 0) {
- if (!invertPt(click->fCurr.fX, click->fCurr.fY,
- &fPts[fDragIndex])) {
- return false;
- }
-
- this->setViews();
- this->inval(NULL);
- return true;
- }
- return false;
- }
-
-private:
- int fDragIndex;
-
- typedef SampleView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new UnitMapperView; }
-static SkViewRegister reg(MyFactory);
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index 4c3a17eb00..1e568f5568 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -47,7 +47,7 @@ static SkShader* make_shader1(const SkIPoint& size) {
{ SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
return SkGradientShader::CreateLinear(pts, colors, NULL,
- SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
+ SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode);
}
class VerticesView : public SampleView {
diff --git a/src/animator/SkDrawGradient.cpp b/src/animator/SkDrawGradient.cpp
index c11559581b..70e5e4493e 100644
--- a/src/animator/SkDrawGradient.cpp
+++ b/src/animator/SkDrawGradient.cpp
@@ -11,49 +11,6 @@
#include "SkAnimateMaker.h"
#include "SkAnimatorScript.h"
#include "SkGradientShader.h"
-#include "SkUnitMapper.h"
-
-static SkScalar SkUnitToScalar(U16CPU x) {
- return x / 65535.0f;
-}
-
-static U16CPU SkScalarToUnit(SkScalar x) {
- SkScalar pin = SkScalarPin(x, 0, SK_Scalar1);
- return (int) (pin * 65535.0f);
-}
-
-class SkDrawGradientUnitMapper : public SkUnitMapper {
-public:
- SkDrawGradientUnitMapper(SkAnimateMaker* maker, const char* script) : fMaker(maker), fScript(script) {
- }
-
- SK_DECLARE_UNFLATTENABLE_OBJECT()
-
-protected:
- virtual uint16_t mapUnit16(uint16_t x) {
- fUnit = SkUnitToScalar(x);
- SkScriptValue value;
- SkAnimatorScript engine(*fMaker, NULL, SkType_Float);
- engine.propertyCallBack(GetUnitValue, &fUnit);
- if (engine.evaluate(fScript, &value, SkType_Float))
- x = SkScalarToUnit(value.fOperand.fScalar);
- return x;
- }
-
- static bool GetUnitValue(const char* token, size_t len, void* unitPtr, SkScriptValue* value) {
- if (SK_LITERAL_STR_EQUAL("unit", token, len)) {
- value->fOperand.fScalar = *(SkScalar*) unitPtr;
- value->fType = SkType_Float;
- return true;
- }
- return false;
- }
-
- SkAnimateMaker* fMaker;
- const char* fScript;
- SkScalar fUnit;
-};
-
#if SK_USE_CONDENSED_INFO == 0
@@ -67,13 +24,12 @@ const SkMemberInfo SkDrawGradient::fInfo[] = {
DEFINE_GET_MEMBER(SkDrawGradient);
-SkDrawGradient::SkDrawGradient() : fUnitMapper(NULL) {
+SkDrawGradient::SkDrawGradient() {
}
SkDrawGradient::~SkDrawGradient() {
for (int index = 0; index < fDrawColors.count(); index++)
delete fDrawColors[index];
- delete fUnitMapper;
}
bool SkDrawGradient::addChild(SkAnimateMaker& , SkDisplayable* child) {
@@ -138,8 +94,6 @@ void SkDrawGradient::onEndElement(SkAnimateMaker& maker) {
}
}
}
- if (unitMapper.size() > 0)
- fUnitMapper = new SkDrawGradientUnitMapper(&maker, unitMapper.c_str());
INHERITED::onEndElement(maker);
}
@@ -176,7 +130,7 @@ SkShader* SkDrawLinearGradient::getShader() {
return NULL;
SkShader* shader = SkGradientShader::CreateLinear((SkPoint*)points.begin(),
fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode,
- fUnitMapper, 0, getMatrix());
+ 0, getMatrix());
SkAutoTDelete<SkShader> autoDel(shader);
(void)autoDel.detach();
return shader;
@@ -211,7 +165,7 @@ SkShader* SkDrawRadialGradient::getShader() {
return NULL;
SkShader* shader = SkGradientShader::CreateRadial(center,
radius, fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode,
- fUnitMapper, 0, getMatrix());
+ 0, getMatrix());
SkAutoTDelete<SkShader> autoDel(shader);
(void)autoDel.detach();
return shader;
diff --git a/src/animator/SkDrawGradient.h b/src/animator/SkDrawGradient.h
index ff79e3fb91..fa46a9e629 100644
--- a/src/animator/SkDrawGradient.h
+++ b/src/animator/SkDrawGradient.h
@@ -14,8 +14,6 @@
#include "SkDrawShader.h"
#include "SkIntArray.h"
-class SkUnitMapper;
-
class SkDrawGradient : public SkDrawShader {
DECLARE_PRIVATE_MEMBER_INFO(DrawGradient);
SkDrawGradient();
@@ -30,7 +28,6 @@ protected:
SkString unitMapper;
SkTDColorArray fColors;
SkTDDrawColorArray fDrawColors;
- SkUnitMapper* fUnitMapper;
int addPrelude();
private:
typedef SkDrawShader INHERITED;
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index d016d9c980..c32c7bd658 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -335,3 +335,25 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
}
return obj;
}
+
+/**
+ * Needs to follow the same pattern as readFlattenable(), but explicitly skip whatever data
+ * has been written.
+ */
+void SkReadBuffer::skipFlattenable() {
+ if (fFactoryCount > 0) {
+ if (0 == fReader.readU32()) {
+ return;
+ }
+ } else if (fFactoryTDArray) {
+ if (0 == fReader.readU32()) {
+ return;
+ }
+ } else {
+ if (NULL == this->readFunctionPtr()) {
+ return;
+ }
+ }
+ uint32_t sizeRecorded = fReader.readU32();
+ fReader.skip(sizeRecorded);
+}
diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp
index 0112f18ec4..96f20a2483 100644
--- a/src/core/SkValidatingReadBuffer.cpp
+++ b/src/core/SkValidatingReadBuffer.cpp
@@ -273,3 +273,15 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type)
}
return obj;
}
+
+void SkValidatingReadBuffer::skipFlattenable() {
+ SkString name;
+ this->readString(&name);
+ if (fError) {
+ return;
+ }
+ uint32_t sizeRecorded = this->readUInt();
+ this->skip(sizeRecorded);
+}
+
+
diff --git a/src/core/SkValidatingReadBuffer.h b/src/core/SkValidatingReadBuffer.h
index d5e192e1c7..12f5413109 100644
--- a/src/core/SkValidatingReadBuffer.h
+++ b/src/core/SkValidatingReadBuffer.h
@@ -40,6 +40,7 @@ public:
// common data structures
virtual SkFlattenable* readFlattenable(SkFlattenable::Type type) SK_OVERRIDE;
+ virtual void skipFlattenable() SK_OVERRIDE;
virtual void readPoint(SkPoint* point) SK_OVERRIDE;
virtual void readMatrix(SkMatrix* matrix) SK_OVERRIDE;
virtual void readIRect(SkIRect* rect) SK_OVERRIDE;
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index d376b22236..38e9210cb3 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -17,8 +17,6 @@ SkGradientShaderBase::SkGradientShaderBase(const Descriptor& desc, const SkMatri
{
SkASSERT(desc.fCount > 1);
- fMapper = desc.fMapper;
- SkSafeRef(fMapper);
fGradFlags = SkToU8(desc.fGradFlags);
SkASSERT((unsigned)desc.fTileMode < SkShader::kTileModeCount);
@@ -142,7 +140,10 @@ static uint32_t unpack_flags(uint32_t packed) {
}
SkGradientShaderBase::SkGradientShaderBase(SkReadBuffer& buffer) : INHERITED(buffer) {
- fMapper = buffer.readUnitMapper();
+ if (buffer.isVersionLT(SkReadBuffer::kNoUnitMappers_Version)) {
+ // skip the old SkUnitMapper slot
+ buffer.skipFlattenable();
+ }
int colorCount = fColorCount = buffer.getArrayCount();
if (colorCount > kColorStorageCount) {
@@ -181,7 +182,6 @@ SkGradientShaderBase::~SkGradientShaderBase() {
if (fOrigColors != fStorage) {
sk_free(fOrigColors);
}
- SkSafeUnref(fMapper);
}
void SkGradientShaderBase::initCommon() {
@@ -194,7 +194,6 @@ void SkGradientShaderBase::initCommon() {
void SkGradientShaderBase::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
- buffer.writeFlattenable(fMapper);
buffer.writeColorArray(fOrigColors, fColorCount);
buffer.writeUInt(pack_mode_flags(fTileMode, fGradFlags));
if (fColorCount > 2) {
@@ -528,20 +527,6 @@ void SkGradientShaderBase::GradientShaderCache::initCache16(GradientShaderCache*
prevIndex = nextIndex;
}
}
-
- if (cache->fShader.fMapper) {
- cache->fCache16Storage = (uint16_t*)sk_malloc_throw(allocSize);
- uint16_t* linear = cache->fCache16; // just computed linear data
- uint16_t* mapped = cache->fCache16Storage; // storage for mapped data
- SkUnitMapper* map = cache->fShader.fMapper;
- for (int i = 0; i < kCache16Count; i++) {
- int index = map->mapUnit16(bitsTo16(i, kCache16Bits)) >> kCache16Shift;
- mapped[i] = linear[index];
- mapped[i + kCache16Count] = linear[index + kCache16Count];
- }
- sk_free(cache->fCache16);
- cache->fCache16 = cache->fCache16Storage;
- }
}
const SkPMColor* SkGradientShaderBase::GradientShaderCache::getCache32() {
@@ -579,23 +564,6 @@ void SkGradientShaderBase::GradientShaderCache::initCache32(GradientShaderCache*
prevIndex = nextIndex;
}
}
-
- if (cache->fShader.fMapper) {
- SkMallocPixelRef* newPR = SkMallocPixelRef::NewAllocate(info, 0, NULL);
- SkPMColor* linear = cache->fCache32; // just computed linear data
- SkPMColor* mapped = (SkPMColor*)newPR->getAddr(); // storage for mapped data
- SkUnitMapper* map = cache->fShader.fMapper;
- for (int i = 0; i < kCache32Count; i++) {
- int index = map->mapUnit16((i << 8) | i) >> 8;
- mapped[i + kCache32Count*0] = linear[index + kCache32Count*0];
- mapped[i + kCache32Count*1] = linear[index + kCache32Count*1];
- mapped[i + kCache32Count*2] = linear[index + kCache32Count*2];
- mapped[i + kCache32Count*3] = linear[index + kCache32Count*3];
- }
- cache->fCache32PixelRef->unref();
- cache->fCache32PixelRef = newPR;
- cache->fCache32 = (SkPMColor*)newPR->getAddr();
- }
}
/*
@@ -627,15 +595,6 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
// built with 0xFF
SkAutoTUnref<GradientShaderCache> cache(this->refCache(0xFF));
- // don't have a way to put the mapper into our cache-key yet
- if (fMapper) {
- // force our cache32pixelref to be built
- (void)cache->getCache32();
- bitmap->setConfig(SkImageInfo::MakeN32Premul(kCache32Count, 1));
- bitmap->setPixelRef(cache->getCache32PixelRef());
- return;
- }
-
// build our key: [numColors + colors[] + {positions[]} + flags ]
int count = 1 + fColorCount + 1;
if (fColorCount > 2) {
@@ -744,8 +703,6 @@ void SkGradientShaderBase::toString(SkString* str) const {
str->append(" ");
str->append(gTileModeName[fTileMode]);
- // TODO: add "fMapper->toString(str);" when SkUnitMapper::toString is added
-
this->INHERITED::toString(str);
}
#endif
@@ -770,13 +727,11 @@ void SkGradientShaderBase::toString(SkString* str) const {
static void desc_init(SkGradientShaderBase::Descriptor* desc,
const SkColor colors[],
const SkScalar pos[], int colorCount,
- SkShader::TileMode mode,
- SkUnitMapper* mapper, uint32_t flags) {
+ SkShader::TileMode mode, uint32_t flags) {
desc->fColors = colors;
desc->fPos = pos;
desc->fCount = colorCount;
desc->fTileMode = mode;
- desc->fMapper = mapper;
desc->fGradFlags = flags;
}
@@ -784,7 +739,6 @@ SkShader* SkGradientShader::CreateLinear(const SkPoint pts[2],
const SkColor colors[],
const SkScalar pos[], int colorCount,
SkShader::TileMode mode,
- SkUnitMapper* mapper,
uint32_t flags,
const SkMatrix* localMatrix) {
if (NULL == pts || NULL == colors || colorCount < 1) {
@@ -793,7 +747,7 @@ SkShader* SkGradientShader::CreateLinear(const SkPoint pts[2],
EXPAND_1_COLOR(colorCount);
SkGradientShaderBase::Descriptor desc;
- desc_init(&desc, colors, pos, colorCount, mode, mapper, flags);
+ desc_init(&desc, colors, pos, colorCount, mode, flags);
return SkNEW_ARGS(SkLinearGradient, (pts, desc, localMatrix));
}
@@ -801,7 +755,6 @@ SkShader* SkGradientShader::CreateRadial(const SkPoint& center, SkScalar radius,
const SkColor colors[],
const SkScalar pos[], int colorCount,
SkShader::TileMode mode,
- SkUnitMapper* mapper,
uint32_t flags,
const SkMatrix* localMatrix) {
if (radius <= 0 || NULL == colors || colorCount < 1) {
@@ -810,7 +763,7 @@ SkShader* SkGradientShader::CreateRadial(const SkPoint& center, SkScalar radius,
EXPAND_1_COLOR(colorCount);
SkGradientShaderBase::Descriptor desc;
- desc_init(&desc, colors, pos, colorCount, mode, mapper, flags);
+ desc_init(&desc, colors, pos, colorCount, mode, flags);
return SkNEW_ARGS(SkRadialGradient, (center, radius, desc, localMatrix));
}
@@ -822,7 +775,6 @@ SkShader* SkGradientShader::CreateTwoPointRadial(const SkPoint& start,
const SkScalar pos[],
int colorCount,
SkShader::TileMode mode,
- SkUnitMapper* mapper,
uint32_t flags,
const SkMatrix* localMatrix) {
if (startRadius < 0 || endRadius < 0 || NULL == colors || colorCount < 1) {
@@ -831,7 +783,7 @@ SkShader* SkGradientShader::CreateTwoPointRadial(const SkPoint& start,
EXPAND_1_COLOR(colorCount);
SkGradientShaderBase::Descriptor desc;
- desc_init(&desc, colors, pos, colorCount, mode, mapper, flags);
+ desc_init(&desc, colors, pos, colorCount, mode, flags);
return SkNEW_ARGS(SkTwoPointRadialGradient,
(start, startRadius, end, endRadius, desc, localMatrix));
}
@@ -844,7 +796,6 @@ SkShader* SkGradientShader::CreateTwoPointConical(const SkPoint& start,
const SkScalar pos[],
int colorCount,
SkShader::TileMode mode,
- SkUnitMapper* mapper,
uint32_t flags,
const SkMatrix* localMatrix) {
if (startRadius < 0 || endRadius < 0 || NULL == colors || colorCount < 1) {
@@ -861,7 +812,7 @@ SkShader* SkGradientShader::CreateTwoPointConical(const SkPoint& start,
SkGradientShaderBase::Descriptor desc;
if (!flipGradient) {
- desc_init(&desc, colors, pos, colorCount, mode, mapper, flags);
+ desc_init(&desc, colors, pos, colorCount, mode, flags);
return SkNEW_ARGS(SkTwoPointConicalGradient,
(start, startRadius, end, endRadius, flipGradient, desc, localMatrix));
} else {
@@ -875,9 +826,9 @@ SkShader* SkGradientShader::CreateTwoPointConical(const SkPoint& start,
for (int i = 0; i < colorCount; ++i) {
posNew[i] = 1 - pos[colorCount - i - 1];
}
- desc_init(&desc, colorsNew.get(), posNew.get(), colorCount, mode, mapper, flags);
+ desc_init(&desc, colorsNew.get(), posNew.get(), colorCount, mode, flags);
} else {
- desc_init(&desc, colorsNew.get(), NULL, colorCount, mode, mapper, flags);
+ desc_init(&desc, colorsNew.get(), NULL, colorCount, mode, flags);
}
return SkNEW_ARGS(SkTwoPointConicalGradient,
@@ -888,7 +839,7 @@ SkShader* SkGradientShader::CreateTwoPointConical(const SkPoint& start,
SkShader* SkGradientShader::CreateSweep(SkScalar cx, SkScalar cy,
const SkColor colors[],
const SkScalar pos[],
- int colorCount, SkUnitMapper* mapper,
+ int colorCount,
uint32_t flags,
const SkMatrix* localMatrix) {
if (NULL == colors || colorCount < 1) {
@@ -897,7 +848,7 @@ SkShader* SkGradientShader::CreateSweep(SkScalar cx, SkScalar cy,
EXPAND_1_COLOR(colorCount);
SkGradientShaderBase::Descriptor desc;
- desc_init(&desc, colors, pos, colorCount, SkShader::kClamp_TileMode, mapper, flags);
+ desc_init(&desc, colors, pos, colorCount, SkShader::kClamp_TileMode, flags);
return SkNEW_ARGS(SkSweepGradient, (cx, cy, desc, localMatrix));
}
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index a699c4ce00..9613537803 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -14,7 +14,6 @@
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkMallocPixelRef.h"
-#include "SkUnitMapper.h"
#include "SkUtils.h"
#include "SkTemplates.h"
#include "SkBitmapCache.h"
@@ -94,7 +93,6 @@ public:
const SkScalar* fPos;
int fCount;
SkShader::TileMode fTileMode;
- SkUnitMapper* fMapper;
uint32_t fGradFlags;
};
@@ -201,7 +199,6 @@ protected:
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
SK_TO_STRING_OVERRIDE()
- SkUnitMapper* fMapper;
SkMatrix fPtsToUnit; // set by subclass
TileMode fTileMode;
TileProc fTileProc;
diff --git a/src/utils/SkUnitMappers.cpp b/src/utils/SkUnitMappers.cpp
deleted file mode 100644
index 336a26e164..0000000000
--- a/src/utils/SkUnitMappers.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "SkUnitMappers.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-
-
-SkDiscreteMapper::SkDiscreteMapper(int segments) {
- if (segments < 2) {
- fSegments = 0;
- fScale = 0;
- } else {
- if (segments > 0xFFFF) {
- segments = 0xFFFF;
- }
- fSegments = segments;
- fScale = (1 << 30) / (segments - 1);
- }
-}
-
-uint16_t SkDiscreteMapper::mapUnit16(uint16_t input) {
- SkFixed x = input * fSegments >> 16;
- x = x * fScale >> 14;
- x += x << 15 >> 31; // map 0x10000 to 0xFFFF
- return SkToU16(x);
-}
-
-SkDiscreteMapper::SkDiscreteMapper(SkReadBuffer& rb)
- : SkUnitMapper(rb) {
- fSegments = rb.readInt();
- fScale = rb.read32();
-}
-
-void SkDiscreteMapper::flatten(SkWriteBuffer& wb) const {
- this->INHERITED::flatten(wb);
-
- wb.writeInt(fSegments);
- wb.write32(fScale);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-uint16_t SkCosineMapper::mapUnit16(uint16_t input)
-{
- /* we want to call cosine(input * pi/2) treating input as [0...1)
- however, the straight multitply would overflow 32bits since input is
- 16bits and pi/2 is 17bits, so we shift down our pi const before we mul
- */
- SkFixed rads = (unsigned)(input * (SK_FixedPI >> 2)) >> 15;
- SkFixed x = SkFixedCos(rads);
- x += x << 15 >> 31; // map 0x10000 to 0xFFFF
- return SkToU16(x);
-}
-
-SkCosineMapper::SkCosineMapper(SkReadBuffer& rb)
- : SkUnitMapper(rb) {}
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index a5a763a9cb..9ffb790507 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -359,7 +359,7 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
const SkColor colors[2] = {SK_ColorWHITE, SK_ColorWHITE};
const SkScalar pos[2] = {0, SK_Scalar1};
SkShader* shader = SkGradientShader::CreateTwoPointConical(
- pt1, r1, pt2, r2, colors, pos, 2, SkShader::kClamp_TileMode, NULL);
+ pt1, r1, pt2, r2, colors, pos, 2, SkShader::kClamp_TileMode);
paint.setShader(shader)->unref();
canvas->drawRect(fullRect, paint);
REPORTER_ASSERT(reporter, !canvas->isFreshFrame());