remove unused (by clients) SkUnitMapper

BUG=skia:
R=robertphillips@google.com, scroggo@google.com, george@mozilla.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/283273002

git-svn-id: http://skia.googlecode.com/svn/trunk@14761 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-05-16 13:35:01 +00:00
parent 61744ec1d2
commit ee0cac336c
48 changed files with 341 additions and 745 deletions

View File

@ -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;
}

View File

@ -41,3 +41,16 @@ canvas-layer-state
# bsalomon: https://codereview.chromium.org/264303008/
# bsalomon@ will rebaseline this test
ninepatch-stretch
# 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

View File

@ -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);

View File

@ -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"

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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,

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -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) {

View File

@ -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();

View File

@ -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();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -13,6 +13,7 @@
# If these become 'permanent', they should be moved into skia_common.gypi
#
'skia_for_chromium_defines': [
'SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE',
'SK_SUPPORT_LEGACY_GETTOPDEVICE',
'SK_SUPPORT_LEGACY_N32_NAME',
'SK_SUPPORT_LEGACY_BUILDMIPMAP',

View File

@ -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',

View File

@ -61,7 +61,7 @@ public:
kSkPixelRef_Type,
kSkRasterizer_Type,
kSkShader_Type,
kSkUnitMapper_Type,
kSkUnused_Type, // used to be SkUnitMapper
kSkXfermode_Type,
};

View File

@ -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;

View File

@ -24,7 +24,6 @@
#include "SkReader32.h"
#include "SkRefCnt.h"
#include "SkShader.h"
#include "SkUnitMapper.h"
#include "SkWriteBuffer.h"
#include "SkXfermode.h"
@ -110,9 +109,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);

View File

@ -21,6 +21,10 @@ class SkXfermode;
class GrContext;
class GrEffectRef;
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
class SkDeadUnitMapperType;
#endif
/** \class SkShader
*
* Shaders specify the source color(s) for what is being drawn. If a paint

View File

@ -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

View File

@ -10,8 +10,6 @@
#include "SkShader.h"
class SkUnitMapper;
/** \class SkGradientShader
SkGradientShader hosts factories for creating subclasses of SkShader that
@ -43,14 +41,28 @@ 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) {
return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
}
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
static SkShader* CreateLinear(const SkPoint pts[2],
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
SkDeadUnitMapperType*, // this type is now gone
uint32_t flags,
const SkMatrix* localMatrix) {
return CreateLinear(pts, colors, pos, count, mode, flags, localMatrix);
}
#endif
/** Returns a shader that generates a radial gradient given the center and radius.
<p />
@ -67,14 +79,27 @@ 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) {
return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
}
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
SkDeadUnitMapperType*,
uint32_t flags, const SkMatrix* localMatrix) {
return CreateRadial(center, radius, colors, pos, count, mode, flags, localMatrix);
}
#endif
/** Returns a shader that generates a radial gradient given the start position, start radius, end position and end radius.
<p />
@ -94,18 +119,32 @@ 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);
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,
0, NULL);
}
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
static SkShader* CreateTwoPointRadial(const SkPoint& start, SkScalar startRadius,
const SkPoint& end, SkScalar endRadius,
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
SkDeadUnitMapperType*,
uint32_t flags, const SkMatrix* localMatrix) {
return CreateTwoPointRadial(start, startRadius, end, endRadius, colors, pos, count, mode,
flags, localMatrix);
}
#endif
/**
* Returns a shader that generates a conical gradient given two circles, or
@ -113,16 +152,31 @@ 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);
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,
0, NULL);
}
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
const SkPoint& end, SkScalar endRadius,
const SkColor colors[], const SkScalar pos[], int count,
SkShader::TileMode mode,
SkDeadUnitMapperType*,
uint32_t flags, const SkMatrix* localMatrix) {
return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
flags, localMatrix);
}
#endif
/** Returns a shader that generates a sweep gradient given a center.
<p />
@ -138,13 +192,24 @@ 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) {
return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
}
#ifdef SK_SUPPORT_LEGACY_DEADUNITMAPPERTYPE
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
const SkColor colors[], const SkScalar pos[], int count,
SkDeadUnitMapperType*,
uint32_t flags, const SkMatrix* localMatrix) {
return CreateSweep(cx, cy, colors, pos, count, flags, localMatrix);
}
#endif
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
};

View File

@ -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;

View File

@ -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));

View File

@ -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);

View File

@ -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);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -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) {

View File

@ -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 {

View File

@ -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);
}

View File

@ -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);

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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 (0 != buffer.pictureVersion() && buffer.pictureVersion() < 27) {
// 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));
}

View File

@ -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;

View File

@ -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) {}

View File

@ -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());